| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1 | /* | 
|  | 2 | * Sigma Control API DUT (station/AP) | 
|  | 3 | * Copyright (c) 2010-2011, Atheros Communications, Inc. | 
| Jouni Malinen | 9d7e31d | 2017-12-22 18:55:04 +0200 | [diff] [blame] | 4 | * Copyright (c) 2011-2017, Qualcomm Atheros, Inc. | 
| Jouni Malinen | c12ea4a | 2018-01-05 21:07:10 +0200 | [diff] [blame] | 5 | * Copyright (c) 2018, The Linux Foundation | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6 | * All Rights Reserved. | 
|  | 7 | * Licensed under the Clear BSD license. See README for more details. | 
|  | 8 | */ | 
|  | 9 |  | 
|  | 10 | #include "sigma_dut.h" | 
|  | 11 | #include <sys/stat.h> | 
|  | 12 | #include <sys/wait.h> | 
|  | 13 | #include <sys/utsname.h> | 
|  | 14 | #include <sys/ioctl.h> | 
|  | 15 | #ifdef __linux__ | 
| Adil Saeed Musthafa | 33ea287 | 2017-04-10 23:13:24 -0700 | [diff] [blame] | 16 | #include <limits.h> | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 17 | #include <dirent.h> | 
|  | 18 | #include <string.h> | 
|  | 19 | #include <sys/types.h> | 
|  | 20 | #include <unistd.h> | 
|  | 21 | #endif /* __linux__ */ | 
|  | 22 | #ifdef __QNXNTO__ | 
|  | 23 | #include <ifaddrs.h> | 
|  | 24 | #include <net/if_dl.h> | 
|  | 25 | #endif /* __QNXNTO__ */ | 
| Alexei Avshalom Lazar | 2712cc8 | 2018-12-23 16:29:14 +0200 | [diff] [blame] | 26 | #include "wpa_ctrl.h" | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 27 | #include "wpa_helpers.h" | 
|  | 28 | #ifdef ANDROID | 
|  | 29 | #include <hardware_legacy/wifi.h> | 
| Veerendranath Jakkam | d7e0008 | 2018-04-25 19:46:01 +0530 | [diff] [blame] | 30 | #include <grp.h> | 
|  | 31 | #include <pwd.h> | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 32 | #endif /* ANDROID */ | 
|  | 33 |  | 
|  | 34 | /* Temporary files for ap_send_addba_req */ | 
|  | 35 | #define VI_QOS_TMP_FILE     "/tmp/vi-qos.tmp" | 
|  | 36 | #define VI_QOS_FILE         "/tmp/vi-qos.txt" | 
|  | 37 | #define VI_QOS_REFFILE      "/etc/vi-qos.txt" | 
|  | 38 |  | 
|  | 39 | /* Configuration file name on Android */ | 
|  | 40 | #ifndef ANDROID_CONFIG_FILE | 
|  | 41 | #define ANDROID_CONFIG_FILE		"/data/misc/wifi/hostapd.conf" | 
|  | 42 | #endif /* ANDROID_CONFIG_FILE */ | 
|  | 43 | /* Maximum length of the line in the configuration file */ | 
|  | 44 | #define MAX_CONF_LINE_LEN  		(156) | 
|  | 45 |  | 
| Jouni Malinen | d6bf1b4 | 2017-06-23 17:51:01 +0300 | [diff] [blame] | 46 | #ifndef SIGMA_DUT_HOSTAPD_PID_FILE | 
|  | 47 | #define SIGMA_DUT_HOSTAPD_PID_FILE "/tmp/sigma_dut-ap-hostapd.pid" | 
|  | 48 | #endif /* SIGMA_DUT_HOSTAPD_PID_FILE */ | 
|  | 49 |  | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 50 | /* The following is taken from Hotspot 2.0 testplan Appendix B.1 */ | 
|  | 51 | #define ANQP_VENUE_NAME_1 "02019c0002083d656e6757692d466920416c6c69616e63650a3239383920436f7070657220526f61640a53616e746120436c6172612c2043412039353035312c205553415b63686957692d4669e88194e79b9fe5ae9ee9aa8ce5aea40ae4ba8ce4b99de585abe4b99de5b9b4e5ba93e69f8fe8b7af0ae59ca3e5858be68b89e68b892c20e58aa0e588a9e7a68fe5b0bce4ba9a39353035312c20e7be8ee59bbd" | 
|  | 52 | #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\"" | 
|  | 53 | #define ANQP_IP_ADDR_TYPE_1 "060101000c" | 
|  | 54 | #define ANQP_HS20_OPERATOR_FRIENDLY_NAME_1 "dddd2700506f9a11030011656e6757692d466920416c6c69616e63650e63686957692d4669e88194e79b9f" | 
|  | 55 | #define ANQP_HS20_WAN_METRICS_1 "dddd1300506f9a11040001c40900008001000000000000" | 
|  | 56 | #define ANQP_HS20_CONNECTION_CAPABILITY_1 "dddd3200506f9a1105000100000006140001061600000650000106bb010106bb060006c4130011f4010111c413001194110132000001" | 
|  | 57 | #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" | 
|  | 58 | #define QOS_MAP_SET_2 "8,15,0,7,255,255,16,31,32,39,255,255,40,47,48,63" | 
|  | 59 |  | 
| Jouni Malinen | f7ff42b | 2018-05-01 00:21:56 +0300 | [diff] [blame] | 60 | #define ADV_OF_CHARGE_1 \ | 
| Jouni Malinen | 3001b43 | 2018-05-03 18:18:15 +0300 | [diff] [blame] | 61 | "bc01000000d200454e475553443c3f786d6c2076657273696f6e3d22312e30222065" \ | 
| Jouni Malinen | f7ff42b | 2018-05-01 00:21:56 +0300 | [diff] [blame] | 62 | "6e636f64696e673d225554462d38223f3e3c506c616e20786d6c6e733d22687474703a2f2f77" \ | 
|  | 63 | "77772e77692d66692e6f72672f73706563696669636174696f6e732f686f7473706f7432646f" \ | 
|  | 64 | "74302f76312e302f616f637069223e3c4465736372697074696f6e3e57692d46692061636365" \ | 
|  | 65 | "737320666f72203120686f75722c207768696c6520796f752077616974206174207468652067" \ | 
| Jouni Malinen | 3001b43 | 2018-05-03 18:18:15 +0300 | [diff] [blame] | 66 | "6174652c2024302e39393c2f4465736372697074696f6e3e3c2f506c616e3ee3004652414341" \ | 
| Jouni Malinen | f7ff42b | 2018-05-01 00:21:56 +0300 | [diff] [blame] | 67 | "443c3f786d6c2076657273696f6e3d22312e302220656e636f64696e673d225554462d38223f" \ | 
|  | 68 | "3e3c506c616e20786d6c6e733d22687474703a2f2f7777772e77692d66692e6f72672f737065" \ | 
|  | 69 | "63696669636174696f6e732f686f7473706f7432646f74302f76312e302f616f637069223e3c" \ | 
| Jouni Malinen | 3001b43 | 2018-05-03 18:18:15 +0300 | [diff] [blame] | 70 | "4465736372697074696f6e3e416363c3a8732057692d46692070656e64616e74203120686575" \ | 
|  | 71 | "72652c2070656e64616e742071756520766f757320617474656e64657a20c3a0206c6120706f" \ | 
|  | 72 | "7274652c20302c393920243c2f4465736372697074696f6e3e3c2f506c616e3ea101010000c7" \ | 
|  | 73 | "00454e475553443c3f786d6c2076657273696f6e3d22312e302220656e636f64696e673d2255" \ | 
|  | 74 | "54462d38223f3e3c506c616e20786d6c6e733d22687474703a2f2f7777772e77692d66692e6f" \ | 
|  | 75 | "72672f73706563696669636174696f6e732f686f7473706f7432646f74302f76312e302f616f" \ | 
|  | 76 | "637069223e3c4465736372697074696f6e3e446f776e6c6f616420766964656f7320666f7220" \ | 
|  | 77 | "796f757220666c696768742c2024322e393920666f7220313047423c2f446573637269707469" \ | 
|  | 78 | "6f6e3e3c2f506c616e3ed3004652414341443c3f786d6c2076657273696f6e3d22312e302220" \ | 
|  | 79 | "656e636f64696e673d225554462d38223f3e3c506c616e20786d6c6e733d22687474703a2f2f" \ | 
|  | 80 | "7777772e77692d66692e6f72672f73706563696669636174696f6e732f686f7473706f743264" \ | 
|  | 81 | "6f74302f76312e302f616f637069223e3c4465736372697074696f6e3e54c3a96cc3a9636861" \ | 
|  | 82 | "7267657a2064657320766964c3a96f7320706f757220766f74726520766f6c2c20322c393920" \ | 
|  | 83 | "2420706f757220313020476f3c2f4465736372697074696f6e3e3c2f506c616e3ee40003002b" \ | 
|  | 84 | "736572766963652d70726f76696465722e636f6d3b66656465726174696f6e2e6578616d706c" \ | 
|  | 85 | "652e636f6db400454e475553443c3f786d6c2076657273696f6e3d22312e302220656e636f64" \ | 
|  | 86 | "696e673d225554462d38223f3e3c506c616e20786d6c6e733d22687474703a2f2f7777772e77" \ | 
|  | 87 | "692d66692e6f72672f73706563696669636174696f6e732f686f7473706f7432646f74302f76" \ | 
|  | 88 | "312e302f616f637069223e3c4465736372697074696f6e3e46726565207769746820796f7572" \ | 
|  | 89 | "20737562736372697074696f6e213c2f4465736372697074696f6e3e3c2f506c616e3e" | 
| Jouni Malinen | f7ff42b | 2018-05-01 00:21:56 +0300 | [diff] [blame] | 90 |  | 
| Alexei Avshalom Lazar | 79f5727 | 2018-12-23 17:22:47 +0200 | [diff] [blame] | 91 | /* | 
|  | 92 | * MTU for Ethernet need to take into account 8-byte SNAP header | 
|  | 93 | * to be added when encapsulating Ethernet frame into 802.11. | 
|  | 94 | */ | 
|  | 95 | #ifndef IEEE80211_MAX_DATA_LEN_DMG | 
|  | 96 | #define IEEE80211_MAX_DATA_LEN_DMG 7920 | 
|  | 97 | #endif /* IEEE80211_MAX_DATA_LEN_DMG */ | 
|  | 98 | #ifndef IEEE80211_SNAP_LEN_DMG | 
|  | 99 | #define IEEE80211_SNAP_LEN_DMG 8 | 
|  | 100 | #endif /* IEEE80211_SNAP_LEN_DMG */ | 
|  | 101 |  | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 102 | extern char *sigma_main_ifname; | 
|  | 103 | extern char *sigma_wpas_ctrl; | 
|  | 104 | extern char *sigma_hapd_ctrl; | 
|  | 105 | extern char *ap_inet_addr; | 
|  | 106 | extern char *ap_inet_mask; | 
|  | 107 | extern char *sigma_radio_ifname[]; | 
|  | 108 |  | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 109 | static int ath_ap_start_hostapd(struct sigma_dut *dut); | 
|  | 110 | static void ath_ap_set_params(struct sigma_dut *dut); | 
|  | 111 | static int kill_process(struct sigma_dut *dut, char *proc_name, | 
|  | 112 | unsigned char is_proc_instance_one, int sig); | 
|  | 113 |  | 
|  | 114 |  | 
| Jouni Malinen | 6be21c8 | 2018-08-01 18:47:24 +0300 | [diff] [blame] | 115 | static int ap_ft_enabled(struct sigma_dut *dut) | 
|  | 116 | { | 
|  | 117 | return dut->ap_ft_oa == 1 || | 
|  | 118 | dut->ap_key_mgmt == AP_WPA2_FT_EAP || | 
|  | 119 | dut->ap_key_mgmt == AP_WPA2_FT_PSK || | 
|  | 120 | dut->ap_key_mgmt == AP_WPA2_ENT_FT_EAP; | 
|  | 121 | } | 
|  | 122 |  | 
|  | 123 |  | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 124 | static int cmd_ap_ca_version(struct sigma_dut *dut, struct sigma_conn *conn, | 
|  | 125 | struct sigma_cmd *cmd) | 
|  | 126 | { | 
|  | 127 | /* const char *name = get_param(cmd, "NAME"); */ | 
|  | 128 | send_resp(dut, conn, SIGMA_COMPLETE, "version,1.0"); | 
|  | 129 | return 0; | 
|  | 130 | } | 
|  | 131 |  | 
|  | 132 |  | 
| Jouni Malinen | d6bf1b4 | 2017-06-23 17:51:01 +0300 | [diff] [blame] | 133 | static void kill_hostapd_process_pid(struct sigma_dut *dut) | 
|  | 134 | { | 
|  | 135 | FILE *f; | 
|  | 136 | int pid, res; | 
|  | 137 | char path[100]; | 
|  | 138 | int count; | 
|  | 139 |  | 
|  | 140 | f = fopen(SIGMA_DUT_HOSTAPD_PID_FILE, "r"); | 
|  | 141 | if (!f) | 
|  | 142 | return; | 
|  | 143 | res = fscanf(f, "%d", &pid); | 
|  | 144 | fclose(f); | 
|  | 145 | if (res != 1) | 
|  | 146 | return; | 
|  | 147 | sigma_dut_print(dut, DUT_MSG_INFO, "Killing hostapd pid %d", pid); | 
|  | 148 | kill(pid, SIGTERM); | 
|  | 149 | snprintf(path, sizeof(path), "/proc/%d", pid); | 
|  | 150 | for (count = 0; count < 20 && file_exists(path); count++) | 
|  | 151 | usleep(100000); | 
|  | 152 | } | 
|  | 153 |  | 
|  | 154 |  | 
| Jouni Malinen | 2e6ccc2 | 2017-09-04 13:43:16 +0300 | [diff] [blame] | 155 | int get_hwaddr(const char *ifname, unsigned char *hwaddr) | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 156 | { | 
|  | 157 | #ifndef __QNXNTO__ | 
|  | 158 | struct ifreq ifr; | 
|  | 159 | int s; | 
|  | 160 |  | 
|  | 161 | s = socket(AF_INET, SOCK_DGRAM, 0); | 
|  | 162 | if (s < 0) | 
|  | 163 | return -1; | 
|  | 164 | memset(&ifr, 0, sizeof(ifr)); | 
| Peng Xu | b8fc5cc | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 165 | strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 166 | if (ioctl(s, SIOCGIFHWADDR, &ifr) < 0) { | 
|  | 167 | perror("ioctl"); | 
|  | 168 | close(s); | 
|  | 169 | return -1; | 
|  | 170 | } | 
|  | 171 | close(s); | 
|  | 172 | memcpy(hwaddr, ifr.ifr_hwaddr.sa_data, 6); | 
|  | 173 | #else /* __QNXNTO__ */ | 
|  | 174 | struct ifaddrs *ifaddrshead = NULL; | 
|  | 175 | int found = 0; | 
|  | 176 | struct ifaddrs *temp_ifap = NULL; | 
|  | 177 | struct sockaddr_dl *sdl = NULL; | 
|  | 178 |  | 
|  | 179 | if (getifaddrs(&ifaddrshead) != 0) { | 
|  | 180 | perror("getifaddrs failed"); | 
|  | 181 | return -1; | 
|  | 182 | } | 
|  | 183 |  | 
|  | 184 | for (temp_ifap = ifaddrshead; ifaddrshead && !found; | 
|  | 185 | ifaddrshead = ifaddrshead->ifa_next) { | 
|  | 186 | if (ifaddrshead->ifa_addr->sa_family == AF_LINK && | 
|  | 187 | strcmp(ifaddrshead->ifa_name, ifname) == 0) { | 
|  | 188 | found = 1; | 
|  | 189 | sdl = (struct sockaddr_dl *) ifaddrshead->ifa_addr; | 
|  | 190 | if (sdl) | 
|  | 191 | memcpy(hwaddr, LLADDR(sdl), sdl->sdl_alen); | 
|  | 192 | } | 
|  | 193 | } | 
|  | 194 |  | 
|  | 195 | if (temp_ifap) | 
|  | 196 | freeifaddrs(temp_ifap); | 
|  | 197 |  | 
|  | 198 | if (!found) { | 
|  | 199 | perror("Failed to get the interface"); | 
|  | 200 | return -1; | 
|  | 201 | } | 
|  | 202 | #endif /* __QNXNTO__ */ | 
|  | 203 | return 0; | 
|  | 204 | } | 
|  | 205 |  | 
|  | 206 |  | 
|  | 207 | static void ath_ap_set_group_id(struct sigma_dut *dut, const char *ifname, | 
|  | 208 | const char *val) | 
|  | 209 | { | 
|  | 210 | char buf[60]; | 
|  | 211 |  | 
|  | 212 | snprintf(buf, sizeof(buf), "wifitool %s beeliner_fw_test 55 %d", | 
|  | 213 | ifname, atoi(val)); | 
|  | 214 | if (system(buf) != 0) { | 
|  | 215 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 216 | "wifitool ap_group_id failed"); | 
|  | 217 | } | 
|  | 218 | } | 
|  | 219 |  | 
|  | 220 |  | 
|  | 221 | void ath_set_cts_width(struct sigma_dut *dut, const char *ifname, | 
|  | 222 | const char *val) | 
|  | 223 | { | 
|  | 224 | char buf[60]; | 
|  | 225 |  | 
|  | 226 | /* TODO: Enable support for other values */ | 
|  | 227 | if (strcasecmp(val, "40") == 0) { | 
|  | 228 | snprintf(buf, sizeof(buf), "wifitool %s beeliner_fw_test 54 1", | 
|  | 229 | ifname); | 
|  | 230 | if (system(buf) != 0) { | 
|  | 231 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 232 | "wifitool cts_width failed"); | 
|  | 233 | } | 
| Priyadharshini Gowthaman | 818afef | 2015-11-09 13:28:15 -0800 | [diff] [blame] | 234 | snprintf(buf, sizeof(buf), | 
|  | 235 | "athdiag --set --address=0x10024  --val=0xd90b8a14"); | 
|  | 236 | if (system(buf) != 0) { | 
|  | 237 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 238 | "disabling phy restart failed"); | 
|  | 239 | } | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 240 | } else { | 
|  | 241 | sigma_dut_print(dut, DUT_MSG_ERROR, "Unsupported CTS_WIDTH"); | 
|  | 242 | } | 
|  | 243 | } | 
|  | 244 |  | 
|  | 245 |  | 
| Priyadharshini Gowthaman | 818afef | 2015-11-09 13:28:15 -0800 | [diff] [blame] | 246 | void ath_config_dyn_bw_sig(struct sigma_dut *dut, const char *ifname, | 
|  | 247 | const char *val) | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 248 | { | 
|  | 249 | char buf[60]; | 
|  | 250 |  | 
|  | 251 | if (strcasecmp(val, "enable") == 0) { | 
| Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 252 | dut->ap_dyn_bw_sig = VALUE_ENABLED; | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 253 | snprintf(buf, sizeof(buf), "iwpriv %s cwmenable 1", ifname); | 
|  | 254 | if (system(buf) != 0) { | 
|  | 255 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 256 | "iwpriv cwmenable 1 failed"); | 
|  | 257 | } | 
| Priyadharshini Gowthaman | 818afef | 2015-11-09 13:28:15 -0800 | [diff] [blame] | 258 | snprintf(buf, sizeof(buf), "wifitool %s beeliner_fw_test 96 1", | 
|  | 259 | ifname); | 
|  | 260 | if (system(buf) != 0) { | 
|  | 261 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 262 | "disabling RTS from rate control logic failed"); | 
|  | 263 | } | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 264 | } else if (strcasecmp(val, "disable") == 0) { | 
| Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 265 | dut->ap_dyn_bw_sig = VALUE_DISABLED; | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 266 | snprintf(buf, sizeof(buf), "iwpriv %s cwmenable 0", ifname); | 
|  | 267 | if (system(buf) != 0) { | 
|  | 268 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 269 | "iwpriv cwmenable 0 failed"); | 
|  | 270 | } | 
|  | 271 | } else { | 
|  | 272 | sigma_dut_print(dut, DUT_MSG_ERROR, "Unsupported DYN_BW_SGL"); | 
|  | 273 | } | 
|  | 274 | } | 
|  | 275 |  | 
|  | 276 |  | 
|  | 277 | static void ath_config_rts_force(struct sigma_dut *dut, const char *ifname, | 
|  | 278 | const char *val) | 
|  | 279 | { | 
|  | 280 | char buf[60]; | 
|  | 281 |  | 
|  | 282 | if (strcasecmp(val, "enable") == 0) { | 
| Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 283 | dut->ap_sig_rts = VALUE_ENABLED; | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 284 | snprintf(buf, sizeof(buf), "iwconfig %s rts 64", ifname); | 
|  | 285 | if (system(buf) != 0) { | 
|  | 286 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 287 | "iwconfig rts 64 failed"); | 
|  | 288 | } | 
| priyadharshini gowthaman | 270870e | 2015-12-09 10:10:23 -0800 | [diff] [blame] | 289 | snprintf(buf, sizeof(buf), "wifitool %s beeliner_fw_test 100 1", | 
|  | 290 | ifname); | 
|  | 291 | if (system(buf) != 0) { | 
|  | 292 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 293 | "wifitool beeliner_fw_test 100 1 failed"); | 
|  | 294 | } | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 295 | } else if (strcasecmp(val, "disable") == 0) { | 
| Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 296 | dut->ap_sig_rts = VALUE_DISABLED; | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 297 | snprintf(buf, sizeof(buf), "iwconfig %s rts 2347", ifname); | 
|  | 298 | if (system(buf) != 0) { | 
|  | 299 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 300 | "iwpriv rts 2347 failed"); | 
|  | 301 | } | 
|  | 302 | } else { | 
|  | 303 | sigma_dut_print(dut, DUT_MSG_ERROR, "Unsupported RTS_FORCE"); | 
|  | 304 | } | 
|  | 305 | } | 
|  | 306 |  | 
|  | 307 |  | 
| priyadharshini gowthaman | 09d613e | 2017-12-20 11:43:44 -0800 | [diff] [blame] | 308 | static void ath_radio(struct sigma_dut *dut, const char *val) | 
|  | 309 | { | 
|  | 310 | if (strcasecmp(val, "on") == 0) { | 
|  | 311 | if (dut->ap_interface_5g == 1) { | 
|  | 312 | run_system(dut, "uci set wireless.wifi0.disabled=0"); | 
|  | 313 | } else if (dut->ap_interface_2g == 1) { | 
|  | 314 | run_system(dut, "uci set wireless.wifi1.disabled=0"); | 
|  | 315 | } else { | 
|  | 316 | run_system(dut, "uci set wireless.wifi0.disabled=0"); | 
|  | 317 | run_system(dut, "uci set wireless.wifi1.disabled=0"); | 
|  | 318 | } | 
|  | 319 | run_system(dut, "uci commit"); | 
|  | 320 | run_system(dut, "wifi down"); | 
|  | 321 | run_system(dut, "wifi up"); | 
|  | 322 | } else if (strcasecmp(val, "off") == 0) { | 
|  | 323 | if (dut->ap_interface_5g == 1) { | 
|  | 324 | run_system(dut, "uci set wireless.wifi0.disabled=1"); | 
|  | 325 | } else if (dut->ap_interface_2g == 1) { | 
|  | 326 | run_system(dut, "uci set wireless.wifi1.disabled=1"); | 
|  | 327 | } else { | 
|  | 328 | run_system(dut, "uci set wireless.wifi0.disabled=1"); | 
|  | 329 | run_system(dut, "uci set wireless.wifi1.disabled=1"); | 
|  | 330 | } | 
|  | 331 | run_system(dut, "uci commit"); | 
|  | 332 | run_system(dut, "wifi down"); | 
|  | 333 | run_system(dut, "wifi up"); | 
|  | 334 | } | 
|  | 335 | } | 
|  | 336 |  | 
|  | 337 |  | 
| priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 338 | static void deauth_disassoc(struct sigma_dut *dut, const char *ifname, | 
|  | 339 | const char *val) | 
|  | 340 | { | 
|  | 341 | char buf[60]; | 
|  | 342 |  | 
|  | 343 | if (strcasecmp(val, "disable") == 0) { | 
|  | 344 | snprintf(buf, sizeof(buf), "iwpriv %s stealthdown 1", ifname); | 
|  | 345 | if (system(buf) != 0) { | 
|  | 346 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 347 | "disable deauthdisassoctx failed"); | 
|  | 348 | } | 
|  | 349 | } | 
|  | 350 | } | 
|  | 351 |  | 
|  | 352 |  | 
| priyadharshini gowthaman | cb22e43 | 2017-12-28 15:23:31 -0800 | [diff] [blame] | 353 | static void ath_set_txpower(struct sigma_dut *dut, const char *ifname, | 
|  | 354 | const char *val) | 
|  | 355 | { | 
|  | 356 | char buf[60]; | 
|  | 357 |  | 
|  | 358 | if (strcasecmp(val, "high") == 0) | 
|  | 359 | snprintf(buf, sizeof(buf), "iwconfig %s txpower 29", ifname); | 
|  | 360 | else if (strcasecmp(val, "low") == 0) | 
|  | 361 | snprintf(buf, sizeof(buf), "iwconfig %s txpower 1", ifname); | 
|  | 362 | else | 
|  | 363 | sigma_dut_print(dut, DUT_MSG_ERROR, "Unsupported txpower"); | 
|  | 364 |  | 
|  | 365 | if (system(buf) != 0) | 
|  | 366 | sigma_dut_print(dut, DUT_MSG_ERROR, "setting txpower failed"); | 
|  | 367 | } | 
|  | 368 |  | 
|  | 369 |  | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 370 | static enum ap_mode get_mode(const char *str) | 
|  | 371 | { | 
|  | 372 | if (strcasecmp(str, "11a") == 0) | 
|  | 373 | return AP_11a; | 
|  | 374 | else if (strcasecmp(str, "11g") == 0) | 
|  | 375 | return AP_11g; | 
|  | 376 | else if (strcasecmp(str, "11b") == 0) | 
|  | 377 | return AP_11b; | 
|  | 378 | else if (strcasecmp(str, "11na") == 0) | 
|  | 379 | return AP_11na; | 
|  | 380 | else if (strcasecmp(str, "11ng") == 0) | 
|  | 381 | return AP_11ng; | 
|  | 382 | else if (strcasecmp(str, "11ac") == 0 || strcasecmp(str, "ac") == 0) | 
|  | 383 | return AP_11ac; | 
| Alexei Avshalom Lazar | 2712cc8 | 2018-12-23 16:29:14 +0200 | [diff] [blame] | 384 | else if (strcasecmp(str, "11ad") == 0) | 
|  | 385 | return AP_11ad; | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 386 | else | 
|  | 387 | return AP_inval; | 
|  | 388 | } | 
|  | 389 |  | 
|  | 390 |  | 
|  | 391 | static int run_hostapd_cli(struct sigma_dut *dut, char *buf) | 
|  | 392 | { | 
|  | 393 | char command[1000]; | 
|  | 394 | const char *bin; | 
|  | 395 | enum driver_type drv = get_driver_type(); | 
| Adil Saeed Musthafa | 3dd6ca7 | 2017-05-15 12:45:18 -0700 | [diff] [blame] | 396 | char *sigma_hapd_file = sigma_hapd_ctrl; | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 397 |  | 
|  | 398 | if (file_exists("hostapd_cli")) | 
|  | 399 | bin = "./hostapd_cli"; | 
| Jouni Malinen | d6bf1b4 | 2017-06-23 17:51:01 +0300 | [diff] [blame] | 400 | else if (file_exists("../../hostapd/hostapd_cli")) | 
|  | 401 | bin = "../../hostapd/hostapd_cli"; | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 402 | else | 
|  | 403 | bin = "hostapd_cli"; | 
|  | 404 |  | 
|  | 405 | if (drv == DRIVER_OPENWRT && sigma_hapd_ctrl == NULL) { | 
| Adil Saeed Musthafa | 3dd6ca7 | 2017-05-15 12:45:18 -0700 | [diff] [blame] | 406 | sigma_hapd_file = "/var/run/hostapd-wifi0"; | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 407 |  | 
|  | 408 | if (sigma_radio_ifname[0] && | 
|  | 409 | strcmp(sigma_radio_ifname[0], "wifi1") == 0) | 
| Adil Saeed Musthafa | 3dd6ca7 | 2017-05-15 12:45:18 -0700 | [diff] [blame] | 410 | sigma_hapd_file = "/var/run/hostapd-wifi1"; | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 411 | else if (sigma_radio_ifname[0] && | 
|  | 412 | strcmp(sigma_radio_ifname[0], "wifi2") == 0) | 
| Adil Saeed Musthafa | 3dd6ca7 | 2017-05-15 12:45:18 -0700 | [diff] [blame] | 413 | sigma_hapd_file = "/var/run/hostapd-wifi2"; | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 414 | } | 
|  | 415 |  | 
| Adil Saeed Musthafa | 3dd6ca7 | 2017-05-15 12:45:18 -0700 | [diff] [blame] | 416 | if (sigma_hapd_file) | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 417 | snprintf(command, sizeof(command), "%s -p %s %s", | 
| Adil Saeed Musthafa | 3dd6ca7 | 2017-05-15 12:45:18 -0700 | [diff] [blame] | 418 | bin, sigma_hapd_file, buf); | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 419 | else | 
|  | 420 | snprintf(command, sizeof(command), "%s %s", bin, buf); | 
|  | 421 | return run_system(dut, command); | 
|  | 422 | } | 
|  | 423 |  | 
|  | 424 |  | 
| priyadharshini gowthaman | 8e26ff4 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 425 | static int ath_set_lci_config(struct sigma_dut *dut, const char *val, | 
|  | 426 | struct sigma_cmd *cmd) | 
|  | 427 | { | 
|  | 428 | FILE *f; | 
|  | 429 | int i; | 
|  | 430 |  | 
|  | 431 | f = fopen("/tmp/lci_cfg.txt", "w"); | 
|  | 432 | if (!f) { | 
|  | 433 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 434 | "Failed to open /tmp/lci_cfg.txt"); | 
|  | 435 | return -1; | 
|  | 436 | } | 
|  | 437 |  | 
|  | 438 | for (i = 2; i < cmd->count; i++) | 
|  | 439 | fprintf(f, "%s = %s \n", cmd->params[i], cmd->values[i]); | 
|  | 440 | fprintf(f, "\n"); | 
|  | 441 | fclose(f); | 
|  | 442 |  | 
|  | 443 | return 0; | 
|  | 444 | } | 
|  | 445 |  | 
|  | 446 |  | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 447 | static int cmd_ap_set_wireless(struct sigma_dut *dut, struct sigma_conn *conn, | 
|  | 448 | struct sigma_cmd *cmd) | 
|  | 449 | { | 
|  | 450 | /* const char *name = get_param(cmd, "NAME"); */ | 
|  | 451 | /* const char *ifname = get_param(cmd, "INTERFACE"); */ | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 452 | const char *val; | 
|  | 453 | unsigned int wlan_tag = 1; | 
|  | 454 | char *ifname = get_main_ifname(); | 
| Alexei Avshalom Lazar | 79f5727 | 2018-12-23 17:22:47 +0200 | [diff] [blame] | 455 | char buf[128]; | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 456 |  | 
| Alexei Avshalom Lazar | 2712cc8 | 2018-12-23 16:29:14 +0200 | [diff] [blame] | 457 | /* Allow program to be overridden if specified in the ap_set_wireless | 
|  | 458 | * to support some 60 GHz test scripts where the program may be 60 GHz | 
|  | 459 | * or WPS. */ | 
|  | 460 | val = get_param(cmd, "PROGRAM"); | 
|  | 461 | if (val) | 
|  | 462 | dut->program = sigma_program_to_enum(val); | 
|  | 463 |  | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 464 | val = get_param(cmd, "WLAN_TAG"); | 
|  | 465 | if (val) { | 
|  | 466 | wlan_tag = atoi(val); | 
| Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 467 | if (wlan_tag < 1 || wlan_tag > 3) { | 
|  | 468 | /* | 
|  | 469 | * The only valid WLAN Tags as of now as per the latest | 
|  | 470 | * WFA scripts are 1, 2, and 3. | 
|  | 471 | */ | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 472 | send_resp(dut, conn, SIGMA_INVALID, | 
|  | 473 | "errorCode,Invalid WLAN_TAG"); | 
|  | 474 | return 0; | 
|  | 475 | } | 
|  | 476 | } | 
|  | 477 |  | 
| priyadharshini gowthaman | 09d613e | 2017-12-20 11:43:44 -0800 | [diff] [blame] | 478 | val = get_param(cmd, "Interface"); | 
|  | 479 | if (val) { | 
|  | 480 | if (strcasecmp(val, "5G") == 0) | 
|  | 481 | dut->ap_interface_5g = 1; | 
|  | 482 | else | 
|  | 483 | dut->ap_interface_2g = 1; | 
|  | 484 |  | 
|  | 485 | if (dut->ap_interface_5g && dut->ap_interface_2g) | 
|  | 486 | dut->ap_is_dual = 1; | 
|  | 487 | } | 
|  | 488 |  | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 489 | val = get_param(cmd, "CountryCode"); | 
|  | 490 | if (val) { | 
|  | 491 | if (strlen(val) > sizeof(dut->ap_countrycode) - 1) | 
|  | 492 | return -1; | 
|  | 493 | snprintf(dut->ap_countrycode, sizeof(dut->ap_countrycode), | 
|  | 494 | "%s", val); | 
|  | 495 | } | 
|  | 496 |  | 
| Pradeep Reddy POTTETI | fba27db | 2015-11-20 16:42:22 +0530 | [diff] [blame] | 497 | val = get_param(cmd, "regulatory_mode"); | 
|  | 498 | if (val) { | 
|  | 499 | if (strcasecmp(val, "11d") == 0 || strcasecmp(val, "11h") == 0) | 
|  | 500 | dut->ap_regulatory_mode = AP_80211D_MODE_ENABLED; | 
|  | 501 | } | 
|  | 502 |  | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 503 | val = get_param(cmd, "SSID"); | 
|  | 504 | if (val) { | 
|  | 505 | if (strlen(val) > sizeof(dut->ap_ssid) - 1) | 
|  | 506 | return -1; | 
|  | 507 |  | 
|  | 508 | if (wlan_tag == 1) { | 
| Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 509 | /* | 
|  | 510 | * If tag is not specified, it is deemed to be 1. | 
|  | 511 | * Hence tag of 1 is a special case and the values | 
|  | 512 | * corresponding to wlan-tag=1 are stored separately | 
|  | 513 | * from the values corresponding tags 2 and 3. | 
|  | 514 | * This approach minimises the changes to existing code | 
|  | 515 | * since most of the sigma_dut code does not deal with | 
|  | 516 | * WLAN-TAG CAPI variable. | 
|  | 517 | */ | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 518 | snprintf(dut->ap_ssid, | 
|  | 519 | sizeof(dut->ap_ssid), "%s", val); | 
| Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 520 | } else { | 
|  | 521 | snprintf(dut->ap_tag_ssid[wlan_tag - 2], | 
|  | 522 | sizeof(dut->ap_tag_ssid[wlan_tag - 2]), | 
|  | 523 | "%s", val); | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 524 | } | 
|  | 525 | } | 
|  | 526 |  | 
|  | 527 | val = get_param(cmd, "CHANNEL"); | 
|  | 528 | if (val) { | 
|  | 529 | const char *pos; | 
|  | 530 | dut->ap_channel = atoi(val); | 
|  | 531 | pos = strchr(val, ';'); | 
|  | 532 | if (pos) { | 
|  | 533 | pos++; | 
|  | 534 | dut->ap_channel_1 = atoi(pos); | 
|  | 535 | } | 
|  | 536 | } | 
|  | 537 |  | 
| Pradeep Reddy POTTETI | fba27db | 2015-11-20 16:42:22 +0530 | [diff] [blame] | 538 | /* Overwrite the AP channel with DFS channel if configured */ | 
|  | 539 | val = get_param(cmd, "dfs_chan"); | 
|  | 540 | if (val) { | 
|  | 541 | dut->ap_channel = atoi(val); | 
|  | 542 | } | 
|  | 543 |  | 
|  | 544 | val = get_param(cmd, "dfs_mode"); | 
|  | 545 | if (val) { | 
|  | 546 | if (strcasecmp(val, "Enable") == 0) | 
|  | 547 | dut->ap_dfs_mode = AP_DFS_MODE_ENABLED; | 
|  | 548 | else if (strcasecmp(val, "Disable") == 0) | 
|  | 549 | dut->ap_dfs_mode = AP_DFS_MODE_DISABLED; | 
|  | 550 | else | 
|  | 551 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 552 | "Unsupported dfs_mode value: %s", val); | 
|  | 553 | } | 
|  | 554 |  | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 555 | val = get_param(cmd, "MODE"); | 
|  | 556 | if (val) { | 
|  | 557 | char *str, *pos; | 
|  | 558 |  | 
|  | 559 | str = strdup(val); | 
|  | 560 | if (str == NULL) | 
|  | 561 | return -1; | 
|  | 562 | pos = strchr(str, ';'); | 
|  | 563 | if (pos) | 
|  | 564 | *pos++ = '\0'; | 
|  | 565 |  | 
|  | 566 | dut->ap_is_dual = 0; | 
|  | 567 | dut->ap_mode = get_mode(str); | 
|  | 568 | if (dut->ap_mode == AP_inval) { | 
|  | 569 | send_resp(dut, conn, SIGMA_INVALID, | 
|  | 570 | "errorCode,Unsupported MODE"); | 
|  | 571 | free(str); | 
|  | 572 | return 0; | 
|  | 573 | } | 
| priyadharshini gowthaman | 63ab848 | 2017-12-28 15:32:55 -0800 | [diff] [blame] | 574 | if (dut->ap_mode == AP_11ac && dut->ap_80plus80 != 1) | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 575 | dut->ap_chwidth = AP_80; | 
|  | 576 |  | 
|  | 577 | if (pos) { | 
|  | 578 | dut->ap_mode_1 = get_mode(pos); | 
|  | 579 | if (dut->ap_mode_1 == AP_inval) { | 
|  | 580 | send_resp(dut, conn, SIGMA_INVALID, | 
|  | 581 | "errorCode,Unsupported MODE"); | 
|  | 582 | free(str); | 
|  | 583 | return 0; | 
|  | 584 | } | 
|  | 585 | if (dut->ap_mode_1 == AP_11ac) | 
|  | 586 | dut->ap_chwidth_1 = AP_80; | 
|  | 587 | dut->ap_is_dual = 1; | 
|  | 588 | } | 
|  | 589 |  | 
|  | 590 | free(str); | 
|  | 591 | } else if (dut->ap_mode == AP_inval) { | 
|  | 592 | if (dut->ap_channel <= 11) | 
|  | 593 | dut->ap_mode = AP_11ng; | 
|  | 594 | else if (dut->program == PROGRAM_VHT) | 
|  | 595 | dut->ap_mode = AP_11ac; | 
|  | 596 | else | 
|  | 597 | dut->ap_mode = AP_11na; | 
|  | 598 | } | 
|  | 599 |  | 
| Alexei Avshalom Lazar | 2712cc8 | 2018-12-23 16:29:14 +0200 | [diff] [blame] | 600 | /* Override the AP mode in case of 60 GHz */ | 
|  | 601 | if (dut->program == PROGRAM_60GHZ) { | 
|  | 602 | dut->ap_mode = AP_11ad; | 
|  | 603 | /* Workaround to force channel 2 if not specified */ | 
|  | 604 | if (!dut->ap_channel) | 
|  | 605 | dut->ap_channel = 2; | 
|  | 606 | } | 
|  | 607 |  | 
| Pradeep Reddy POTTETI | 0d3db63 | 2016-03-11 15:21:11 +0530 | [diff] [blame] | 608 | val = get_param(cmd, "WME"); | 
|  | 609 | if (val) { | 
|  | 610 | if (strcasecmp(val, "on") == 0) | 
|  | 611 | dut->ap_wme = AP_WME_ON; | 
|  | 612 | else if (strcasecmp(val, "off") == 0) | 
|  | 613 | dut->ap_wme = AP_WME_OFF; | 
|  | 614 | else | 
|  | 615 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 616 | "Unsupported WME value: %s", val); | 
|  | 617 | } | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 618 |  | 
| Mohammed Shafi Shajakhan | 02e3b82 | 2017-02-23 04:15:02 +0530 | [diff] [blame] | 619 | val = get_param(cmd, "WMMPS"); | 
|  | 620 | if (val) { | 
|  | 621 | if (strcasecmp(val, "on") == 0) | 
|  | 622 | dut->ap_wmmps = AP_WMMPS_ON; | 
|  | 623 | else if (strcasecmp(val, "off") == 0) | 
|  | 624 | dut->ap_wmmps = AP_WMMPS_OFF; | 
|  | 625 | else | 
|  | 626 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 627 | "Unsupported WMMPS value: %s", val); | 
|  | 628 | } | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 629 |  | 
|  | 630 | val = get_param(cmd, "RTS"); | 
|  | 631 | if (val) | 
|  | 632 | dut->ap_rts = atoi(val); | 
|  | 633 |  | 
|  | 634 | val = get_param(cmd, "FRGMNT"); | 
|  | 635 | if (val) | 
|  | 636 | dut->ap_frgmnt = atoi(val); | 
|  | 637 |  | 
|  | 638 | /* TODO: PWRSAVE */ | 
|  | 639 |  | 
|  | 640 | val = get_param(cmd, "BCNINT"); | 
|  | 641 | if (val) | 
|  | 642 | dut->ap_bcnint = atoi(val); | 
|  | 643 |  | 
|  | 644 | val = get_param(cmd, "RADIO"); | 
|  | 645 | if (val) { | 
| Mohammed Shafi Shajakhan | 94997f9 | 2017-01-09 21:31:09 +0530 | [diff] [blame] | 646 | enum driver_type drv = get_driver_type(); | 
|  | 647 |  | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 648 | if (strcasecmp(val, "on") == 0) { | 
| priyadharshini gowthaman | 09d613e | 2017-12-20 11:43:44 -0800 | [diff] [blame] | 649 | if (drv == DRIVER_OPENWRT) | 
|  | 650 | ath_radio(dut, val); | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 651 | if (drv == DRIVER_ATHEROS) | 
|  | 652 | ath_ap_start_hostapd(dut); | 
|  | 653 | else if (cmd_ap_config_commit(dut, conn, cmd) <= 0) | 
|  | 654 | return 0; | 
|  | 655 | } else if (strcasecmp(val, "off") == 0) { | 
| Mohammed Shafi Shajakhan | 94997f9 | 2017-01-09 21:31:09 +0530 | [diff] [blame] | 656 | if (drv == DRIVER_OPENWRT) { | 
| priyadharshini gowthaman | 09d613e | 2017-12-20 11:43:44 -0800 | [diff] [blame] | 657 | ath_radio(dut, val); | 
| Jouni Malinen | d6bf1b4 | 2017-06-23 17:51:01 +0300 | [diff] [blame] | 658 | } else if (dut->use_hostapd_pid_file) { | 
|  | 659 | kill_hostapd_process_pid(dut); | 
| Mohammed Shafi Shajakhan | 94997f9 | 2017-01-09 21:31:09 +0530 | [diff] [blame] | 660 | } else if (kill_process(dut, "(hostapd)", 1, | 
|  | 661 | SIGTERM) == 0 || | 
|  | 662 | system("killall hostapd") == 0) { | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 663 | sigma_dut_print(dut, DUT_MSG_INFO, | 
|  | 664 | "Killed hostapd on radio,off"); | 
|  | 665 | } | 
|  | 666 | } else { | 
|  | 667 | send_resp(dut, conn, SIGMA_INVALID, | 
|  | 668 | "errorCode,Unsupported RADIO value"); | 
|  | 669 | return 0; | 
|  | 670 | } | 
|  | 671 | } | 
|  | 672 |  | 
|  | 673 | val = get_param(cmd, "P2PMgmtBit"); | 
|  | 674 | if (val) | 
|  | 675 | dut->ap_p2p_mgmt = atoi(val); | 
|  | 676 |  | 
|  | 677 | /* TODO: ChannelUsage */ | 
|  | 678 |  | 
|  | 679 | /* TODO: 40_INTOLERANT */ | 
|  | 680 |  | 
|  | 681 | val = get_param(cmd, "ADDBA_REJECT"); | 
|  | 682 | if (val) { | 
|  | 683 | if (strcasecmp(val, "Enable") == 0) | 
| Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 684 | dut->ap_addba_reject = VALUE_ENABLED; | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 685 | else if (strcasecmp(val, "Disable") == 0) | 
| Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 686 | dut->ap_addba_reject = VALUE_DISABLED; | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 687 | } | 
|  | 688 |  | 
|  | 689 | val = get_param(cmd, "AMPDU"); | 
|  | 690 | if (val) { | 
|  | 691 | if (strcasecmp(val, "Enable") == 0) | 
| Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 692 | dut->ap_ampdu = VALUE_ENABLED; | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 693 | else if (strcasecmp(val, "Disable") == 0) | 
| Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 694 | dut->ap_ampdu = VALUE_DISABLED; | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 695 | } | 
|  | 696 |  | 
|  | 697 | val = get_param(cmd, "AMPDU_EXP"); | 
|  | 698 | if (val) | 
|  | 699 | dut->ap_ampdu_exp = atoi(val); | 
|  | 700 |  | 
|  | 701 | val = get_param(cmd, "AMSDU"); | 
|  | 702 | if (val) { | 
|  | 703 | if (strcasecmp(val, "Enable") == 0) | 
| Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 704 | dut->ap_amsdu = VALUE_ENABLED; | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 705 | else if (strcasecmp(val, "Disable") == 0) | 
| Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 706 | dut->ap_amsdu = VALUE_DISABLED; | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 707 | } | 
|  | 708 |  | 
|  | 709 | val = get_param(cmd, "NoAck"); | 
|  | 710 | if (val) { | 
|  | 711 | if (strcasecmp(val, "on") == 0) | 
| Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 712 | dut->ap_noack = VALUE_ENABLED; | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 713 | else if (strcasecmp(val, "off") == 0) | 
| Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 714 | dut->ap_noack = VALUE_DISABLED; | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 715 | } | 
|  | 716 |  | 
|  | 717 | /* TODO: GREENFIELD */ | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 718 | /* TODO: MCS_32 */ | 
|  | 719 |  | 
| Pradeep Reddy Potteti | 4b0cdee | 2017-03-15 12:37:33 +0530 | [diff] [blame] | 720 | val = get_param(cmd, "OFFSET"); | 
|  | 721 | if (val) { | 
|  | 722 | if (strcasecmp(val, "Above") == 0) | 
|  | 723 | dut->ap_chwidth_offset = SEC_CH_40ABOVE; | 
|  | 724 | else if (strcasecmp(val, "Below") == 0) | 
|  | 725 | dut->ap_chwidth_offset = SEC_CH_40BELOW; | 
|  | 726 | } | 
|  | 727 |  | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 728 | val = get_param(cmd, "MCS_FIXEDRATE"); | 
|  | 729 | if (val) { | 
|  | 730 | dut->ap_fixed_rate = 1; | 
|  | 731 | dut->ap_mcs = atoi(val); | 
|  | 732 | } | 
|  | 733 |  | 
|  | 734 | val = get_param(cmd, "SPATIAL_RX_STREAM"); | 
|  | 735 | if (val) { | 
|  | 736 | if (strcasecmp(val, "1SS") == 0 || strcasecmp(val, "1") == 0) { | 
|  | 737 | dut->ap_rx_streams = 1; | 
|  | 738 | if (dut->device_type == AP_testbed) | 
|  | 739 | dut->ap_vhtmcs_map = 0xfffc; | 
|  | 740 | } else if (strcasecmp(val, "2SS") == 0 || | 
|  | 741 | strcasecmp(val, "2") == 0) { | 
|  | 742 | dut->ap_rx_streams = 2; | 
|  | 743 | if (dut->device_type == AP_testbed) | 
|  | 744 | dut->ap_vhtmcs_map = 0xfff0; | 
|  | 745 | } else if (strcasecmp(val, "3SS") == 0 || | 
|  | 746 | strcasecmp(val, "3") == 0) { | 
|  | 747 | dut->ap_rx_streams = 3; | 
|  | 748 | if (dut->device_type == AP_testbed) | 
|  | 749 | dut->ap_vhtmcs_map = 0xffc0; | 
|  | 750 | } else if (strcasecmp(val, "4SS") == 0 || | 
|  | 751 | strcasecmp(val, "4") == 0) { | 
|  | 752 | dut->ap_rx_streams = 4; | 
|  | 753 | } | 
|  | 754 | } | 
|  | 755 |  | 
|  | 756 | val = get_param(cmd, "SPATIAL_TX_STREAM"); | 
|  | 757 | if (val) { | 
|  | 758 | if (strcasecmp(val, "1SS") == 0 || | 
|  | 759 | strcasecmp(val, "1") == 0) { | 
|  | 760 | dut->ap_tx_streams = 1; | 
|  | 761 | if (dut->device_type == AP_testbed) | 
|  | 762 | dut->ap_vhtmcs_map =  0xfffc; | 
|  | 763 | } else if (strcasecmp(val, "2SS") == 0 || | 
|  | 764 | strcasecmp(val, "2") == 0) { | 
|  | 765 | dut->ap_tx_streams = 2; | 
|  | 766 | if (dut->device_type == AP_testbed) | 
|  | 767 | dut->ap_vhtmcs_map = 0xfff0; | 
|  | 768 | } else if (strcasecmp(val, "3SS") == 0 || | 
|  | 769 | strcasecmp(val, "3") == 0) { | 
|  | 770 | dut->ap_tx_streams = 3; | 
|  | 771 | if (dut->device_type == AP_testbed) | 
|  | 772 | dut->ap_vhtmcs_map = 0xffc0; | 
|  | 773 | } else if (strcasecmp(val, "4SS") == 0 || | 
|  | 774 | strcasecmp(val, "4") == 0) { | 
|  | 775 | dut->ap_tx_streams = 4; | 
|  | 776 | } | 
|  | 777 | } | 
|  | 778 |  | 
| Adil Saeed Musthafa | 33ea287 | 2017-04-10 23:13:24 -0700 | [diff] [blame] | 779 | val = get_param(cmd, "BSS_max_idle"); | 
|  | 780 | if (val) { | 
|  | 781 | if (strncasecmp(val, "Enable", 7) == 0) { | 
|  | 782 | dut->wnm_bss_max_feature = VALUE_ENABLED; | 
|  | 783 | } else if (strncasecmp(val, "Disable", 8) == 0) { | 
|  | 784 | dut->wnm_bss_max_feature = VALUE_DISABLED; | 
|  | 785 | } else { | 
|  | 786 | send_resp(dut, conn, SIGMA_ERROR, | 
|  | 787 | "errorCode,Invalid value for BSS_max_Feature"); | 
|  | 788 | return 0; | 
|  | 789 | } | 
|  | 790 | } | 
|  | 791 |  | 
|  | 792 | val = get_param(cmd, "BSS_Idle_Protection_options"); | 
|  | 793 | if (val) { | 
|  | 794 | int protection = (int) strtol(val, (char **) NULL, 10); | 
|  | 795 |  | 
|  | 796 | if (protection != 1 && protection != 0) { | 
|  | 797 | send_resp(dut, conn, SIGMA_ERROR, | 
|  | 798 | "errorCode,Invalid value for BSS_Idle_Protection_options"); | 
|  | 799 | return 0; | 
|  | 800 | } | 
|  | 801 | dut->wnm_bss_max_protection = protection ? | 
|  | 802 | VALUE_ENABLED : VALUE_DISABLED; | 
|  | 803 | } | 
|  | 804 |  | 
|  | 805 | val = get_param(cmd, "BSS_max_Idle_period"); | 
|  | 806 | if (val) { | 
|  | 807 | int idle_time = (int) strtol(val, (char **) NULL, 10); | 
|  | 808 |  | 
|  | 809 | if (idle_time == LONG_MIN || idle_time == LONG_MAX) { | 
|  | 810 | send_resp(dut, conn, SIGMA_ERROR, | 
|  | 811 | "errorCode,Invalid value for BSS_max_Idle_period"); | 
|  | 812 | return 0; | 
|  | 813 | } | 
|  | 814 | dut->wnm_bss_max_idle_time = idle_time; | 
|  | 815 | } | 
|  | 816 |  | 
|  | 817 | val = get_param(cmd, "PROXY_ARP"); | 
|  | 818 | if (val) | 
|  | 819 | dut->ap_proxy_arp = (int) strtol(val, (char **) NULL, 10); | 
|  | 820 |  | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 821 | val = get_param(cmd, "nss_mcs_cap"); | 
|  | 822 | if (val) { | 
|  | 823 | int nss, mcs; | 
|  | 824 | char token[20]; | 
|  | 825 | char *result = NULL; | 
| Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 826 | char *saveptr; | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 827 |  | 
|  | 828 | if (strlen(val) >= sizeof(token)) | 
|  | 829 | return -1; | 
| Jouni Malinen | 947fdf6 | 2017-05-14 22:29:32 +0300 | [diff] [blame] | 830 | strlcpy(token, val, sizeof(token)); | 
| Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 831 | result = strtok_r(token, ";", &saveptr); | 
| Pradeep Reddy POTTETI | 41b8c54 | 2016-06-15 16:09:46 +0530 | [diff] [blame] | 832 | if (!result) { | 
|  | 833 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 834 | "VHT NSS not specified"); | 
|  | 835 | return 0; | 
|  | 836 | } | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 837 | nss = atoi(result); | 
| Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 838 | result = strtok_r(NULL, ";", &saveptr); | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 839 | if (result == NULL) { | 
|  | 840 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 841 | "VHTMCS NOT SPECIFIED!"); | 
|  | 842 | return 0; | 
|  | 843 | } | 
| Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 844 | result = strtok_r(result, "-", &saveptr); | 
|  | 845 | result = strtok_r(NULL, "-", &saveptr); | 
| Pradeep Reddy POTTETI | 41b8c54 | 2016-06-15 16:09:46 +0530 | [diff] [blame] | 846 | if (!result) { | 
|  | 847 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 848 | "VHT MCS not specified"); | 
|  | 849 | return 0; | 
|  | 850 | } | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 851 | mcs = atoi(result); | 
|  | 852 | switch (nss) { | 
|  | 853 | case 1: | 
|  | 854 | switch (mcs) { | 
|  | 855 | case 7: | 
|  | 856 | dut->ap_vhtmcs_map = 0xfffc; | 
|  | 857 | break; | 
|  | 858 | case 8: | 
|  | 859 | dut->ap_vhtmcs_map = 0xfffd; | 
|  | 860 | break; | 
|  | 861 | case 9: | 
|  | 862 | dut->ap_vhtmcs_map = 0xfffe; | 
|  | 863 | break; | 
|  | 864 | default: | 
|  | 865 | dut->ap_vhtmcs_map = 0xfffe; | 
|  | 866 | break; | 
|  | 867 | } | 
|  | 868 | break; | 
|  | 869 | case 2: | 
|  | 870 | switch (mcs) { | 
|  | 871 | case 7: | 
|  | 872 | dut->ap_vhtmcs_map = 0xfff0; | 
|  | 873 | break; | 
|  | 874 | case 8: | 
|  | 875 | dut->ap_vhtmcs_map = 0xfff5; | 
|  | 876 | break; | 
|  | 877 | case 9: | 
|  | 878 | dut->ap_vhtmcs_map = 0xfffa; | 
|  | 879 | break; | 
|  | 880 | default: | 
|  | 881 | dut->ap_vhtmcs_map = 0xfffa; | 
|  | 882 | break; | 
|  | 883 | } | 
|  | 884 | break; | 
|  | 885 | case 3: | 
|  | 886 | switch (mcs) { | 
|  | 887 | case 7: | 
|  | 888 | dut->ap_vhtmcs_map = 0xffc0; | 
|  | 889 | break; | 
|  | 890 | case 8: | 
|  | 891 | dut->ap_vhtmcs_map = 0xffd5; | 
|  | 892 | break; | 
|  | 893 | case 9: | 
|  | 894 | dut->ap_vhtmcs_map = 0xffea; | 
|  | 895 | break; | 
|  | 896 | default: | 
|  | 897 | dut->ap_vhtmcs_map = 0xffea; | 
|  | 898 | break; | 
|  | 899 | } | 
|  | 900 | break; | 
|  | 901 | default: | 
|  | 902 | dut->ap_vhtmcs_map = 0xffea; | 
|  | 903 | break; | 
|  | 904 | } | 
|  | 905 | } | 
|  | 906 |  | 
|  | 907 | /* TODO: MPDU_MIN_START_SPACING */ | 
|  | 908 | /* TODO: RIFS_TEST */ | 
|  | 909 | /* TODO: SGI20 */ | 
|  | 910 |  | 
|  | 911 | val = get_param(cmd, "STBC_TX"); | 
|  | 912 | if (val) | 
|  | 913 | dut->ap_tx_stbc = atoi(val); | 
|  | 914 |  | 
|  | 915 | val = get_param(cmd, "WIDTH"); | 
|  | 916 | if (val) { | 
|  | 917 | if (strcasecmp(val, "20") == 0) | 
|  | 918 | dut->ap_chwidth = AP_20; | 
|  | 919 | else if (strcasecmp(val, "40") == 0) | 
|  | 920 | dut->ap_chwidth = AP_40; | 
|  | 921 | else if (strcasecmp(val, "80") == 0) | 
|  | 922 | dut->ap_chwidth = AP_80; | 
|  | 923 | else if (strcasecmp(val, "160") == 0) | 
|  | 924 | dut->ap_chwidth = AP_160; | 
| priyadharshini gowthaman | 63ab848 | 2017-12-28 15:32:55 -0800 | [diff] [blame] | 925 | else if (strcasecmp(val, "80plus80") == 0) { | 
|  | 926 | dut->ap_80plus80 = 1; | 
|  | 927 | dut->ap_chwidth = AP_80_80; | 
|  | 928 | } else if (strcasecmp(val, "Auto") == 0) | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 929 | dut->ap_chwidth = AP_AUTO; | 
|  | 930 | else { | 
|  | 931 | send_resp(dut, conn, SIGMA_INVALID, | 
|  | 932 | "errorCode,Unsupported WIDTH"); | 
|  | 933 | return 0; | 
|  | 934 | } | 
|  | 935 | } | 
|  | 936 |  | 
|  | 937 | /* TODO: WIDTH_SCAN */ | 
|  | 938 |  | 
|  | 939 | val = get_param(cmd, "TDLSProhibit"); | 
|  | 940 | dut->ap_tdls_prohibit = val && strcasecmp(val, "Enabled") == 0; | 
|  | 941 | val = get_param(cmd, "TDLSChswitchProhibit"); | 
|  | 942 | dut->ap_tdls_prohibit_chswitch = | 
|  | 943 | val && strcasecmp(val, "Enabled") == 0; | 
|  | 944 | val = get_param(cmd, "HS2"); | 
|  | 945 | if (val && wlan_tag == 1) | 
|  | 946 | dut->ap_hs2 = atoi(val); | 
|  | 947 | val = get_param(cmd, "P2P_CROSS_CONNECT"); | 
|  | 948 | if (val) | 
|  | 949 | dut->ap_p2p_cross_connect = strcasecmp(val, "Enabled") == 0; | 
|  | 950 |  | 
|  | 951 | val = get_param(cmd, "FakePubKey"); | 
|  | 952 | dut->ap_fake_pkhash = val && atoi(val); | 
|  | 953 |  | 
|  | 954 | val = get_param(cmd, "vht_tkip"); | 
|  | 955 | dut->ap_allow_vht_tkip = val && strcasecmp(val, "Enable") == 0; | 
|  | 956 | val = get_param(cmd, "vht_wep"); | 
|  | 957 | dut->ap_allow_vht_wep = val && strcasecmp(val, "Enable") == 0; | 
|  | 958 |  | 
|  | 959 | val = get_param(cmd, "Protect_mode"); | 
|  | 960 | dut->ap_disable_protection = val && strcasecmp(val, "Disable") == 0; | 
|  | 961 |  | 
|  | 962 | val = get_param(cmd, "DYN_BW_SGNL"); | 
|  | 963 | if (val) { | 
|  | 964 | switch (get_driver_type()) { | 
|  | 965 | case DRIVER_OPENWRT: | 
|  | 966 | switch (get_openwrt_driver_type()) { | 
|  | 967 | case OPENWRT_DRIVER_ATHEROS: | 
|  | 968 | ath_config_dyn_bw_sig(dut, ifname, val); | 
|  | 969 | break; | 
|  | 970 | default: | 
|  | 971 | send_resp(dut, conn, SIGMA_ERROR, | 
|  | 972 | "errorCode,Unsupported DYN_BW_SGNL with OpenWrt driver"); | 
|  | 973 | return 0; | 
|  | 974 | } | 
|  | 975 | break; | 
| Nirav Shah | 8ad8d74 | 2017-10-17 10:49:11 +0530 | [diff] [blame] | 976 | case DRIVER_WCN: | 
|  | 977 | case DRIVER_LINUX_WCN: | 
|  | 978 | ath_config_dyn_bw_sig(dut, ifname, val); | 
|  | 979 | break; | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 980 | default: | 
|  | 981 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 982 | "Unsupported DYN_BW_SGL with the current driver"); | 
|  | 983 | break; | 
|  | 984 | } | 
|  | 985 | } | 
|  | 986 |  | 
|  | 987 | val = get_param(cmd, "SGI80"); | 
|  | 988 | if (val) { | 
|  | 989 | if (strcasecmp(val, "enable") == 0) | 
|  | 990 | dut->ap_sgi80 = 1; | 
|  | 991 | else if (strcasecmp(val, "disable") == 0) | 
|  | 992 | dut->ap_sgi80 = 0; | 
|  | 993 | else { | 
|  | 994 | send_resp(dut, conn, SIGMA_INVALID, | 
|  | 995 | "errorCode,Unsupported SGI80"); | 
|  | 996 | return 0; | 
|  | 997 | } | 
|  | 998 | } | 
|  | 999 |  | 
|  | 1000 | val = get_param(cmd, "LDPC"); | 
|  | 1001 | if (val) { | 
|  | 1002 | if (strcasecmp(val, "enable") == 0) | 
| Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 1003 | dut->ap_ldpc = VALUE_ENABLED; | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1004 | else if (strcasecmp(val, "disable") == 0) | 
| Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 1005 | dut->ap_ldpc = VALUE_DISABLED; | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1006 | else { | 
|  | 1007 | send_resp(dut, conn, SIGMA_INVALID, | 
|  | 1008 | "errorCode,Unsupported LDPC"); | 
|  | 1009 | return 0; | 
|  | 1010 | } | 
|  | 1011 | } | 
|  | 1012 |  | 
|  | 1013 | val = get_param(cmd, "BW_SGNL"); | 
|  | 1014 | if (val) { | 
|  | 1015 | /* | 
|  | 1016 | * With dynamic bandwidth signaling enabled we should see | 
|  | 1017 | * RTS if the threshold is met. | 
|  | 1018 | */ | 
|  | 1019 | if (strcasecmp(val, "enable") == 0) { | 
| Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 1020 | dut->ap_sig_rts = VALUE_ENABLED; | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1021 | } else if (strcasecmp(val, "disable") == 0) { | 
| Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 1022 | dut->ap_sig_rts = VALUE_DISABLED; | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1023 | } else { | 
|  | 1024 | send_resp(dut, conn, SIGMA_INVALID, | 
|  | 1025 | "errorCode,Unsupported BW_SGNL"); | 
|  | 1026 | return 0; | 
|  | 1027 | } | 
|  | 1028 | } | 
|  | 1029 |  | 
|  | 1030 | val = get_param(cmd, "RTS_FORCE"); | 
|  | 1031 | if (val) { | 
|  | 1032 | switch (get_driver_type()) { | 
|  | 1033 | case DRIVER_OPENWRT: | 
|  | 1034 | switch (get_openwrt_driver_type()) { | 
|  | 1035 | case OPENWRT_DRIVER_ATHEROS: | 
|  | 1036 | ath_config_rts_force(dut, ifname, val); | 
|  | 1037 | break; | 
|  | 1038 | default: | 
|  | 1039 | send_resp(dut, conn, SIGMA_ERROR, | 
|  | 1040 | "errorCode,Unsupported RTS_FORCE with OpenWrt driver"); | 
|  | 1041 | return 0; | 
|  | 1042 | } | 
|  | 1043 | break; | 
|  | 1044 | default: | 
|  | 1045 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 1046 | "Unsupported RTS_FORCE with the current driver"); | 
|  | 1047 | break; | 
|  | 1048 | } | 
|  | 1049 | } | 
|  | 1050 |  | 
|  | 1051 | val = get_param(cmd, "Zero_crc"); | 
|  | 1052 | if (val) { | 
|  | 1053 | switch (get_driver_type()) { | 
|  | 1054 | case DRIVER_ATHEROS: | 
|  | 1055 | ath_set_zero_crc(dut, val); | 
|  | 1056 | break; | 
|  | 1057 | case DRIVER_OPENWRT: | 
|  | 1058 | switch (get_openwrt_driver_type()) { | 
|  | 1059 | case OPENWRT_DRIVER_ATHEROS: | 
|  | 1060 | ath_set_zero_crc(dut, val); | 
|  | 1061 | break; | 
|  | 1062 | default: | 
|  | 1063 | send_resp(dut, conn, SIGMA_ERROR, | 
|  | 1064 | "errorCode,Unsupported zero_crc with the current driver"); | 
|  | 1065 | return 0; | 
|  | 1066 | } | 
|  | 1067 | break; | 
|  | 1068 | default: | 
|  | 1069 | send_resp(dut, conn, SIGMA_ERROR, | 
|  | 1070 | "errorCode,Unsupported zero_crc with the current driver"); | 
|  | 1071 | return 0; | 
|  | 1072 | } | 
|  | 1073 | } | 
|  | 1074 |  | 
|  | 1075 | val = get_param(cmd, "TxBF"); | 
|  | 1076 | if (val) | 
|  | 1077 | dut->ap_txBF = strcasecmp(val, "enable") == 0; | 
|  | 1078 |  | 
|  | 1079 | val = get_param(cmd, "MU_TxBF"); | 
| Manikanta Pubbisetty | 210f7c8 | 2017-02-14 12:33:54 +0530 | [diff] [blame] | 1080 | if (val) { | 
|  | 1081 | if (strcasecmp(val, "enable") == 0) { | 
|  | 1082 | dut->ap_txBF = 1; | 
|  | 1083 | dut->ap_mu_txBF = 1; | 
|  | 1084 | } else if (strcasecmp(val, "disable") == 0) { | 
|  | 1085 | dut->ap_txBF = 0; | 
|  | 1086 | dut->ap_mu_txBF = 0; | 
|  | 1087 | } else { | 
|  | 1088 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 1089 | "Unsupported MU_TxBF"); | 
|  | 1090 | } | 
|  | 1091 | } | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1092 |  | 
|  | 1093 | /* UNSUPPORTED: tx_lgi_rate */ | 
|  | 1094 |  | 
|  | 1095 | val = get_param(cmd, "wpsnfc"); | 
|  | 1096 | if (val) | 
|  | 1097 | dut->ap_wpsnfc = atoi(val); | 
|  | 1098 |  | 
|  | 1099 | val = get_param(cmd, "GROUP_ID"); | 
|  | 1100 | if (val) { | 
|  | 1101 | switch (get_driver_type()) { | 
|  | 1102 | case DRIVER_OPENWRT: | 
|  | 1103 | switch (get_openwrt_driver_type()) { | 
|  | 1104 | case OPENWRT_DRIVER_ATHEROS: | 
|  | 1105 | ath_ap_set_group_id(dut, ifname, val); | 
|  | 1106 | break; | 
|  | 1107 | default: | 
|  | 1108 | send_resp(dut, conn, SIGMA_ERROR, | 
|  | 1109 | "errorCode,Unsupported group_id with the current driver"); | 
|  | 1110 | return 0; | 
|  | 1111 | } | 
|  | 1112 | break; | 
|  | 1113 | default: | 
|  | 1114 | send_resp(dut, conn, SIGMA_ERROR, | 
|  | 1115 | "errorCode,Unsupported group_id with the current driver"); | 
|  | 1116 | return 0; | 
|  | 1117 | } | 
|  | 1118 | } | 
|  | 1119 |  | 
|  | 1120 | val = get_param(cmd, "CTS_WIDTH"); | 
|  | 1121 | if (val) { | 
|  | 1122 | switch (get_driver_type()) { | 
|  | 1123 | case DRIVER_OPENWRT: | 
|  | 1124 | switch (get_openwrt_driver_type()) { | 
|  | 1125 | case OPENWRT_DRIVER_ATHEROS: | 
|  | 1126 | ath_set_cts_width(dut, ifname, val); | 
|  | 1127 | break; | 
|  | 1128 | default: | 
|  | 1129 | send_resp(dut, conn, SIGMA_ERROR, | 
|  | 1130 | "errorCode,Unsupported cts_width with the current driver"); | 
|  | 1131 | return 0; | 
|  | 1132 | } | 
|  | 1133 | break; | 
|  | 1134 | default: | 
|  | 1135 | send_resp(dut, conn, SIGMA_ERROR, | 
|  | 1136 | "errorCode,Unsupported cts_width with the current driver"); | 
|  | 1137 | return 0; | 
|  | 1138 | } | 
|  | 1139 | } | 
|  | 1140 |  | 
| priyadharshini gowthaman | 264d544 | 2016-02-25 15:52:22 -0800 | [diff] [blame] | 1141 | val = get_param(cmd, "MU_NDPA_FrameFormat"); | 
|  | 1142 | if (val) | 
|  | 1143 | dut->ap_ndpa_frame = atoi(val); | 
|  | 1144 |  | 
| priyadharshini gowthaman | c52fff8 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 1145 | val = get_param(cmd, "interworking"); | 
|  | 1146 | if (val && strcmp(val, "1") == 0) | 
|  | 1147 | dut->ap_interworking = 1; | 
|  | 1148 |  | 
|  | 1149 | val = get_param(cmd, "GAS_CB_DELAY"); | 
|  | 1150 | if (val) | 
|  | 1151 | dut->ap_gas_cb_delay = atoi(val); | 
|  | 1152 |  | 
| priyadharshini gowthaman | 8e26ff4 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 1153 | val = get_param(cmd, "LCI"); | 
|  | 1154 | if (val) { | 
|  | 1155 | if (strlen(val) > sizeof(dut->ap_val_lci) - 1) | 
|  | 1156 | return -1; | 
|  | 1157 | dut->ap_lci = 1; | 
|  | 1158 | snprintf(dut->ap_val_lci, sizeof(dut->ap_val_lci), "%s", val); | 
|  | 1159 | ath_set_lci_config(dut, val, cmd); | 
|  | 1160 | } | 
|  | 1161 |  | 
| priyadharshini gowthaman | c2357bd | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 1162 | val = get_param(cmd, "InfoZ"); | 
|  | 1163 | if (val) { | 
|  | 1164 | if (strlen(val) > sizeof(dut->ap_infoz) - 1) | 
|  | 1165 | return -1; | 
|  | 1166 | snprintf(dut->ap_infoz, sizeof(dut->ap_infoz), "%s", val); | 
|  | 1167 | } | 
|  | 1168 |  | 
| priyadharshini gowthaman | 8e26ff4 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 1169 | val = get_param(cmd, "LocCivicAddr"); | 
|  | 1170 | if (val) { | 
|  | 1171 | if (strlen(val) > sizeof(dut->ap_val_lcr) - 1) | 
|  | 1172 | return -1; | 
|  | 1173 | dut->ap_lcr = 1; | 
|  | 1174 | snprintf(dut->ap_val_lcr, sizeof(dut->ap_val_lcr), "%s", val); | 
|  | 1175 | if (dut->ap_lci == 0) | 
|  | 1176 | ath_set_lci_config(dut, val, cmd); | 
|  | 1177 | } | 
|  | 1178 |  | 
|  | 1179 | val = get_param(cmd, "NeighAPBSSID"); | 
|  | 1180 | if (val) { | 
|  | 1181 | if (dut->ap_neighap < 3) { | 
|  | 1182 | if (parse_mac_address( | 
|  | 1183 | dut, val, | 
|  | 1184 | dut->ap_val_neighap[dut->ap_neighap]) < 0) { | 
|  | 1185 | send_resp(dut, conn, SIGMA_INVALID, | 
|  | 1186 | "Failed to parse MAC address"); | 
|  | 1187 | return 0; | 
|  | 1188 | } | 
|  | 1189 | dut->ap_neighap++; | 
|  | 1190 | if (dut->ap_lci == 1) | 
|  | 1191 | dut->ap_scan = 1; | 
|  | 1192 | } | 
|  | 1193 | } | 
|  | 1194 |  | 
|  | 1195 | val = get_param(cmd, "OpChannel"); | 
|  | 1196 | if (val) { | 
|  | 1197 | if (dut->ap_opchannel < 3) { | 
|  | 1198 | dut->ap_val_opchannel[dut->ap_opchannel] = atoi(val); | 
|  | 1199 | dut->ap_opchannel++; | 
|  | 1200 | } | 
|  | 1201 | } | 
|  | 1202 |  | 
| priyadharshini gowthaman | c2357bd | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 1203 | val = get_param(cmd, "URI-FQDNdescriptor"); | 
|  | 1204 | if (val) { | 
|  | 1205 | if (strcasecmp(val, "HELD") == 0) { | 
|  | 1206 | dut->ap_fqdn_held = 1; | 
|  | 1207 | } else if (strcasecmp(val, "SUPL") == 0) { | 
|  | 1208 | dut->ap_fqdn_supl = 1; | 
|  | 1209 | } else { | 
|  | 1210 | send_resp(dut, conn, SIGMA_INVALID, | 
|  | 1211 | "errorCode,Unsupported URI-FQDNdescriptor"); | 
|  | 1212 | return 0; | 
|  | 1213 | } | 
|  | 1214 | } | 
|  | 1215 |  | 
| Adil Saeed Musthafa | 604c826 | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 1216 | val = get_param(cmd, "Reg_Domain"); | 
|  | 1217 | if (val) { | 
|  | 1218 | if (strcasecmp(val, "Local") == 0) { | 
|  | 1219 | dut->ap_reg_domain = REG_DOMAIN_LOCAL; | 
|  | 1220 | } else if (strcasecmp(val, "Global") == 0) { | 
|  | 1221 | dut->ap_reg_domain = REG_DOMAIN_GLOBAL; | 
|  | 1222 | } else { | 
|  | 1223 | send_resp(dut, conn, SIGMA_ERROR, | 
|  | 1224 | "errorCode,Wrong value for Reg_Domain"); | 
|  | 1225 | return 0; | 
|  | 1226 | } | 
|  | 1227 | } | 
|  | 1228 |  | 
| Adil Saeed Musthafa | 4ec61bd | 2017-04-10 23:13:41 -0700 | [diff] [blame] | 1229 | val = get_param(cmd, "NAME"); | 
|  | 1230 | if (val) { | 
|  | 1231 | if (strcasecmp(val, "ap1mbo") == 0) | 
|  | 1232 | dut->ap_name = 1; | 
|  | 1233 | else if (strcasecmp(val, "ap2mbo") == 0) | 
|  | 1234 | dut->ap_name = 2; | 
|  | 1235 | else | 
|  | 1236 | dut->ap_name = 0; | 
|  | 1237 | } | 
|  | 1238 |  | 
|  | 1239 | val = get_param(cmd, "FT_OA"); | 
|  | 1240 | if (val) { | 
|  | 1241 | if (strcasecmp(val, "Enable") == 0) { | 
|  | 1242 | dut->ap_ft_oa = 1; | 
|  | 1243 | } else if (strcasecmp(val, "Disable") == 0) { | 
|  | 1244 | dut->ap_ft_oa = 0; | 
|  | 1245 | } else { | 
|  | 1246 | send_resp(dut, conn, SIGMA_ERROR, | 
|  | 1247 | "errorCode,Wrong value for FT_OA"); | 
|  | 1248 | return 0; | 
|  | 1249 | } | 
|  | 1250 | } | 
|  | 1251 |  | 
| Adil Saeed Musthafa | 023108a | 2017-04-10 23:13:37 -0700 | [diff] [blame] | 1252 | val = get_param(cmd, "Cellular_Cap_Pref"); | 
|  | 1253 | if (val) | 
|  | 1254 | dut->ap_cell_cap_pref = atoi(val); | 
|  | 1255 |  | 
| Adil Saeed Musthafa | cf752fa | 2017-04-10 23:13:32 -0700 | [diff] [blame] | 1256 | val = get_param(cmd, "DOMAIN"); | 
|  | 1257 | if (val) { | 
|  | 1258 | if (strlen(val) >= sizeof(dut->ap_mobility_domain)) { | 
|  | 1259 | send_resp(dut, conn, SIGMA_ERROR, | 
|  | 1260 | "errorCode,Too long DOMAIN"); | 
|  | 1261 | return 0; | 
|  | 1262 | } | 
|  | 1263 | snprintf(dut->ap_mobility_domain, | 
|  | 1264 | sizeof(dut->ap_mobility_domain), "%s", val); | 
|  | 1265 | } | 
|  | 1266 |  | 
| Adil Saeed Musthafa | 4ec61bd | 2017-04-10 23:13:41 -0700 | [diff] [blame] | 1267 | val = get_param(cmd, "ft_bss_list"); | 
|  | 1268 | if (val) { | 
|  | 1269 | char *mac_str; | 
|  | 1270 | int i; | 
|  | 1271 | char *saveptr; | 
|  | 1272 | char *mac_list_str; | 
|  | 1273 |  | 
|  | 1274 | mac_list_str = strdup(val); | 
|  | 1275 | if (!mac_list_str) | 
|  | 1276 | return -1; | 
|  | 1277 | mac_str = strtok_r(mac_list_str, " ", &saveptr); | 
|  | 1278 | for (i = 0; mac_str && i < MAX_FT_BSS_LIST; i++) { | 
|  | 1279 | if (parse_mac_address(dut, mac_str, | 
|  | 1280 | dut->ft_bss_mac_list[i]) < 0) { | 
|  | 1281 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 1282 | "MAC Address not in proper format"); | 
|  | 1283 | break; | 
|  | 1284 | } | 
|  | 1285 | dut->ft_bss_mac_cnt++; | 
|  | 1286 | mac_str = strtok_r(NULL, " ", &saveptr); | 
|  | 1287 | } | 
|  | 1288 | sigma_dut_print(dut, DUT_MSG_DEBUG, | 
|  | 1289 | "Storing the following FT BSS MAC List"); | 
|  | 1290 | for (i = 0; i < dut->ft_bss_mac_cnt; i++) { | 
|  | 1291 | sigma_dut_print(dut, DUT_MSG_DEBUG, | 
|  | 1292 | "MAC[%d] %02x:%02x:%02x:%02x:%02x:%02x", | 
|  | 1293 | i, | 
|  | 1294 | dut->ft_bss_mac_list[i][0], | 
|  | 1295 | dut->ft_bss_mac_list[i][1], | 
|  | 1296 | dut->ft_bss_mac_list[i][2], | 
|  | 1297 | dut->ft_bss_mac_list[i][3], | 
|  | 1298 | dut->ft_bss_mac_list[i][4], | 
|  | 1299 | dut->ft_bss_mac_list[i][5]); | 
|  | 1300 | } | 
|  | 1301 | free(mac_list_str); | 
|  | 1302 | } | 
|  | 1303 |  | 
| priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 1304 | val = get_param(cmd, "OCESupport"); | 
|  | 1305 | if (val) { | 
|  | 1306 | if (strcasecmp(val, "enable") == 0) { | 
|  | 1307 | dut->ap_oce = VALUE_ENABLED; | 
|  | 1308 | } else if (strcasecmp(val, "disable") == 0) { | 
|  | 1309 | dut->ap_oce = VALUE_DISABLED; | 
|  | 1310 | dut->ap_filsdscv = VALUE_DISABLED; | 
|  | 1311 | } else { | 
|  | 1312 | send_resp(dut, conn, SIGMA_INVALID, | 
|  | 1313 | "errorCode,Unsupported OCE"); | 
|  | 1314 | return 0; | 
|  | 1315 | } | 
|  | 1316 | } | 
|  | 1317 |  | 
|  | 1318 | val = get_param(cmd, "FILSDscvInterval"); | 
|  | 1319 | if (val) | 
|  | 1320 | dut->ap_fils_dscv_int = atoi(val); | 
|  | 1321 |  | 
|  | 1322 | val = get_param(cmd, "BroadcastSSID"); | 
|  | 1323 | if (val) { | 
|  | 1324 | if (strcasecmp(val, "enable") == 0) { | 
|  | 1325 | dut->ap_broadcast_ssid = VALUE_ENABLED; | 
|  | 1326 | } else if (strcasecmp(val, "disable") == 0) { | 
|  | 1327 | dut->ap_broadcast_ssid = VALUE_DISABLED; | 
|  | 1328 | } else { | 
|  | 1329 | send_resp(dut, conn, SIGMA_INVALID, | 
|  | 1330 | "errorCode,Unsupported hidden SSID"); | 
|  | 1331 | return 0; | 
|  | 1332 | } | 
|  | 1333 | } | 
|  | 1334 |  | 
|  | 1335 | val = get_param(cmd, "FILSDscv"); | 
|  | 1336 | if (val) { | 
|  | 1337 | if (strcasecmp(val, "enable") == 0) { | 
|  | 1338 | dut->ap_filsdscv = VALUE_ENABLED; | 
|  | 1339 | } else if (strcasecmp(val, "disable") == 0) { | 
|  | 1340 | dut->ap_filsdscv = VALUE_DISABLED; | 
|  | 1341 | } else { | 
|  | 1342 | send_resp(dut, conn, SIGMA_INVALID, | 
|  | 1343 | "errorCode,Unsupported FILSDscv"); | 
|  | 1344 | return 0; | 
|  | 1345 | } | 
|  | 1346 | } | 
|  | 1347 |  | 
|  | 1348 | val = get_param(cmd, "FILSHLP"); | 
|  | 1349 | if (val) { | 
|  | 1350 | if (strcasecmp(val, "enable") == 0) { | 
|  | 1351 | dut->ap_filshlp = VALUE_ENABLED; | 
|  | 1352 | } else if (strcasecmp(val, "disable") == 0) { | 
|  | 1353 | dut->ap_filshlp = VALUE_DISABLED; | 
|  | 1354 | } else { | 
|  | 1355 | send_resp(dut, conn, SIGMA_INVALID, | 
|  | 1356 | "errorCode,Unsupported FILSHLP"); | 
|  | 1357 | return 0; | 
|  | 1358 | } | 
|  | 1359 | } | 
|  | 1360 |  | 
|  | 1361 | val = get_param(cmd, "NAIRealm"); | 
|  | 1362 | if (val) { | 
|  | 1363 | dut->ap_nairealm_int = 1; | 
|  | 1364 | if (strlen(val) > sizeof(dut->ap_nairealm) - 1) | 
|  | 1365 | return -1; | 
|  | 1366 | snprintf(dut->ap_nairealm, sizeof(dut->ap_nairealm), "%s", val); | 
|  | 1367 | } | 
|  | 1368 |  | 
|  | 1369 | val = get_param(cmd, "DeauthDisassocTx"); | 
|  | 1370 | if (val) { | 
|  | 1371 | if (strcasecmp(val, "disable") == 0) { | 
|  | 1372 | deauth_disassoc(dut, ifname, val); | 
|  | 1373 | } else { | 
|  | 1374 | send_resp(dut, conn, SIGMA_INVALID, | 
|  | 1375 | "errorCode,Unsupported DeauthDisassocTx"); | 
|  | 1376 | return 0; | 
|  | 1377 | } | 
|  | 1378 | } | 
|  | 1379 |  | 
|  | 1380 | val = get_param(cmd, "RNR"); | 
|  | 1381 | if (val) { | 
|  | 1382 | if (strcasecmp(val, "enable") == 0) { | 
|  | 1383 | dut->ap_rnr = VALUE_ENABLED; | 
|  | 1384 | } else if (strcasecmp(val, "disable") == 0) { | 
|  | 1385 | dut->ap_rnr = VALUE_DISABLED; | 
|  | 1386 | } else { | 
|  | 1387 | send_resp(dut, conn, SIGMA_INVALID, | 
|  | 1388 | "errorCode,Unsupported RNR"); | 
|  | 1389 | return 0; | 
|  | 1390 | } | 
|  | 1391 | } | 
|  | 1392 |  | 
|  | 1393 | val = get_param(cmd, "BLEChannelUtil"); | 
|  | 1394 | if (val) | 
|  | 1395 | dut->ap_blechanutil = atoi(val); | 
|  | 1396 |  | 
|  | 1397 | val = get_param(cmd, "BLEAvailAdminCap"); | 
|  | 1398 | if (val) | 
|  | 1399 | dut->ap_ble_admit_cap = atoi(val); | 
|  | 1400 |  | 
|  | 1401 | val = get_param(cmd, "DataPPDUDuration"); | 
|  | 1402 | if (val) | 
|  | 1403 | dut->ap_datappdudura = atoi(val); | 
|  | 1404 |  | 
|  | 1405 | val = get_param(cmd, "AirTimeFract"); | 
|  | 1406 | if (val) | 
|  | 1407 | dut->ap_airtimefract = atoi(val); | 
|  | 1408 |  | 
|  | 1409 | val = get_param(cmd, "dhcpServIPADDR"); | 
|  | 1410 | if (val) { | 
|  | 1411 | if (strlen(val) > sizeof(dut->ap_dhcpserv_ipaddr) - 1) | 
|  | 1412 | return -1; | 
|  | 1413 | snprintf(dut->ap_dhcpserv_ipaddr, | 
|  | 1414 | sizeof(dut->ap_dhcpserv_ipaddr), "%s", val); | 
|  | 1415 | dut->ap_dhcp_stop = 1; | 
|  | 1416 | } | 
|  | 1417 |  | 
|  | 1418 | val = get_param(cmd, "ESP_IE"); | 
|  | 1419 | if (val) { | 
|  | 1420 | if (strcasecmp(val, "enable") == 0) { | 
|  | 1421 | dut->ap_esp = VALUE_ENABLED; | 
|  | 1422 | } else if (strcasecmp(val, "disable") == 0) { | 
|  | 1423 | dut->ap_esp = VALUE_DISABLED; | 
|  | 1424 | } else { | 
|  | 1425 | send_resp(dut, conn, SIGMA_INVALID, | 
|  | 1426 | "errorCode,Unsupported ESP_IE"); | 
|  | 1427 | return 0; | 
|  | 1428 | } | 
|  | 1429 | } | 
|  | 1430 |  | 
|  | 1431 | val = get_param(cmd, "BAWinSize"); | 
|  | 1432 | if (val) | 
|  | 1433 | dut->ap_bawinsize = atoi(val); | 
|  | 1434 |  | 
|  | 1435 | val = get_param(cmd, "BLEStaCount"); | 
|  | 1436 | if (val) | 
|  | 1437 | dut->ap_blestacnt = atoi(val); | 
|  | 1438 |  | 
| priyadharshini gowthaman | 350f191 | 2018-06-04 13:09:12 -0700 | [diff] [blame] | 1439 | val = get_param(cmd, "PPDUTxType"); | 
|  | 1440 | if (val) { | 
|  | 1441 | if (strcasecmp(val, "MU") == 0) { | 
|  | 1442 | dut->ap_he_ppdu = PPDU_MU; | 
|  | 1443 | } else { | 
|  | 1444 | send_resp(dut, conn, SIGMA_INVALID, | 
|  | 1445 | "errorCode,Unsupported PPDUTxType"); | 
|  | 1446 | return 0; | 
|  | 1447 | } | 
|  | 1448 | } | 
|  | 1449 |  | 
| Alexei Avshalom Lazar | 33f700c | 2018-12-18 16:00:39 +0200 | [diff] [blame] | 1450 | val = get_param(cmd, "WscIEFragment"); | 
|  | 1451 | if (val && strcasecmp(val, "enable") == 0) { | 
|  | 1452 | sigma_dut_print(dut, DUT_MSG_DEBUG, | 
|  | 1453 | "Enable WSC IE fragmentation"); | 
|  | 1454 | dut->wsc_fragment = 1; | 
|  | 1455 | } | 
|  | 1456 |  | 
| Alexei Avshalom Lazar | 79f5727 | 2018-12-23 17:22:47 +0200 | [diff] [blame] | 1457 | val = get_param(cmd, "MSDUSize"); | 
|  | 1458 | if (val) { | 
|  | 1459 | int mtu; | 
|  | 1460 |  | 
|  | 1461 | dut->amsdu_size = atoi(val); | 
|  | 1462 | if (dut->amsdu_size > IEEE80211_MAX_DATA_LEN_DMG || | 
|  | 1463 | dut->amsdu_size < IEEE80211_SNAP_LEN_DMG) { | 
|  | 1464 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 1465 | "MSDUSize %d is above max %d or below min %d", | 
|  | 1466 | dut->amsdu_size, | 
|  | 1467 | IEEE80211_MAX_DATA_LEN_DMG, | 
|  | 1468 | IEEE80211_SNAP_LEN_DMG); | 
|  | 1469 | dut->amsdu_size = 0; | 
| Jouni Malinen | 0e29cf2 | 2019-02-19 01:13:21 +0200 | [diff] [blame] | 1470 | return ERROR_SEND_STATUS; | 
| Alexei Avshalom Lazar | 79f5727 | 2018-12-23 17:22:47 +0200 | [diff] [blame] | 1471 | } | 
|  | 1472 |  | 
|  | 1473 | mtu = dut->amsdu_size - IEEE80211_SNAP_LEN_DMG; | 
|  | 1474 | sigma_dut_print(dut, DUT_MSG_DEBUG, | 
|  | 1475 | "Setting amsdu_size to %d", mtu); | 
|  | 1476 | snprintf(buf, sizeof(buf), "ifconfig %s mtu %d", | 
|  | 1477 | get_station_ifname(), mtu); | 
|  | 1478 |  | 
|  | 1479 | if (system(buf) != 0) { | 
|  | 1480 | sigma_dut_print(dut, DUT_MSG_ERROR, "Failed to set %s", | 
|  | 1481 | buf); | 
| Jouni Malinen | 0e29cf2 | 2019-02-19 01:13:21 +0200 | [diff] [blame] | 1482 | return ERROR_SEND_STATUS; | 
| Alexei Avshalom Lazar | 79f5727 | 2018-12-23 17:22:47 +0200 | [diff] [blame] | 1483 | } | 
|  | 1484 | } | 
|  | 1485 |  | 
| Alexei Avshalom Lazar | 0e239a9 | 2018-12-23 17:27:50 +0200 | [diff] [blame] | 1486 | val = get_param(cmd, "BAckRcvBuf"); | 
|  | 1487 | if (val) { | 
|  | 1488 | dut->back_rcv_buf = atoi(val); | 
|  | 1489 | if (dut->back_rcv_buf == 0) { | 
|  | 1490 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 1491 | "Failed to convert %s or value is 0", | 
|  | 1492 | val); | 
| Jouni Malinen | 0e29cf2 | 2019-02-19 01:13:21 +0200 | [diff] [blame] | 1493 | return ERROR_SEND_STATUS; | 
| Alexei Avshalom Lazar | 0e239a9 | 2018-12-23 17:27:50 +0200 | [diff] [blame] | 1494 | } | 
|  | 1495 |  | 
|  | 1496 | sigma_dut_print(dut, DUT_MSG_DEBUG, | 
|  | 1497 | "Setting BAckRcvBuf to %s", val); | 
|  | 1498 | } | 
|  | 1499 |  | 
| Alexei Avshalom Lazar | bc180dc | 2018-12-18 16:01:14 +0200 | [diff] [blame] | 1500 | val = get_param(cmd, "ExtSchIE"); | 
|  | 1501 | if (val && !strcasecmp(val, "Enable")) { | 
|  | 1502 | int num_allocs = MAX_ESE_ALLOCS; | 
|  | 1503 |  | 
|  | 1504 | if (sta_extract_60g_ese(dut, cmd, dut->ap_ese_allocs, | 
|  | 1505 | &num_allocs)) { | 
|  | 1506 | send_resp(dut, conn, SIGMA_INVALID, | 
|  | 1507 | "errorCode,Invalid ExtSchIE"); | 
|  | 1508 | return 0; | 
|  | 1509 | } | 
|  | 1510 | dut->ap_num_ese_allocs = num_allocs; | 
|  | 1511 | } | 
|  | 1512 |  | 
| Alexei Avshalom Lazar | 49498b8 | 2019-01-31 15:16:32 +0200 | [diff] [blame^] | 1513 | if (is_60g_sigma_dut(dut)) { | 
|  | 1514 | unsigned int abft_len = 1; /* default is one slot */ | 
|  | 1515 |  | 
|  | 1516 | val = get_param(cmd, "ABFTLRang"); | 
|  | 1517 | if (val) { | 
|  | 1518 | sigma_dut_print(dut, DUT_MSG_DEBUG, | 
|  | 1519 | "ABFTLRang parameter %s", val); | 
|  | 1520 | if (strcasecmp(val, "Gt1") == 0) | 
|  | 1521 | abft_len = 2; /* 2 slots in this case */ | 
|  | 1522 | } | 
|  | 1523 |  | 
|  | 1524 | if (sta_set_60g_abft_len(dut, conn, abft_len)) { | 
|  | 1525 | send_resp(dut, conn, SIGMA_ERROR, | 
|  | 1526 | "ErrorCode,Can't set ABFT length"); | 
|  | 1527 | return STATUS_SENT; | 
|  | 1528 | } | 
|  | 1529 | } | 
|  | 1530 |  | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1531 | return 1; | 
|  | 1532 | } | 
|  | 1533 |  | 
|  | 1534 |  | 
|  | 1535 | static void ath_inject_frame(struct sigma_dut *dut, const char *ifname, int tid) | 
|  | 1536 | { | 
|  | 1537 | char buf[256]; | 
|  | 1538 | int tid_to_dscp[] = { 0x00, 0x20, 0x40, 0x60, 0x80, 0xa0, 0xc0, 0xe0 }; | 
|  | 1539 |  | 
| Pradeep Reddy POTTETI | d31d132 | 2016-10-13 17:22:03 +0530 | [diff] [blame] | 1540 | if (tid < 0 || | 
|  | 1541 | tid >= (int) (sizeof(tid_to_dscp) / sizeof(tid_to_dscp[0]))) { | 
|  | 1542 | sigma_dut_print(dut, DUT_MSG_ERROR, "Unsupported TID: %d", tid); | 
|  | 1543 | return; | 
|  | 1544 | } | 
|  | 1545 |  | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1546 | snprintf(buf, sizeof(buf), | 
|  | 1547 | "wlanconfig %s list sta | grep : | cut -b 1-17 > %s", | 
|  | 1548 | ifname, VI_QOS_TMP_FILE); | 
|  | 1549 | if (system(buf) != 0) | 
|  | 1550 | return; | 
|  | 1551 |  | 
|  | 1552 | snprintf(buf, sizeof(buf), | 
|  | 1553 | "ifconfig %s | grep HWaddr | cut -b 39-56 >> %s", | 
|  | 1554 | ifname, VI_QOS_TMP_FILE); | 
|  | 1555 | if (system(buf) != 0) | 
|  | 1556 | sigma_dut_print(dut, DUT_MSG_ERROR, "Retrieve HWaddr failed"); | 
|  | 1557 |  | 
|  | 1558 | snprintf(buf, sizeof(buf), "sed -n '3,$p' %s >> %s", | 
|  | 1559 | VI_QOS_REFFILE, VI_QOS_TMP_FILE); | 
|  | 1560 | if (system(buf) != 0) { | 
|  | 1561 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 1562 | "Output redirection to VI_QOS_TMP_FILE failed"); | 
|  | 1563 | } | 
|  | 1564 |  | 
|  | 1565 | snprintf(buf, sizeof(buf), "sed '5 c %x' %s > %s", | 
|  | 1566 | tid_to_dscp[tid], VI_QOS_TMP_FILE, VI_QOS_FILE); | 
|  | 1567 | if (system(buf) != 0) { | 
|  | 1568 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 1569 | "Append TID to VI_QOS_FILE failed "); | 
|  | 1570 | } | 
|  | 1571 |  | 
|  | 1572 | snprintf(buf, sizeof(buf), "ethinject %s %s", ifname, VI_QOS_FILE); | 
|  | 1573 | if (system(buf) != 0) | 
|  | 1574 | sigma_dut_print(dut, DUT_MSG_ERROR, "Ethinject frame failed"); | 
|  | 1575 | } | 
|  | 1576 |  | 
|  | 1577 |  | 
|  | 1578 | static int ath_ap_send_addba_req(struct sigma_dut *dut, struct sigma_conn *conn, | 
|  | 1579 | struct sigma_cmd *cmd) | 
|  | 1580 | { | 
|  | 1581 | const char *val; | 
|  | 1582 | char *ifname; | 
|  | 1583 | char buf[256]; | 
|  | 1584 | int tid = 0; | 
|  | 1585 |  | 
|  | 1586 | ifname = get_main_ifname(); | 
|  | 1587 | val = get_param(cmd, "TID"); | 
|  | 1588 | if (val) { | 
|  | 1589 | tid = atoi(val); | 
|  | 1590 | if (tid) | 
|  | 1591 | ath_inject_frame(dut, ifname, tid); | 
|  | 1592 | } | 
|  | 1593 |  | 
|  | 1594 | /* NOTE: This is the command sequence on Peregrine for ADDBA */ | 
|  | 1595 | snprintf(buf, sizeof(buf), "iwpriv %s setaddbaoper 1", ifname); | 
|  | 1596 | if (system(buf) != 0) { | 
|  | 1597 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 1598 | "iwpriv setaddbaoper failed"); | 
|  | 1599 | } | 
|  | 1600 |  | 
|  | 1601 | snprintf(buf, sizeof(buf), "wifitool %s senddelba 1 %d 1 4", | 
|  | 1602 | ifname, tid); | 
|  | 1603 | if (system(buf) != 0) { | 
|  | 1604 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 1605 | "wifitool senddelba failed"); | 
|  | 1606 | } | 
|  | 1607 |  | 
|  | 1608 | snprintf(buf, sizeof(buf), "wifitool %s sendaddba 1 %d 64", | 
|  | 1609 | ifname, tid); | 
|  | 1610 | if (system(buf) != 0) { | 
|  | 1611 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 1612 | "wifitool sendaddba failed"); | 
|  | 1613 | } | 
|  | 1614 |  | 
|  | 1615 | return 1; | 
|  | 1616 | } | 
|  | 1617 |  | 
|  | 1618 |  | 
| Mohammed Shafi Shajakhan | a0535d4 | 2016-06-17 11:55:00 +0530 | [diff] [blame] | 1619 | static int ath10k_debug_enable_addba_req(struct sigma_dut *dut, int tid, | 
|  | 1620 | const char *sta_mac, | 
|  | 1621 | const char *dir_path) | 
|  | 1622 | { | 
|  | 1623 | DIR *dir; | 
|  | 1624 | struct dirent *entry; | 
|  | 1625 | char buf[128], path[128]; | 
|  | 1626 | int ret = 0; | 
|  | 1627 |  | 
|  | 1628 | dir = opendir(dir_path); | 
|  | 1629 | if (!dir) | 
|  | 1630 | return 0; | 
|  | 1631 |  | 
|  | 1632 | while ((entry = readdir(dir))) { | 
|  | 1633 | ret = 1; | 
|  | 1634 |  | 
|  | 1635 | if (strcmp(entry->d_name, ".") == 0 || | 
|  | 1636 | strcmp(entry->d_name, "..") == 0) | 
|  | 1637 | continue; | 
|  | 1638 |  | 
|  | 1639 | snprintf(path, sizeof(path) - 1, "%s/%s", | 
|  | 1640 | dir_path, entry->d_name); | 
|  | 1641 | path[sizeof(path) - 1] = 0; | 
|  | 1642 |  | 
|  | 1643 | if (strcmp(entry->d_name, sta_mac) == 0) { | 
|  | 1644 | snprintf(buf, sizeof(buf), "echo 1 > %s/aggr_mode", | 
|  | 1645 | path); | 
|  | 1646 | if (system(buf) != 0) { | 
|  | 1647 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 1648 | "Failed to set aggr mode for ath10k"); | 
|  | 1649 | } | 
|  | 1650 |  | 
|  | 1651 | snprintf(buf, sizeof(buf), "echo %d 32 > %s/addba", | 
|  | 1652 | tid, path); | 
|  | 1653 | if (system(buf) != 0) { | 
|  | 1654 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 1655 | "Failed to set addbareq for ath10k"); | 
|  | 1656 | } | 
|  | 1657 |  | 
|  | 1658 | break; | 
|  | 1659 | } | 
|  | 1660 |  | 
|  | 1661 | /* Recursively search subdirectories */ | 
|  | 1662 | ath10k_debug_enable_addba_req(dut, tid, sta_mac, path); | 
|  | 1663 | } | 
|  | 1664 |  | 
|  | 1665 | closedir(dir); | 
|  | 1666 |  | 
|  | 1667 | return ret; | 
|  | 1668 | } | 
|  | 1669 |  | 
|  | 1670 |  | 
|  | 1671 | static int ath10k_ap_send_addba_req(struct sigma_dut *dut, | 
|  | 1672 | struct sigma_cmd *cmd) | 
|  | 1673 | { | 
|  | 1674 | const char *val; | 
|  | 1675 | int tid = 0; | 
|  | 1676 |  | 
|  | 1677 | val = get_param(cmd, "TID"); | 
|  | 1678 | if (val) | 
|  | 1679 | tid = atoi(val); | 
|  | 1680 |  | 
|  | 1681 | val = get_param(cmd, "sta_mac_address"); | 
|  | 1682 | if (!val) { | 
|  | 1683 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 1684 | "Failed to parse station MAC address"); | 
|  | 1685 | return 0; | 
|  | 1686 | } | 
|  | 1687 |  | 
|  | 1688 | return ath10k_debug_enable_addba_req(dut, tid, val, | 
|  | 1689 | "/sys/kernel/debug/ieee80211"); | 
|  | 1690 | } | 
|  | 1691 |  | 
|  | 1692 |  | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1693 | static int cmd_ap_send_addba_req(struct sigma_dut *dut, struct sigma_conn *conn, | 
|  | 1694 | struct sigma_cmd *cmd) | 
|  | 1695 | { | 
|  | 1696 | /* const char *name = get_param(cmd, "NAME"); */ | 
|  | 1697 | /* const char *ifname = get_param(cmd, "INTERFACE"); */ | 
| Mohammed Shafi Shajakhan | a0535d4 | 2016-06-17 11:55:00 +0530 | [diff] [blame] | 1698 | struct stat s; | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1699 |  | 
|  | 1700 | switch (get_driver_type()) { | 
|  | 1701 | case DRIVER_ATHEROS: | 
|  | 1702 | return ath_ap_send_addba_req(dut, conn, cmd); | 
| Alexei Avshalom Lazar | 79fa3fe | 2018-12-24 15:43:33 +0200 | [diff] [blame] | 1703 | #ifdef __linux__ | 
|  | 1704 | case DRIVER_WIL6210: | 
|  | 1705 | return send_addba_60g(dut, conn, cmd, "sta_mac_address"); | 
|  | 1706 | #endif /* __linux__ */ | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1707 | case DRIVER_OPENWRT: | 
|  | 1708 | switch (get_openwrt_driver_type()) { | 
|  | 1709 | case OPENWRT_DRIVER_ATHEROS: | 
|  | 1710 | return ath_ap_send_addba_req(dut, conn, cmd); | 
|  | 1711 | default: | 
|  | 1712 | send_resp(dut, conn, SIGMA_ERROR, | 
|  | 1713 | "errorCode,ap_send_addba_req not supported with this driver"); | 
|  | 1714 | return 0; | 
|  | 1715 | } | 
| Pradeep Reddy POTTETI | fdb0491 | 2016-08-02 14:16:24 +0530 | [diff] [blame] | 1716 | case DRIVER_WCN: | 
|  | 1717 | case DRIVER_LINUX_WCN: | 
|  | 1718 | /* AP automatically sends ADDBA request after association. */ | 
|  | 1719 | sigma_dut_print(dut, DUT_MSG_INFO, | 
|  | 1720 | "ap_send_addba_req command ignored"); | 
|  | 1721 | return 1; | 
| Mohammed Shafi Shajakhan | a0535d4 | 2016-06-17 11:55:00 +0530 | [diff] [blame] | 1722 | case DRIVER_MAC80211: | 
|  | 1723 | if (stat("/sys/module/ath10k_core", &s) == 0) | 
|  | 1724 | return ath10k_ap_send_addba_req(dut, cmd); | 
|  | 1725 | /* fall through */ | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1726 | default: | 
|  | 1727 | send_resp(dut, conn, SIGMA_ERROR, | 
|  | 1728 | "errorCode,ap_send_addba_req not supported with this driver"); | 
|  | 1729 | return 0; | 
|  | 1730 | } | 
|  | 1731 | } | 
|  | 1732 |  | 
|  | 1733 |  | 
|  | 1734 | static int cmd_ap_set_security(struct sigma_dut *dut, struct sigma_conn *conn, | 
|  | 1735 | struct sigma_cmd *cmd) | 
|  | 1736 | { | 
|  | 1737 | /* const char *name = get_param(cmd, "NAME"); */ | 
|  | 1738 | const char *val; | 
|  | 1739 | unsigned int wlan_tag = 1; | 
| Ankita Bajaj | 0d212e8 | 2017-11-27 15:54:57 +0530 | [diff] [blame] | 1740 | const char *security; | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1741 |  | 
|  | 1742 | val = get_param(cmd, "WLAN_TAG"); | 
|  | 1743 | if (val) | 
|  | 1744 | wlan_tag = atoi(val); | 
|  | 1745 |  | 
| Ankita Bajaj | 0d212e8 | 2017-11-27 15:54:57 +0530 | [diff] [blame] | 1746 | security = get_param(cmd, "Security"); | 
|  | 1747 |  | 
| Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 1748 | if (wlan_tag > 1) { | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1749 | val = get_param(cmd, "KEYMGNT"); | 
| Ankita Bajaj | 0d212e8 | 2017-11-27 15:54:57 +0530 | [diff] [blame] | 1750 | if (!val) | 
|  | 1751 | val = get_param(cmd, "KeyMgmtType"); | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1752 | if (val) { | 
| Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 1753 | if (strcasecmp(val, "NONE") == 0) { | 
|  | 1754 | dut->ap_tag_key_mgmt[wlan_tag - 2] = AP2_OPEN; | 
|  | 1755 | } else if (strcasecmp(val, "OSEN") == 0 && | 
|  | 1756 | wlan_tag == 2) { | 
|  | 1757 | /* | 
|  | 1758 | * OSEN only supported on WLAN_TAG = 2 for now | 
|  | 1759 | */ | 
|  | 1760 | dut->ap_tag_key_mgmt[wlan_tag - 2] = AP2_OSEN; | 
| Ankita Bajaj | 0d212e8 | 2017-11-27 15:54:57 +0530 | [diff] [blame] | 1761 | } else if (strcasecmp(val, "WPA2-PSK") == 0 || | 
|  | 1762 | (security && | 
|  | 1763 | strcasecmp(security, "PSK") == 0 && | 
|  | 1764 | strcasecmp(val, "WPA2") == 0)) { | 
| Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 1765 | dut->ap_tag_key_mgmt[wlan_tag - 2] = | 
|  | 1766 | AP2_WPA2_PSK; | 
| Jouni Malinen | 353ba8b | 2018-01-10 17:04:12 +0200 | [diff] [blame] | 1767 | } else if (strcasecmp(val, "OWE") == 0 && | 
|  | 1768 | wlan_tag == 2) { | 
|  | 1769 | dut->ap_tag_key_mgmt[wlan_tag - 2] = | 
|  | 1770 | AP2_WPA2_OWE; | 
| Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 1771 | } else { | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1772 | send_resp(dut, conn, SIGMA_INVALID, | 
|  | 1773 | "errorCode,Unsupported KEYMGNT"); | 
|  | 1774 | return 0; | 
|  | 1775 | } | 
|  | 1776 | return 1; | 
|  | 1777 | } | 
|  | 1778 | } | 
|  | 1779 |  | 
|  | 1780 | val = get_param(cmd, "KEYMGNT"); | 
| Ankita Bajaj | 0d212e8 | 2017-11-27 15:54:57 +0530 | [diff] [blame] | 1781 | if (!val) | 
|  | 1782 | val = get_param(cmd,"KeyMgmtType"); | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1783 | if (val) { | 
| Ankita Bajaj | 0d212e8 | 2017-11-27 15:54:57 +0530 | [diff] [blame] | 1784 | if (strcasecmp(val, "WPA2-PSK") == 0 || | 
|  | 1785 | (security && strcasecmp(security, "PSK") == 0 && | 
|  | 1786 | strcasecmp(val, "WPA2") == 0)) { | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1787 | dut->ap_key_mgmt = AP_WPA2_PSK; | 
|  | 1788 | dut->ap_cipher = AP_CCMP; | 
|  | 1789 | } else if (strcasecmp(val, "WPA2-EAP") == 0 || | 
|  | 1790 | strcasecmp(val, "WPA2-Ent") == 0) { | 
|  | 1791 | dut->ap_key_mgmt = AP_WPA2_EAP; | 
|  | 1792 | dut->ap_cipher = AP_CCMP; | 
| Jouni Malinen | ad395a2 | 2017-09-01 21:13:46 +0300 | [diff] [blame] | 1793 | } else if (strcasecmp(val, "SuiteB") == 0) { | 
|  | 1794 | dut->ap_key_mgmt = AP_SUITEB; | 
|  | 1795 | dut->ap_cipher = AP_GCMP_256; | 
| Jouni Malinen | d75e4d8 | 2018-01-11 20:21:15 +0200 | [diff] [blame] | 1796 | dut->ap_pmf = AP_PMF_REQUIRED; | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1797 | } else if (strcasecmp(val, "WPA-PSK") == 0) { | 
|  | 1798 | dut->ap_key_mgmt = AP_WPA_PSK; | 
|  | 1799 | dut->ap_cipher = AP_TKIP; | 
|  | 1800 | } else if (strcasecmp(val, "WPA-EAP") == 0 || | 
|  | 1801 | strcasecmp(val, "WPA-Ent") == 0) { | 
|  | 1802 | dut->ap_key_mgmt = AP_WPA_EAP; | 
|  | 1803 | dut->ap_cipher = AP_TKIP; | 
|  | 1804 | } else if (strcasecmp(val, "WPA2-Mixed") == 0) { | 
|  | 1805 | dut->ap_key_mgmt = AP_WPA2_EAP_MIXED; | 
|  | 1806 | dut->ap_cipher = AP_CCMP_TKIP; | 
|  | 1807 | } else if (strcasecmp(val, "WPA2-PSK-Mixed") == 0) { | 
|  | 1808 | dut->ap_key_mgmt = AP_WPA2_PSK_MIXED; | 
|  | 1809 | dut->ap_cipher = AP_CCMP_TKIP; | 
| Jouni Malinen | 794a7a3 | 2018-01-10 16:39:34 +0200 | [diff] [blame] | 1810 | } else if (strcasecmp(val, "WPA2-SAE") == 0 || | 
|  | 1811 | strcasecmp(val, "SAE") == 0) { | 
| Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 1812 | dut->ap_key_mgmt = AP_WPA2_SAE; | 
|  | 1813 | dut->ap_cipher = AP_CCMP; | 
| Jouni Malinen | 1287cd7 | 2018-01-04 17:08:01 +0200 | [diff] [blame] | 1814 | dut->ap_pmf = AP_PMF_REQUIRED; | 
| Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 1815 | } else if (strcasecmp(val, "WPA2-PSK-SAE") == 0) { | 
|  | 1816 | dut->ap_key_mgmt = AP_WPA2_PSK_SAE; | 
|  | 1817 | dut->ap_cipher = AP_CCMP; | 
| Jouni Malinen | 1287cd7 | 2018-01-04 17:08:01 +0200 | [diff] [blame] | 1818 | dut->ap_pmf = AP_PMF_OPTIONAL; | 
| Jouni Malinen | 147b3c3 | 2017-10-09 16:51:54 +0300 | [diff] [blame] | 1819 | } else if (strcasecmp(val, "OWE") == 0) { | 
|  | 1820 | dut->ap_key_mgmt = AP_WPA2_OWE; | 
|  | 1821 | dut->ap_cipher = AP_CCMP; | 
| Jouni Malinen | 1287cd7 | 2018-01-04 17:08:01 +0200 | [diff] [blame] | 1822 | dut->ap_pmf = AP_PMF_REQUIRED; | 
| Jouni Malinen | 4cf699f | 2018-06-19 00:46:27 +0300 | [diff] [blame] | 1823 | } else if (strcasecmp(val, "WPA2-ENT-OSEN") == 0) { | 
|  | 1824 | dut->ap_key_mgmt = AP_WPA2_EAP_OSEN; | 
|  | 1825 | dut->ap_cipher = AP_CCMP; | 
|  | 1826 | dut->ap_pmf = AP_PMF_OPTIONAL; | 
| Jouni Malinen | c2b9121 | 2018-09-12 02:26:39 +0300 | [diff] [blame] | 1827 | } else if (strcasecmp(val, "OSEN") == 0) { | 
|  | 1828 | dut->ap_key_mgmt = AP_OSEN; | 
|  | 1829 | dut->ap_cipher = AP_CCMP; | 
| Jouni Malinen | 6be21c8 | 2018-08-01 18:47:24 +0300 | [diff] [blame] | 1830 | } else if (strcasecmp(val, "FT-EAP") == 0) { | 
|  | 1831 | dut->ap_key_mgmt = AP_WPA2_FT_EAP; | 
|  | 1832 | dut->ap_cipher = AP_CCMP; | 
|  | 1833 | dut->ap_pmf = AP_PMF_OPTIONAL; | 
|  | 1834 | } else if (strcasecmp(val, "FT-PSK") == 0) { | 
|  | 1835 | dut->ap_key_mgmt = AP_WPA2_FT_PSK; | 
|  | 1836 | dut->ap_cipher = AP_CCMP; | 
|  | 1837 | dut->ap_pmf = AP_PMF_OPTIONAL; | 
|  | 1838 | } else if (strcasecmp(val, "WPA2-ENT-256") == 0) { | 
|  | 1839 | dut->ap_key_mgmt = AP_WPA2_EAP_SHA256; | 
|  | 1840 | dut->ap_cipher = AP_CCMP; | 
|  | 1841 | dut->ap_pmf = AP_PMF_OPTIONAL; | 
|  | 1842 | } else if (strcasecmp(val, "WPA2-PSK-256") == 0) { | 
|  | 1843 | dut->ap_key_mgmt = AP_WPA2_PSK_SHA256; | 
|  | 1844 | dut->ap_cipher = AP_CCMP; | 
|  | 1845 | dut->ap_pmf = AP_PMF_OPTIONAL; | 
|  | 1846 | } else if (strcasecmp(val, "WPA2-ENT-FT-EAP") == 0) { | 
|  | 1847 | dut->ap_key_mgmt = AP_WPA2_ENT_FT_EAP; | 
|  | 1848 | dut->ap_cipher = AP_CCMP; | 
|  | 1849 | dut->ap_pmf = AP_PMF_OPTIONAL; | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1850 | } else if (strcasecmp(val, "NONE") == 0) { | 
|  | 1851 | dut->ap_key_mgmt = AP_OPEN; | 
|  | 1852 | dut->ap_cipher = AP_PLAIN; | 
|  | 1853 | } else { | 
|  | 1854 | send_resp(dut, conn, SIGMA_INVALID, | 
|  | 1855 | "errorCode,Unsupported KEYMGNT"); | 
|  | 1856 | return 0; | 
|  | 1857 | } | 
|  | 1858 | } | 
|  | 1859 |  | 
| Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 1860 | val = get_param(cmd, "ECGroupID"); | 
|  | 1861 | if (val) { | 
| Jouni Malinen | ed670f4 | 2017-08-31 01:39:28 +0300 | [diff] [blame] | 1862 | free(dut->ap_sae_groups); | 
|  | 1863 | dut->ap_sae_groups = strdup(val); | 
| Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 1864 | } | 
|  | 1865 |  | 
| Jouni Malinen | 2f524ce | 2017-08-31 01:43:29 +0300 | [diff] [blame] | 1866 | val = get_param(cmd, "AntiCloggingThreshold"); | 
|  | 1867 | if (val) | 
|  | 1868 | dut->sae_anti_clogging_threshold = atoi(val); | 
|  | 1869 |  | 
| Jouni Malinen | b347db0 | 2017-09-02 01:36:03 +0300 | [diff] [blame] | 1870 | val = get_param(cmd, "Reflection"); | 
|  | 1871 | if (val) | 
|  | 1872 | dut->sae_reflection = strcasecmp(val, "SAE") == 0; | 
|  | 1873 |  | 
| Jouni Malinen | 6814313 | 2017-09-02 02:34:08 +0300 | [diff] [blame] | 1874 | val = get_param(cmd, "InvalidSAEElement"); | 
|  | 1875 | if (val) { | 
|  | 1876 | free(dut->sae_commit_override); | 
|  | 1877 | dut->sae_commit_override = strdup(val); | 
|  | 1878 | } | 
|  | 1879 |  | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1880 | val = get_param(cmd, "ENCRYPT"); | 
| Ankita Bajaj | 0d212e8 | 2017-11-27 15:54:57 +0530 | [diff] [blame] | 1881 | if (!val) | 
|  | 1882 | val = get_param(cmd, "EncpType"); | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1883 | if (val) { | 
|  | 1884 | if (strcasecmp(val, "WEP") == 0) { | 
|  | 1885 | dut->ap_cipher = AP_WEP; | 
|  | 1886 | } else if (strcasecmp(val, "TKIP") == 0) { | 
|  | 1887 | dut->ap_cipher = AP_TKIP; | 
|  | 1888 | } else if (strcasecmp(val, "AES") == 0 || | 
|  | 1889 | strcasecmp(val, "AES-CCMP") == 0) { | 
|  | 1890 | dut->ap_cipher = AP_CCMP; | 
| Jouni Malinen | 3d633da | 2017-09-14 22:19:21 +0300 | [diff] [blame] | 1891 | } else if (strcasecmp(val, "AES-GCMP") == 0) { | 
|  | 1892 | dut->ap_cipher = AP_GCMP_128; | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1893 | } else { | 
|  | 1894 | send_resp(dut, conn, SIGMA_INVALID, | 
|  | 1895 | "errorCode,Unsupported ENCRYPT"); | 
|  | 1896 | return 0; | 
|  | 1897 | } | 
|  | 1898 | } | 
|  | 1899 |  | 
| Jouni Malinen | 3d633da | 2017-09-14 22:19:21 +0300 | [diff] [blame] | 1900 | val = get_param(cmd, "PairwiseCipher"); | 
|  | 1901 | if (val) { | 
|  | 1902 | if (strcasecmp(val, "AES-GCMP-256") == 0) { | 
|  | 1903 | dut->ap_cipher = AP_GCMP_256; | 
|  | 1904 | } else if (strcasecmp(val, "AES-CCMP-256") == 0) { | 
|  | 1905 | dut->ap_cipher = AP_CCMP_256; | 
|  | 1906 | } else if (strcasecmp(val, "AES-GCMP-128") == 0) { | 
|  | 1907 | dut->ap_cipher = AP_GCMP_128; | 
|  | 1908 | } else if (strcasecmp(val, "AES-CCMP-128") == 0) { | 
|  | 1909 | dut->ap_cipher = AP_CCMP; | 
| Jouni Malinen | d538c78 | 2017-11-17 12:13:04 +0200 | [diff] [blame] | 1910 | } else if (strcasecmp(val, "AES-CCMP-128 AES-GCMP-256") == 0 || | 
|  | 1911 | strcasecmp(val, "AES-GCMP-256 AES-CCMP-128") == 0) { | 
|  | 1912 | dut->ap_cipher = AP_CCMP_128_GCMP_256; | 
| Jouni Malinen | 3d633da | 2017-09-14 22:19:21 +0300 | [diff] [blame] | 1913 | } else { | 
|  | 1914 | send_resp(dut, conn, SIGMA_INVALID, | 
|  | 1915 | "errorCode,Unsupported PairwiseCipher"); | 
|  | 1916 | return 0; | 
|  | 1917 | } | 
|  | 1918 | } | 
|  | 1919 |  | 
| Jouni Malinen | 2ba2449 | 2017-11-17 12:43:59 +0200 | [diff] [blame] | 1920 | val = get_param(cmd, "GroupCipher"); | 
|  | 1921 | if (val) { | 
|  | 1922 | if (strcasecmp(val, "AES-GCMP-256") == 0) { | 
|  | 1923 | dut->ap_group_cipher = AP_GCMP_256; | 
|  | 1924 | } else if (strcasecmp(val, "AES-CCMP-256") == 0) { | 
|  | 1925 | dut->ap_group_cipher = AP_CCMP_256; | 
|  | 1926 | } else if (strcasecmp(val, "AES-GCMP-128") == 0) { | 
|  | 1927 | dut->ap_group_cipher = AP_GCMP_128; | 
|  | 1928 | } else if (strcasecmp(val, "AES-CCMP-128") == 0) { | 
|  | 1929 | dut->ap_group_cipher = AP_CCMP; | 
|  | 1930 | } else { | 
|  | 1931 | send_resp(dut, conn, SIGMA_INVALID, | 
|  | 1932 | "errorCode,Unsupported GroupCipher"); | 
|  | 1933 | return 0; | 
|  | 1934 | } | 
|  | 1935 | } | 
|  | 1936 |  | 
| Jouni Malinen | 3d633da | 2017-09-14 22:19:21 +0300 | [diff] [blame] | 1937 | val = get_param(cmd, "GroupMgntCipher"); | 
|  | 1938 | if (val) { | 
|  | 1939 | if (strcasecmp(val, "BIP-GMAC-256") == 0) { | 
|  | 1940 | dut->ap_group_mgmt_cipher = AP_BIP_GMAC_256; | 
|  | 1941 | } else if (strcasecmp(val, "BIP-CMAC-256") == 0) { | 
|  | 1942 | dut->ap_group_mgmt_cipher = AP_BIP_CMAC_256; | 
|  | 1943 | } else if (strcasecmp(val, "BIP-GMAC-128") == 0) { | 
|  | 1944 | dut->ap_group_mgmt_cipher = AP_BIP_GMAC_128; | 
|  | 1945 | } else if (strcasecmp(val, "BIP-CMAC-128") == 0) { | 
|  | 1946 | dut->ap_group_mgmt_cipher = AP_BIP_CMAC_128; | 
|  | 1947 | } else { | 
|  | 1948 | send_resp(dut, conn, SIGMA_INVALID, | 
|  | 1949 | "errorCode,Unsupported GroupMgntCipher"); | 
|  | 1950 | return 0; | 
|  | 1951 | } | 
|  | 1952 | } | 
|  | 1953 |  | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1954 | val = get_param(cmd, "WEPKEY"); | 
|  | 1955 | if (val) { | 
|  | 1956 | size_t len; | 
|  | 1957 | if (dut->ap_cipher != AP_WEP) { | 
|  | 1958 | send_resp(dut, conn, SIGMA_INVALID, | 
|  | 1959 | "errorCode,Unexpected WEPKEY without WEP " | 
|  | 1960 | "configuration"); | 
|  | 1961 | return 0; | 
|  | 1962 | } | 
|  | 1963 | len = strlen(val); | 
|  | 1964 | if (len != 10 && len != 26) { | 
|  | 1965 | send_resp(dut, conn, SIGMA_INVALID, | 
|  | 1966 | "errorCode,Unexpected WEPKEY length"); | 
|  | 1967 | return 0; | 
|  | 1968 | } | 
|  | 1969 | snprintf(dut->ap_wepkey, sizeof(dut->ap_wepkey), "%s", val); | 
|  | 1970 | } | 
|  | 1971 |  | 
|  | 1972 | val = get_param(cmd, "PSK"); | 
| Ankita Bajaj | 0d212e8 | 2017-11-27 15:54:57 +0530 | [diff] [blame] | 1973 | if (!val) | 
|  | 1974 | val = get_param(cmd, "passphrase"); | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1975 | if (val) { | 
| Jouni Malinen | 2126f42 | 2017-10-11 23:24:33 +0300 | [diff] [blame] | 1976 | if (dut->ap_key_mgmt != AP_WPA2_SAE && strlen(val) > 64) | 
|  | 1977 | return -1; | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1978 | if (strlen(val) > sizeof(dut->ap_passphrase) - 1) | 
|  | 1979 | return -1; | 
|  | 1980 | snprintf(dut->ap_passphrase, sizeof(dut->ap_passphrase), | 
|  | 1981 | "%s", val); | 
|  | 1982 | } | 
|  | 1983 |  | 
| Jouni Malinen | 6337062 | 2017-11-18 17:47:13 +0200 | [diff] [blame] | 1984 | val = get_param(cmd, "PSKHEX"); | 
|  | 1985 | if (val) { | 
|  | 1986 | if (strlen(val) != 64) | 
|  | 1987 | return -1; | 
|  | 1988 | strlcpy(dut->ap_psk, val, sizeof(dut->ap_psk)); | 
|  | 1989 | } | 
|  | 1990 |  | 
| Ankita Bajaj | 0d212e8 | 2017-11-27 15:54:57 +0530 | [diff] [blame] | 1991 | if (dut->program == PROGRAM_OCE && dut->dev_role == DEVROLE_STA_CFON) | 
|  | 1992 | dut->ap_pmf = AP_PMF_OPTIONAL; | 
|  | 1993 |  | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 1994 | val = get_param(cmd, "PMF"); | 
|  | 1995 | if (val) { | 
|  | 1996 | if (strcasecmp(val, "Disabled") == 0) { | 
|  | 1997 | dut->ap_pmf = AP_PMF_DISABLED; | 
|  | 1998 | } else if (strcasecmp(val, "Optional") == 0) { | 
|  | 1999 | dut->ap_pmf = AP_PMF_OPTIONAL; | 
|  | 2000 | } else if (strcasecmp(val, "Required") == 0) { | 
|  | 2001 | dut->ap_pmf = AP_PMF_REQUIRED; | 
|  | 2002 | } else { | 
|  | 2003 | send_resp(dut, conn, SIGMA_INVALID, | 
|  | 2004 | "errorCode,Unsupported PMF"); | 
|  | 2005 | return 0; | 
|  | 2006 | } | 
|  | 2007 | } | 
|  | 2008 |  | 
|  | 2009 | if (dut->ap_key_mgmt == AP_OPEN) { | 
|  | 2010 | dut->ap_hs2 = 0; | 
|  | 2011 | dut->ap_pmf = AP_PMF_DISABLED; | 
|  | 2012 | } | 
|  | 2013 |  | 
|  | 2014 | dut->ap_add_sha256 = 0; | 
|  | 2015 | val = get_param(cmd, "SHA256AD"); | 
|  | 2016 | if (val == NULL) | 
|  | 2017 | val = get_param(cmd, "SHA256"); | 
|  | 2018 | if (val) { | 
|  | 2019 | if (strcasecmp(val, "Disabled") == 0) { | 
|  | 2020 | } else if (strcasecmp(val, "Enabled") == 0) { | 
|  | 2021 | dut->ap_add_sha256 = 1; | 
|  | 2022 | } else { | 
|  | 2023 | send_resp(dut, conn, SIGMA_INVALID, | 
|  | 2024 | "errorCode,Unsupported PMF"); | 
|  | 2025 | return 0; | 
|  | 2026 | } | 
|  | 2027 | } | 
|  | 2028 |  | 
| Sarvepalli, Rajesh Babu | 24dc7e4 | 2016-03-18 21:27:26 +0530 | [diff] [blame] | 2029 | val = get_param(cmd, "PreAuthentication"); | 
|  | 2030 | if (val) { | 
|  | 2031 | if (strcasecmp(val, "disabled") == 0) { | 
|  | 2032 | dut->ap_rsn_preauth = 0; | 
|  | 2033 | } else if (strcasecmp(val, "enabled") == 0) { | 
|  | 2034 | dut->ap_rsn_preauth = 1; | 
|  | 2035 | } else { | 
|  | 2036 | send_resp(dut, conn, SIGMA_INVALID, | 
|  | 2037 | "errorCode,Unsupported PreAuthentication value"); | 
|  | 2038 | return 0; | 
|  | 2039 | } | 
|  | 2040 | } | 
|  | 2041 |  | 
| priyadharshini gowthaman | de81f39 | 2017-12-28 15:28:49 -0800 | [diff] [blame] | 2042 | val = get_param(cmd, "AKMSuiteType"); | 
|  | 2043 | if (val) { | 
|  | 2044 | unsigned int akmsuitetype = 0; | 
|  | 2045 |  | 
|  | 2046 | dut->ap_akm = 1; | 
|  | 2047 | akmsuitetype = atoi(val); | 
|  | 2048 | if (akmsuitetype == 14) { | 
|  | 2049 | dut->ap_add_sha256 = 1; | 
|  | 2050 | } else if (akmsuitetype == 15) { | 
|  | 2051 | dut->ap_add_sha384 = 1; | 
|  | 2052 | } else { | 
|  | 2053 | send_resp(dut, conn, SIGMA_INVALID, | 
|  | 2054 | "errorCode,Unsupported AKMSuitetype"); | 
|  | 2055 | return 0; | 
|  | 2056 | } | 
|  | 2057 | } | 
|  | 2058 |  | 
|  | 2059 | val = get_param(cmd, "PMKSACaching"); | 
|  | 2060 | if (val) { | 
|  | 2061 | dut->ap_pmksa = 1; | 
|  | 2062 | if (strcasecmp(val, "disabled") == 0) { | 
|  | 2063 | dut->ap_pmksa_caching = 1; | 
|  | 2064 | } else if (strcasecmp(val, "enabled") == 0) { | 
|  | 2065 | dut->ap_pmksa_caching = 0; | 
|  | 2066 | } else { | 
|  | 2067 | send_resp(dut, conn, SIGMA_INVALID, | 
|  | 2068 | "errorCode,Unsupported PMKSACaching value"); | 
|  | 2069 | return 0; | 
|  | 2070 | } | 
|  | 2071 | } | 
|  | 2072 |  | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2073 | return 1; | 
|  | 2074 | } | 
|  | 2075 |  | 
|  | 2076 |  | 
| Ankita Bajaj | 0d5825b | 2017-10-25 16:20:17 +0530 | [diff] [blame] | 2077 | int sta_cfon_set_wireless(struct sigma_dut *dut, struct sigma_conn *conn, | 
|  | 2078 | struct sigma_cmd *cmd) | 
|  | 2079 | { | 
|  | 2080 | int status; | 
|  | 2081 |  | 
|  | 2082 | status = cmd_ap_set_wireless(dut, conn, cmd); | 
|  | 2083 | if (status != 1) | 
|  | 2084 | return status; | 
| Ankita Bajaj | 0d212e8 | 2017-11-27 15:54:57 +0530 | [diff] [blame] | 2085 | status = cmd_ap_set_security(dut, conn, cmd); | 
|  | 2086 | if (status != 1) | 
|  | 2087 | return status; | 
| Ankita Bajaj | 0d5825b | 2017-10-25 16:20:17 +0530 | [diff] [blame] | 2088 | return cmd_ap_config_commit(dut, conn, cmd); | 
|  | 2089 | } | 
|  | 2090 |  | 
|  | 2091 |  | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2092 | static int cmd_ap_set_radius(struct sigma_dut *dut, struct sigma_conn *conn, | 
|  | 2093 | struct sigma_cmd *cmd) | 
|  | 2094 | { | 
|  | 2095 | /* const char *name = get_param(cmd, "NAME"); */ | 
|  | 2096 | const char *val; | 
|  | 2097 | unsigned int wlan_tag = 1, radius_port = 0; | 
|  | 2098 | char *radius_ipaddr = NULL, *radius_password = NULL; | 
|  | 2099 |  | 
|  | 2100 | val = get_param(cmd, "WLAN_TAG"); | 
|  | 2101 | if (val) { | 
|  | 2102 | wlan_tag = atoi(val); | 
|  | 2103 | if (wlan_tag != 1 && wlan_tag != 2) { | 
|  | 2104 | send_resp(dut, conn, SIGMA_INVALID, | 
|  | 2105 | "errorCode,Invalid WLAN_TAG"); | 
|  | 2106 | return 0; | 
|  | 2107 | } | 
|  | 2108 | } | 
|  | 2109 |  | 
|  | 2110 | val = get_param(cmd, "PORT"); | 
|  | 2111 | if (val) | 
|  | 2112 | radius_port = atoi(val); | 
|  | 2113 |  | 
|  | 2114 | if (wlan_tag == 1) { | 
|  | 2115 | if (radius_port) | 
|  | 2116 | dut->ap_radius_port = radius_port; | 
|  | 2117 | radius_ipaddr = dut->ap_radius_ipaddr; | 
|  | 2118 | radius_password = dut->ap_radius_password; | 
|  | 2119 | } else if (wlan_tag == 2) { | 
|  | 2120 | if (radius_port) | 
|  | 2121 | dut->ap2_radius_port = radius_port; | 
|  | 2122 | radius_ipaddr = dut->ap2_radius_ipaddr; | 
|  | 2123 | radius_password = dut->ap2_radius_password; | 
|  | 2124 | } | 
|  | 2125 |  | 
|  | 2126 | val = get_param(cmd, "IPADDR"); | 
|  | 2127 | if (val) { | 
|  | 2128 | if (strlen(val) > sizeof(dut->ap_radius_ipaddr) - 1) | 
|  | 2129 | return -1; | 
|  | 2130 | snprintf(radius_ipaddr, sizeof(dut->ap_radius_ipaddr), | 
|  | 2131 | "%s", val); | 
|  | 2132 | } | 
|  | 2133 |  | 
|  | 2134 | val = get_param(cmd, "PASSWORD"); | 
|  | 2135 | if (val) { | 
|  | 2136 | if (strlen(val) > sizeof(dut->ap_radius_password) - 1) | 
|  | 2137 | return -1; | 
|  | 2138 | snprintf(radius_password, | 
|  | 2139 | sizeof(dut->ap_radius_password), "%s", val); | 
|  | 2140 | } | 
|  | 2141 |  | 
|  | 2142 | return 1; | 
|  | 2143 | } | 
|  | 2144 |  | 
|  | 2145 |  | 
|  | 2146 | static void owrt_ap_set_radio(struct sigma_dut *dut, int id, | 
|  | 2147 | const char *key, const char *val) | 
|  | 2148 | { | 
|  | 2149 | char buf[100]; | 
|  | 2150 |  | 
|  | 2151 | if (val == NULL) { | 
|  | 2152 | snprintf(buf, sizeof(buf), | 
|  | 2153 | "uci delete wireless.wifi%d.%s", id, key); | 
|  | 2154 | run_system(dut, buf); | 
|  | 2155 | return; | 
|  | 2156 | } | 
|  | 2157 |  | 
|  | 2158 | snprintf(buf, sizeof(buf), "uci set wireless.wifi%d.%s=%s", | 
|  | 2159 | id, key, val); | 
|  | 2160 | run_system(dut, buf); | 
|  | 2161 | } | 
|  | 2162 |  | 
|  | 2163 |  | 
|  | 2164 | static void owrt_ap_set_list_radio(struct sigma_dut *dut, int id, | 
|  | 2165 | const char *key, const char *val) | 
|  | 2166 | { | 
|  | 2167 | char buf[256]; | 
|  | 2168 |  | 
|  | 2169 | if (val == NULL) { | 
|  | 2170 | snprintf(buf, sizeof(buf), | 
|  | 2171 | "uci del_list wireless.wifi%d.%s", id, key); | 
|  | 2172 | run_system(dut, buf); | 
|  | 2173 | return; | 
|  | 2174 | } | 
|  | 2175 |  | 
|  | 2176 | snprintf(buf, sizeof(buf), "uci add_list wireless.wifi%d.%s=%s", | 
|  | 2177 | id, key, val); | 
|  | 2178 | run_system(dut, buf); | 
|  | 2179 | } | 
|  | 2180 |  | 
|  | 2181 |  | 
|  | 2182 | static void owrt_ap_set_vap(struct sigma_dut *dut, int id, const char *key, | 
|  | 2183 | const char *val) | 
|  | 2184 | { | 
|  | 2185 | char buf[256]; | 
|  | 2186 |  | 
|  | 2187 | if (val == NULL) { | 
|  | 2188 | snprintf(buf, sizeof(buf), | 
|  | 2189 | "uci delete wireless.@wifi-iface[%d].%s", id, key); | 
|  | 2190 | run_system(dut, buf); | 
|  | 2191 | return; | 
|  | 2192 | } | 
|  | 2193 |  | 
|  | 2194 | snprintf(buf, sizeof(buf), "uci set wireless.@wifi-iface[%d].%s=%s", | 
|  | 2195 | id, key, val); | 
|  | 2196 | run_system(dut, buf); | 
|  | 2197 | } | 
|  | 2198 |  | 
|  | 2199 |  | 
|  | 2200 | static void owrt_ap_set_list_vap(struct sigma_dut *dut, int id, | 
|  | 2201 | const char *key, const char *val) | 
|  | 2202 | { | 
| priyadharshini gowthaman | 2323d0a | 2016-09-02 15:48:02 -0700 | [diff] [blame] | 2203 | char buf[1024]; | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2204 |  | 
|  | 2205 | if (val == NULL) { | 
|  | 2206 | snprintf(buf, sizeof(buf), | 
|  | 2207 | "uci del_list wireless.@wifi-iface[%d].%s", id, key); | 
|  | 2208 | run_system(dut, buf); | 
|  | 2209 | return; | 
|  | 2210 | } | 
|  | 2211 |  | 
|  | 2212 | snprintf(buf, sizeof(buf), | 
|  | 2213 | "uci add_list wireless.@wifi-iface[%d].%s=%s", | 
|  | 2214 | id, key, val); | 
|  | 2215 | run_system(dut, buf); | 
|  | 2216 | } | 
|  | 2217 |  | 
|  | 2218 |  | 
|  | 2219 | static void owrt_ap_add_vap(struct sigma_dut *dut, int id, const char *key, | 
|  | 2220 | const char *val) | 
|  | 2221 | { | 
|  | 2222 | char buf[256]; | 
|  | 2223 |  | 
|  | 2224 | if (val == NULL) { | 
|  | 2225 | snprintf(buf, sizeof(buf), | 
|  | 2226 | "uci delete wireless.@wifi-iface[%d].%s", id, key); | 
|  | 2227 | run_system(dut, buf); | 
|  | 2228 | return; | 
|  | 2229 | } | 
|  | 2230 |  | 
|  | 2231 | snprintf(buf, sizeof(buf), "uci add wireless wifi-iface"); | 
|  | 2232 | run_system(dut, buf); | 
|  | 2233 | snprintf(buf, sizeof(buf), "uci set wireless.@wifi-iface[%d].%s=%s", | 
|  | 2234 | id, key, val); | 
|  | 2235 | run_system(dut, buf); | 
|  | 2236 | snprintf(buf, sizeof(buf), "uci set wireless.@wifi-iface[%d].%s=%s", | 
|  | 2237 | id, "network", "lan"); | 
|  | 2238 | run_system(dut, buf); | 
|  | 2239 | snprintf(buf, sizeof(buf), "uci set wireless.@wifi-iface[%d].%s=%s", | 
|  | 2240 | id, "mode", "ap"); | 
|  | 2241 | run_system(dut, buf); | 
|  | 2242 | snprintf(buf, sizeof(buf), "uci set wireless.@wifi-iface[%d].%s=%s", | 
|  | 2243 | id, "encryption", "none"); | 
|  | 2244 | run_system(dut, buf); | 
|  | 2245 | } | 
|  | 2246 |  | 
|  | 2247 |  | 
| Alejandro Vasquez | 363f558 | 2018-07-17 11:25:05 -0700 | [diff] [blame] | 2248 | #define OPENWRT_MAX_NUM_RADIOS (MAX_RADIO + 1) | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2249 | static void owrt_ap_config_radio(struct sigma_dut *dut) | 
|  | 2250 | { | 
| Alejandro Vasquez | 363f558 | 2018-07-17 11:25:05 -0700 | [diff] [blame] | 2251 | int radio_id[MAX_RADIO] = { 0, 1, 2 }; | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2252 | int radio_count, radio_no; | 
|  | 2253 | char buf[64]; | 
|  | 2254 |  | 
|  | 2255 | for (radio_count = 0; radio_count < OPENWRT_MAX_NUM_RADIOS; | 
|  | 2256 | radio_count++) { | 
|  | 2257 | snprintf(buf, sizeof(buf), "%s%d", "wifi", radio_count); | 
|  | 2258 | for (radio_no = 0; radio_no < MAX_RADIO; radio_no++) { | 
|  | 2259 | if (!sigma_radio_ifname[radio_no] || | 
|  | 2260 | strcmp(sigma_radio_ifname[radio_no], buf) != 0) | 
|  | 2261 | continue; | 
|  | 2262 | owrt_ap_set_radio(dut, radio_count, "disabled", "0"); | 
|  | 2263 | owrt_ap_set_vap(dut, radio_count, "device", buf); | 
|  | 2264 | radio_id[radio_no] = radio_count; | 
|  | 2265 | } | 
|  | 2266 | } | 
|  | 2267 |  | 
|  | 2268 | /* Hardware mode (11a/b/g/n/ac) & HT mode selection */ | 
|  | 2269 | switch (dut->ap_mode) { | 
|  | 2270 | case AP_11g: | 
|  | 2271 | owrt_ap_set_radio(dut, radio_id[0], "hwmode", "11g"); | 
|  | 2272 | break; | 
|  | 2273 | case AP_11b: | 
|  | 2274 | owrt_ap_set_radio(dut, radio_id[0], "hwmode", "11b"); | 
|  | 2275 | break; | 
|  | 2276 | case AP_11ng: | 
|  | 2277 | owrt_ap_set_radio(dut, radio_id[0], "hwmode", "11ng"); | 
|  | 2278 | owrt_ap_set_radio(dut, radio_id[0], "htmode", "HT20"); | 
|  | 2279 | break; | 
|  | 2280 | case AP_11a: | 
|  | 2281 | owrt_ap_set_radio(dut, radio_id[0], "hwmode", "11a"); | 
|  | 2282 | break; | 
|  | 2283 | case AP_11na: | 
|  | 2284 | owrt_ap_set_radio(dut, radio_id[0], "hwmode", "11na"); | 
|  | 2285 | owrt_ap_set_radio(dut, radio_id[0], "htmode", "HT20"); | 
|  | 2286 | break; | 
|  | 2287 | case AP_11ac: | 
|  | 2288 | owrt_ap_set_radio(dut, radio_id[0], "hwmode", "11ac"); | 
|  | 2289 | owrt_ap_set_radio(dut, radio_id[0], "htmode", "HT80"); | 
|  | 2290 | break; | 
|  | 2291 | case AP_inval: | 
|  | 2292 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 2293 | "MODE NOT SPECIFIED!"); | 
|  | 2294 | return; | 
|  | 2295 | default: | 
|  | 2296 | owrt_ap_set_radio(dut, radio_id[0], "hwmode", "11ng"); | 
|  | 2297 | owrt_ap_set_radio(dut, radio_id[0], "htmode", "HT20"); | 
|  | 2298 | break; | 
|  | 2299 | } | 
|  | 2300 |  | 
|  | 2301 | if (dut->ap_is_dual) { | 
|  | 2302 | /* Hardware mode (11a/b/g/n/ac) & HT mode selection */ | 
|  | 2303 | switch (dut->ap_mode_1) { | 
|  | 2304 | case AP_11g: | 
|  | 2305 | owrt_ap_set_radio(dut, radio_id[1], "hwmode", "11g"); | 
|  | 2306 | break; | 
|  | 2307 | case AP_11b: | 
|  | 2308 | owrt_ap_set_radio(dut, radio_id[1], "hwmode", "11b"); | 
|  | 2309 | break; | 
|  | 2310 | case AP_11ng: | 
|  | 2311 | owrt_ap_set_radio(dut, radio_id[1], "hwmode", "11ng"); | 
|  | 2312 | owrt_ap_set_radio(dut, radio_id[1], "htmode", "HT20"); | 
|  | 2313 | break; | 
|  | 2314 | case AP_11a: | 
|  | 2315 | owrt_ap_set_radio(dut, radio_id[1], "hwmode", "11a"); | 
|  | 2316 | break; | 
|  | 2317 | case AP_11na: | 
|  | 2318 | owrt_ap_set_radio(dut, radio_id[1], "hwmode", "11na"); | 
|  | 2319 | owrt_ap_set_radio(dut, radio_id[1], "htmode", "HT20"); | 
|  | 2320 | break; | 
|  | 2321 | case AP_11ac: | 
|  | 2322 | owrt_ap_set_radio(dut, radio_id[1], "hwmode", "11ac"); | 
|  | 2323 | owrt_ap_set_radio(dut, radio_id[1], "htmode", "HT80"); | 
|  | 2324 | break; | 
|  | 2325 | case AP_inval: | 
|  | 2326 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 2327 | "MODE NOT SPECIFIED!"); | 
|  | 2328 | return; | 
|  | 2329 | default: | 
|  | 2330 | owrt_ap_set_radio(dut, radio_id[1], "hwmode", "11ng"); | 
|  | 2331 | owrt_ap_set_radio(dut, radio_id[1], "htmode", "HT20"); | 
|  | 2332 | break; | 
|  | 2333 | } | 
|  | 2334 |  | 
|  | 2335 | } | 
|  | 2336 |  | 
|  | 2337 | /* Channel */ | 
|  | 2338 | snprintf(buf, sizeof(buf), "%d", dut->ap_channel); | 
|  | 2339 | owrt_ap_set_radio(dut, radio_id[0], "channel", buf); | 
|  | 2340 |  | 
|  | 2341 | switch (dut->ap_chwidth) { | 
|  | 2342 | case AP_20: | 
|  | 2343 | owrt_ap_set_radio(dut, radio_id[0], "htmode", "HT20"); | 
|  | 2344 | break; | 
|  | 2345 | case AP_40: | 
|  | 2346 | owrt_ap_set_radio(dut, radio_id[0], "htmode", "HT40"); | 
|  | 2347 | break; | 
|  | 2348 | case AP_80: | 
|  | 2349 | owrt_ap_set_radio(dut, radio_id[0], "htmode", "HT80"); | 
|  | 2350 | break; | 
|  | 2351 | case AP_160: | 
|  | 2352 | owrt_ap_set_radio(dut, radio_id[0], "htmode", "HT160"); | 
|  | 2353 | break; | 
| priyadharshini gowthaman | 63ab848 | 2017-12-28 15:32:55 -0800 | [diff] [blame] | 2354 | case AP_80_80: | 
|  | 2355 | owrt_ap_set_radio(dut, radio_id[0], "htmode", "HT80_80"); | 
|  | 2356 | break; | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2357 | case AP_AUTO: | 
|  | 2358 | default: | 
|  | 2359 | break; | 
|  | 2360 | } | 
|  | 2361 |  | 
|  | 2362 | if (dut->ap_channel == 140 || dut->ap_channel == 144) { | 
|  | 2363 | if (get_openwrt_driver_type() == OPENWRT_DRIVER_ATHEROS) | 
|  | 2364 | owrt_ap_set_radio(dut, radio_id[0], "set_ch_144", "3"); | 
|  | 2365 | } | 
|  | 2366 |  | 
|  | 2367 | if (dut->ap_is_dual) { | 
|  | 2368 | snprintf(buf, sizeof(buf), "%d", dut->ap_channel_1); | 
|  | 2369 | owrt_ap_set_radio(dut, radio_id[1], "channel", buf); | 
|  | 2370 | } | 
|  | 2371 |  | 
| Adil Saeed Musthafa | 604c826 | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 2372 | /* Country Code */ | 
|  | 2373 | if (dut->ap_reg_domain == REG_DOMAIN_GLOBAL) { | 
|  | 2374 | const char *country; | 
|  | 2375 |  | 
|  | 2376 | country = dut->ap_countrycode[0] ? dut->ap_countrycode : "US"; | 
|  | 2377 | snprintf(buf, sizeof(buf), "%s4", country); | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2378 | owrt_ap_set_radio(dut, radio_id[0], "country", buf); | 
| priyadharshini gowthaman | 27406b0 | 2017-12-28 15:35:45 -0800 | [diff] [blame] | 2379 | if (dut->ap_is_dual) | 
|  | 2380 | owrt_ap_set_radio(dut, radio_id[1], "country", buf); | 
| Adil Saeed Musthafa | 604c826 | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 2381 | } else if (dut->ap_countrycode[0]) { | 
|  | 2382 | owrt_ap_set_radio(dut, radio_id[0], "country", | 
|  | 2383 | dut->ap_countrycode); | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2384 | } | 
|  | 2385 |  | 
|  | 2386 | if (dut->ap_disable_protection == 1) { | 
|  | 2387 | owrt_ap_set_list_radio(dut, radio_id[0], "aggr_burst", "'0 0'"); | 
|  | 2388 | owrt_ap_set_list_radio(dut, radio_id[0], "aggr_burst", "'1 0'"); | 
|  | 2389 | owrt_ap_set_list_radio(dut, radio_id[0], "aggr_burst", "'2 0'"); | 
|  | 2390 | owrt_ap_set_list_radio(dut, radio_id[0], "aggr_burst", "'3 0'"); | 
|  | 2391 | } | 
| priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 2392 |  | 
|  | 2393 | if (dut->ap_oce == VALUE_ENABLED && | 
|  | 2394 | get_driver_type() == DRIVER_OPENWRT) | 
|  | 2395 | owrt_ap_set_radio(dut, radio_id[0], "bcnburst", "1"); | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2396 | } | 
|  | 2397 |  | 
|  | 2398 |  | 
|  | 2399 | static int owrt_ap_config_vap_hs2(struct sigma_dut *dut, int vap_id) | 
|  | 2400 | { | 
|  | 2401 | char buf[256]; | 
|  | 2402 |  | 
|  | 2403 | snprintf(buf, sizeof(buf), "%d", dut->ap_hs2); | 
|  | 2404 | owrt_ap_set_vap(dut, vap_id, "hs20", buf); | 
|  | 2405 | owrt_ap_set_vap(dut, vap_id, "qbssload", "1"); | 
|  | 2406 | owrt_ap_set_vap(dut, vap_id, "hs20_deauth_req_timeout","3"); | 
|  | 2407 |  | 
|  | 2408 | owrt_ap_set_list_vap(dut, vap_id, "hs20_oper_friendly_name", | 
|  | 2409 | "'eng:Wi-Fi Alliance'"); | 
|  | 2410 |  | 
|  | 2411 | owrt_ap_set_list_vap(dut, vap_id, "hs20_oper_friendly_name", | 
|  | 2412 | "'chi:Wi-Fi\xe8\x81\x94\xe7\x9b\x9f'"); | 
|  | 2413 |  | 
|  | 2414 | if (dut->ap_wan_metrics == 1) | 
|  | 2415 | owrt_ap_set_vap(dut, vap_id, "hs20_wan_metrics", | 
|  | 2416 | "'01:2500:384:0:0:10'"); | 
|  | 2417 | else if (dut->ap_wan_metrics == 1) | 
|  | 2418 | owrt_ap_set_vap(dut, vap_id, "hs20_wan_metrics", | 
|  | 2419 | "'01:1500:384:20:20:10'"); | 
|  | 2420 | else if (dut->ap_wan_metrics == 2) | 
|  | 2421 | owrt_ap_set_vap(dut, vap_id, "hs20_wan_metrics", | 
|  | 2422 | "'01:1500:384:20:20:10'"); | 
|  | 2423 | else if (dut->ap_wan_metrics == 3) | 
|  | 2424 | owrt_ap_set_vap(dut, vap_id, "hs20_wan_metrics", | 
|  | 2425 | "'01:2000:1000:20:20:10'"); | 
|  | 2426 | else if (dut->ap_wan_metrics == 4) | 
|  | 2427 | owrt_ap_set_vap(dut, vap_id, "hs20_wan_metrics", | 
|  | 2428 | "'01:8000:1000:20:20:10'"); | 
|  | 2429 | else if (dut->ap_wan_metrics == 5) | 
|  | 2430 | owrt_ap_set_vap(dut, vap_id, "hs20_wan_metrics", | 
|  | 2431 | "'01:9000:5000:20:20:10'"); | 
|  | 2432 |  | 
|  | 2433 | if (dut->ap_conn_capab == 1) { | 
|  | 2434 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", "'1:0:0'"); | 
|  | 2435 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", | 
|  | 2436 | "'6:20:1'"); | 
|  | 2437 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", | 
|  | 2438 | "'6:22:0'"); | 
|  | 2439 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", | 
|  | 2440 | "'6:80:1'"); | 
|  | 2441 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", | 
|  | 2442 | "'6:443:1'"); | 
|  | 2443 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", | 
|  | 2444 | "'6:1723:0'"); | 
|  | 2445 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", | 
|  | 2446 | "'6:5060:0'"); | 
|  | 2447 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", | 
|  | 2448 | "'17:500:1'"); | 
|  | 2449 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", | 
|  | 2450 | "'17:5060:0'"); | 
|  | 2451 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", | 
|  | 2452 | "'17:4500:1'"); | 
|  | 2453 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", | 
|  | 2454 | "'50:0:1'"); | 
|  | 2455 | } else if (dut->ap_conn_capab == 2) { | 
|  | 2456 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", | 
|  | 2457 | "'6:80:1'"); | 
|  | 2458 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", | 
|  | 2459 | "'6:443:1'"); | 
|  | 2460 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", | 
|  | 2461 | "'17:5060:1'"); | 
|  | 2462 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", | 
|  | 2463 | "'6:5060:1'"); | 
|  | 2464 | } else if (dut->ap_conn_capab == 3) { | 
|  | 2465 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", | 
|  | 2466 | "'6:80:1'"); | 
|  | 2467 | owrt_ap_set_list_vap(dut, vap_id, "hs20_conn_capab", | 
|  | 2468 | "'6:443:1'"); | 
|  | 2469 | } | 
|  | 2470 |  | 
|  | 2471 | if (dut->ap_oper_class == 1) | 
|  | 2472 | snprintf(buf, sizeof(buf), "%s", "51"); | 
|  | 2473 | else if (dut->ap_oper_class == 2) | 
|  | 2474 | snprintf(buf, sizeof(buf), "%s", "73"); | 
|  | 2475 | else if (dut->ap_oper_class == 3) | 
|  | 2476 | snprintf(buf, sizeof(buf), "%s", "5173"); | 
|  | 2477 |  | 
|  | 2478 | if (dut->ap_oper_class) | 
|  | 2479 | owrt_ap_set_vap(dut, vap_id, "hs20_operating_class", buf); | 
|  | 2480 |  | 
|  | 2481 | if (dut->ap_osu_provider_list) { | 
|  | 2482 | char *osu_friendly_name = NULL; | 
|  | 2483 | char *osu_icon = NULL; | 
|  | 2484 | char *osu_ssid = NULL; | 
|  | 2485 | char *osu_nai = NULL; | 
|  | 2486 | char *osu_service_desc = NULL; | 
|  | 2487 | char *hs20_icon_filename = NULL; | 
|  | 2488 | char hs20_icon[150]; | 
|  | 2489 | int osu_method; | 
|  | 2490 |  | 
|  | 2491 | hs20_icon_filename = "icon_red_zxx.png"; | 
|  | 2492 | if (dut->ap_osu_icon_tag == 2) | 
|  | 2493 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; | 
|  | 2494 | snprintf(hs20_icon, sizeof(hs20_icon), | 
|  | 2495 | "'128:61:zxx:image/png:icon_red_zxx.png:/etc/ath/%s'", | 
|  | 2496 | hs20_icon_filename); | 
|  | 2497 | osu_icon = "icon_red_zxx.png"; | 
|  | 2498 | osu_ssid = "OSU"; | 
|  | 2499 | osu_friendly_name = "'kor:SP 빨강 테스트 전용'"; | 
|  | 2500 | osu_service_desc = "'kor:테스트 목적으로 무료 서비스'"; | 
|  | 2501 | osu_method = (dut->ap_osu_method[0] == 0xFF) ? 1 : | 
|  | 2502 | dut->ap_osu_method[0]; | 
|  | 2503 |  | 
|  | 2504 | if (strlen(dut->ap_osu_server_uri[0])) | 
|  | 2505 | owrt_ap_set_list_vap(dut, vap_id, "osu_server_uri", | 
|  | 2506 | dut->ap_osu_server_uri[0]); | 
|  | 2507 | else | 
|  | 2508 | owrt_ap_set_list_vap(dut, vap_id, "osu_server_uri", | 
|  | 2509 | "'https://osu-server.r2-testbed.wi-fi.org/'"); | 
|  | 2510 | switch (dut->ap_osu_provider_list) { | 
|  | 2511 | case 1: | 
|  | 2512 | case 101: | 
|  | 2513 | owrt_ap_set_list_vap(dut, vap_id, "osu_friendly_name", | 
|  | 2514 | "'eng:SP Red Test Only'"); | 
|  | 2515 | owrt_ap_set_list_vap(dut, vap_id, "osu_service_desc", | 
|  | 2516 | "'eng:Free service for test purpose'"); | 
|  | 2517 | owrt_ap_set_list_vap(dut, vap_id, "hs20_icon", | 
|  | 2518 | hs20_icon); | 
|  | 2519 |  | 
|  | 2520 | hs20_icon_filename = "icon_red_eng.png"; | 
|  | 2521 | if (dut->ap_osu_icon_tag == 2) | 
|  | 2522 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; | 
|  | 2523 |  | 
|  | 2524 | snprintf(hs20_icon, sizeof(hs20_icon), | 
|  | 2525 | "'160:76:eng:image/png:icon_red_eng.png:/etc/ath/%s'", | 
|  | 2526 | hs20_icon_filename); | 
|  | 2527 | owrt_ap_set_list_vap(dut, vap_id, "osu_icon", | 
|  | 2528 | "icon_red_eng.png"); | 
|  | 2529 | break; | 
|  | 2530 | case 2: | 
|  | 2531 | case 102: | 
|  | 2532 | owrt_ap_set_list_vap(dut, vap_id, "osu_friendly_name", | 
|  | 2533 | "'eng:Wireless Broadband Alliance'"); | 
|  | 2534 | owrt_ap_set_list_vap(dut, vap_id, "osu_service_desc", | 
|  | 2535 | "'eng:Free service for test purpose'"); | 
| priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2536 | hs20_icon_filename = "icon_orange_zxx.png"; | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2537 | if (dut->ap_osu_icon_tag == 2) | 
|  | 2538 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; | 
|  | 2539 |  | 
|  | 2540 | snprintf(hs20_icon, sizeof(hs20_icon), | 
| priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2541 | "'128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/%s'", | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2542 | hs20_icon_filename); | 
| priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2543 | osu_icon = "icon_orange_zxx.png"; | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2544 | osu_friendly_name = "'kor:와이어리스 브로드밴드 얼라이언스'"; | 
|  | 2545 | break; | 
|  | 2546 | case 3: | 
|  | 2547 | case 103: | 
| Jouni Malinen | 02502de | 2018-10-15 17:19:33 +0300 | [diff] [blame] | 2548 | osu_friendly_name = "'spa:SP Red Test Only'"; | 
|  | 2549 | osu_service_desc = "'spa:Free service for test purpose'"; | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2550 | break; | 
|  | 2551 | case 4: | 
|  | 2552 | case 104: | 
|  | 2553 | owrt_ap_set_list_vap(dut, vap_id, "osu_friendly_name", | 
| priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2554 | "'eng:SP Orange Test Only'"); | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2555 | owrt_ap_set_list_vap(dut, vap_id, "osu_service_desc", | 
|  | 2556 | "'eng:Free service for test purpose'"); | 
| priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2557 | hs20_icon_filename = "icon_orange_eng.png"; | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2558 | if (dut->ap_osu_icon_tag == 2) | 
|  | 2559 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; | 
|  | 2560 |  | 
|  | 2561 | snprintf(hs20_icon, sizeof(hs20_icon), | 
| priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2562 | "'160:76:eng:image/png:icon_orange_eng.png:/etc/ath/%s'", | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2563 | hs20_icon_filename); | 
|  | 2564 | owrt_ap_set_list_vap(dut, vap_id, "hs20_icon", | 
|  | 2565 | hs20_icon); | 
| Jouni Malinen | fd45ad5 | 2018-10-15 17:06:18 +0300 | [diff] [blame] | 2566 | osu_friendly_name = "'kor:SP 오렌지 테스트 전용'"; | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2567 |  | 
| priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2568 | hs20_icon_filename = "icon_orange_zxx.png"; | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2569 | if (dut->ap_osu_icon_tag == 2) | 
|  | 2570 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; | 
|  | 2571 |  | 
|  | 2572 | snprintf(hs20_icon, sizeof(hs20_icon), | 
| priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2573 | "'128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/%s'", | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2574 | hs20_icon_filename); | 
| priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2575 | osu_icon = "icon_orange_zxx.png"; | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2576 | break; | 
|  | 2577 | case 5: | 
|  | 2578 | case 105: | 
|  | 2579 | owrt_ap_set_list_vap(dut, vap_id, "osu_friendly_name", | 
| priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2580 | "'eng:SP Orange Test Only'"); | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2581 | owrt_ap_set_list_vap(dut, vap_id, "osu_service_desc", | 
|  | 2582 | "'eng:Free service for test purpose'"); | 
| Jouni Malinen | fd45ad5 | 2018-10-15 17:06:18 +0300 | [diff] [blame] | 2583 | osu_friendly_name = "'kor:SP 오렌지 테스트 전용'"; | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2584 |  | 
| priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2585 | hs20_icon_filename = "icon_orange_zxx.png"; | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2586 | if (dut->ap_osu_icon_tag == 2) | 
|  | 2587 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; | 
|  | 2588 |  | 
|  | 2589 | snprintf(hs20_icon, sizeof(hs20_icon), | 
| priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2590 | "'128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/%s'", | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2591 | hs20_icon_filename); | 
| priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2592 | osu_icon = "icon_orange_zxx.png"; | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2593 | break; | 
|  | 2594 | case 6: | 
|  | 2595 | case 106: | 
|  | 2596 | owrt_ap_set_list_vap(dut, vap_id, "osu_friendly_name", | 
|  | 2597 | "'eng:SP Green Test Only'"); | 
|  | 2598 | owrt_ap_set_list_vap(dut, vap_id, "osu_friendly_name", | 
|  | 2599 | "'kor:SP 초록 테스트 전용'"); | 
|  | 2600 |  | 
|  | 2601 | hs20_icon_filename = "icon_green_zxx.png"; | 
|  | 2602 | if (dut->ap_osu_icon_tag == 2) | 
|  | 2603 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; | 
|  | 2604 |  | 
|  | 2605 | snprintf(hs20_icon, sizeof(hs20_icon), | 
|  | 2606 | "'128:61:zxx:image/png:icon_green_zxx.png:/etc/ath/%s'", | 
|  | 2607 | hs20_icon_filename); | 
|  | 2608 | owrt_ap_set_list_vap(dut, vap_id, "hs20_icon", | 
|  | 2609 | hs20_icon); | 
|  | 2610 |  | 
|  | 2611 | owrt_ap_set_list_vap(dut, vap_id, "osu_icon", | 
|  | 2612 | "'icon_green_zxx.png'"); | 
|  | 2613 | osu_method = (dut->ap_osu_method[0] == 0xFF) ? 0 : | 
|  | 2614 | dut->ap_osu_method[0]; | 
|  | 2615 |  | 
|  | 2616 | snprintf(buf, sizeof(buf), "%d", osu_method); | 
|  | 2617 | owrt_ap_set_vap(dut, vap_id, "osu_method_list", buf); | 
|  | 2618 |  | 
|  | 2619 | if (strlen(dut->ap_osu_server_uri[1])) | 
|  | 2620 | owrt_ap_set_list_vap(dut, vap_id, | 
|  | 2621 | "osu_server_uri", | 
|  | 2622 | dut->ap_osu_server_uri[1]); | 
|  | 2623 | else | 
|  | 2624 | owrt_ap_set_list_vap(dut, vap_id, | 
|  | 2625 | "osu_server_uri", | 
|  | 2626 | "'https://osu-server.r2-testbed.wi-fi.org/'"); | 
|  | 2627 |  | 
|  | 2628 | owrt_ap_set_list_vap(dut, vap_id, "osu_friendly_name", | 
|  | 2629 | "'eng:SP Orange Test Only'"); | 
|  | 2630 |  | 
|  | 2631 | hs20_icon_filename = "icon_orange_zxx.png"; | 
|  | 2632 | if (dut->ap_osu_icon_tag == 2) | 
|  | 2633 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; | 
|  | 2634 |  | 
|  | 2635 | snprintf(hs20_icon, sizeof(hs20_icon), | 
|  | 2636 | "'128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/%s'", | 
|  | 2637 | hs20_icon_filename); | 
|  | 2638 |  | 
|  | 2639 | osu_icon = "icon_orange_zxx.png"; | 
|  | 2640 | osu_friendly_name = "'kor:SP 오렌지 테스트 전용'"; | 
|  | 2641 | osu_method = (dut->ap_osu_method[1] == 0xFF) ? 0 : | 
|  | 2642 | dut->ap_osu_method[1]; | 
|  | 2643 | osu_service_desc = NULL; | 
|  | 2644 | break; | 
|  | 2645 | case 7: | 
|  | 2646 | case 107: | 
|  | 2647 | owrt_ap_set_list_vap(dut, vap_id, "osu_friendly_name", | 
| priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2648 | "'eng:SP Green Test Only'"); | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2649 | owrt_ap_set_list_vap(dut, vap_id, "osu_service_desc", | 
|  | 2650 | "'eng:Free service for test purpose'"); | 
|  | 2651 |  | 
| priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2652 | hs20_icon_filename = "icon_green_eng.png"; | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2653 | if (dut->ap_osu_icon_tag == 2) | 
|  | 2654 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; | 
|  | 2655 |  | 
|  | 2656 | snprintf(hs20_icon, sizeof(hs20_icon), | 
| priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2657 | "'160:76:eng:image/png:icon_green_eng.png:/etc/ath/%s'", | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2658 | hs20_icon_filename); | 
|  | 2659 | owrt_ap_set_list_vap(dut, vap_id, "hs20_icon", | 
|  | 2660 | hs20_icon); | 
|  | 2661 |  | 
|  | 2662 | owrt_ap_set_list_vap(dut, vap_id, "osu_icon", | 
| priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2663 | "'icon_green_eng.png'"); | 
| Jouni Malinen | fd45ad5 | 2018-10-15 17:06:18 +0300 | [diff] [blame] | 2664 | osu_friendly_name = "'kor:SP 초록 테스트 전용'"; | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2665 |  | 
| priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2666 | hs20_icon_filename = "icon_green_zxx.png"; | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2667 | if (dut->ap_osu_icon_tag == 2) | 
|  | 2668 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; | 
|  | 2669 |  | 
|  | 2670 | snprintf(hs20_icon, sizeof(hs20_icon), | 
| priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2671 | "'128:61:zxx:image/png:icon_green_zxx.png:/etc/ath/%s'", | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2672 | hs20_icon_filename); | 
| priyadharshini gowthaman | cc0e29c | 2016-10-17 11:48:59 +0300 | [diff] [blame] | 2673 | osu_icon = "icon_green_zxx.png"; | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2674 | break; | 
|  | 2675 | case 8: | 
|  | 2676 | case 108: | 
|  | 2677 | owrt_ap_set_list_vap(dut, vap_id, "osu_friendly_name", | 
|  | 2678 | "'eng:SP Red Test Only'"); | 
|  | 2679 | owrt_ap_set_list_vap(dut, vap_id, "osu_service_desc", | 
|  | 2680 | "'eng:Free service for test purpose'"); | 
|  | 2681 | osu_ssid = "OSU-Encrypted"; | 
|  | 2682 | osu_nai = "'anonymous@hotspot.net'"; | 
|  | 2683 | break; | 
|  | 2684 | case 9: | 
|  | 2685 | case 109: | 
|  | 2686 | osu_ssid = "OSU-OSEN"; | 
|  | 2687 | osu_nai = "'test-anonymous@wi-fi.org'"; | 
|  | 2688 | osu_friendly_name = "'eng:SP Orange Test Only'"; | 
|  | 2689 | hs20_icon_filename = "icon_orange_zxx.png"; | 
|  | 2690 | if (dut->ap_osu_icon_tag == 2) | 
|  | 2691 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; | 
|  | 2692 |  | 
|  | 2693 | snprintf(hs20_icon, sizeof(hs20_icon), | 
|  | 2694 | "'128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/%s'", | 
|  | 2695 | hs20_icon_filename); | 
|  | 2696 | osu_icon = "icon_orange_zxx.png"; | 
|  | 2697 | osu_method = (dut->ap_osu_method[0] == 0xFF) ? 1 : | 
|  | 2698 | dut->ap_osu_method[0]; | 
|  | 2699 | osu_service_desc = NULL; | 
|  | 2700 | break; | 
|  | 2701 | default: | 
|  | 2702 | break; | 
|  | 2703 | } | 
|  | 2704 |  | 
|  | 2705 | if (strlen(dut->ap_osu_ssid)) { | 
| Jouni Malinen | e6ac6a0 | 2018-09-11 02:40:17 +0300 | [diff] [blame] | 2706 | if (dut->ap_tag_ssid[0][0] && | 
|  | 2707 | strcmp(dut->ap_tag_ssid[0], | 
| Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 2708 | dut->ap_osu_ssid) != 0 && | 
|  | 2709 | strcmp(dut->ap_tag_ssid[0], osu_ssid) != 0) { | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2710 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 2711 | "OSU_SSID and WLAN_TAG2 SSID differ"); | 
|  | 2712 | return -2; | 
|  | 2713 | } | 
|  | 2714 |  | 
|  | 2715 | snprintf(buf, sizeof(buf), "'\"%s\"'", | 
|  | 2716 | dut->ap_osu_ssid); | 
|  | 2717 | } else { | 
|  | 2718 | snprintf(buf, sizeof(buf), "'\"%s\"'", osu_ssid); | 
|  | 2719 | } | 
|  | 2720 |  | 
|  | 2721 | owrt_ap_set_vap(dut, vap_id, "osu_ssid", buf); | 
|  | 2722 |  | 
|  | 2723 |  | 
|  | 2724 | if (osu_friendly_name) | 
|  | 2725 | owrt_ap_set_list_vap(dut, vap_id, "osu_friendly_name", | 
|  | 2726 | osu_friendly_name); | 
|  | 2727 | if (osu_service_desc) | 
|  | 2728 | owrt_ap_set_list_vap(dut, vap_id, "osu_service_desc", | 
|  | 2729 | osu_service_desc); | 
|  | 2730 | if (osu_nai) | 
|  | 2731 | owrt_ap_set_vap(dut, vap_id, "osu_nai", osu_nai); | 
|  | 2732 |  | 
|  | 2733 | owrt_ap_set_list_vap(dut, vap_id, "hs20_icon", hs20_icon); | 
|  | 2734 |  | 
|  | 2735 | if (osu_icon) | 
|  | 2736 | owrt_ap_set_list_vap(dut, vap_id, "osu_icon", | 
|  | 2737 | osu_icon); | 
|  | 2738 |  | 
|  | 2739 | if (dut->ap_osu_provider_list > 100) { | 
|  | 2740 | owrt_ap_set_list_vap(dut, vap_id, "osu_method_list", | 
|  | 2741 | "0"); | 
|  | 2742 | } else { | 
|  | 2743 | snprintf(buf, sizeof(buf), "%d", osu_method); | 
|  | 2744 | owrt_ap_set_list_vap(dut, vap_id, "osu_method_list", | 
|  | 2745 | buf); | 
|  | 2746 | } | 
|  | 2747 | } | 
|  | 2748 |  | 
|  | 2749 | return 0; | 
|  | 2750 | } | 
|  | 2751 |  | 
|  | 2752 |  | 
| Adil Saeed Musthafa | a8d7484 | 2017-04-10 23:13:39 -0700 | [diff] [blame] | 2753 | static void set_anqp_elem_value(struct sigma_dut *dut, const char *ifname, | 
|  | 2754 | char *anqp_string, size_t str_size) | 
|  | 2755 | { | 
|  | 2756 | unsigned char bssid[ETH_ALEN]; | 
|  | 2757 | unsigned char dummy_mac[] = { 0x00, 0x10, 0x20, 0x30, 0x40, 0x50 }; | 
|  | 2758 | int preference = 0xff; | 
|  | 2759 |  | 
|  | 2760 | get_hwaddr(ifname, bssid); | 
|  | 2761 | snprintf(anqp_string, str_size, | 
|  | 2762 | "272:3410%02x%02x%02x%02x%02x%02xf70000007330000301%02x3410%02x%02x%02x%02x%02x%02xf70000007330000301%02x", | 
|  | 2763 | bssid[0], bssid[1], bssid[2], bssid[3], bssid[4], bssid[5], | 
|  | 2764 | preference, | 
|  | 2765 | dummy_mac[0], dummy_mac[1], dummy_mac[2], | 
|  | 2766 | dummy_mac[3], dummy_mac[4], dummy_mac[5], | 
|  | 2767 | preference - 1); | 
|  | 2768 | } | 
|  | 2769 |  | 
|  | 2770 |  | 
| Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 2771 | static void get_if_name(struct sigma_dut *dut, char *ifname_str, | 
|  | 2772 | size_t str_size, int wlan_tag) | 
|  | 2773 | { | 
| Jouni Malinen | f898464 | 2017-10-12 00:02:37 +0300 | [diff] [blame] | 2774 | const char *ifname; | 
| Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 2775 | enum driver_type drv; | 
|  | 2776 |  | 
|  | 2777 | drv = get_driver_type(); | 
| Jouni Malinen | f898464 | 2017-10-12 00:02:37 +0300 | [diff] [blame] | 2778 | if (dut->hostapd_ifname && if_nametoindex(dut->hostapd_ifname) > 0) { | 
|  | 2779 | ifname = dut->hostapd_ifname; | 
|  | 2780 | } else if (drv == DRIVER_ATHEROS) { | 
| Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 2781 | if ((dut->ap_mode == AP_11a || dut->ap_mode == AP_11na || | 
|  | 2782 | dut->ap_mode == AP_11ac) && | 
|  | 2783 | if_nametoindex("ath1") > 0) | 
|  | 2784 | ifname = "ath1"; | 
|  | 2785 | else | 
|  | 2786 | ifname = "ath0"; | 
|  | 2787 | } else if (drv == DRIVER_OPENWRT) { | 
|  | 2788 | if (sigma_radio_ifname[0] && | 
|  | 2789 | strcmp(sigma_radio_ifname[0], "wifi2") == 0) | 
|  | 2790 | ifname = "ath2"; | 
|  | 2791 | else if (sigma_radio_ifname[0] && | 
|  | 2792 | strcmp(sigma_radio_ifname[0], "wifi1") == 0) | 
|  | 2793 | ifname = "ath1"; | 
|  | 2794 | else | 
|  | 2795 | ifname = "ath0"; | 
| Alexei Avshalom Lazar | 2712cc8 | 2018-12-23 16:29:14 +0200 | [diff] [blame] | 2796 | } else if (drv == DRIVER_WIL6210) { | 
|  | 2797 | ifname = get_main_ifname(); | 
| Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 2798 | } else { | 
|  | 2799 | if ((dut->ap_mode == AP_11a || dut->ap_mode == AP_11na || | 
|  | 2800 | dut->ap_mode == AP_11ac) && | 
|  | 2801 | if_nametoindex("wlan1") > 0) | 
|  | 2802 | ifname = "wlan1"; | 
|  | 2803 | else | 
|  | 2804 | ifname = "wlan0"; | 
|  | 2805 | } | 
|  | 2806 |  | 
|  | 2807 | if (drv == DRIVER_OPENWRT && wlan_tag > 1) { | 
|  | 2808 | /* Handle tagged-ifname only on OPENWRT for now */ | 
|  | 2809 | snprintf(ifname_str, str_size, "%s%d", ifname, wlan_tag - 1); | 
| Liangwei Dong | 8357289 | 2019-01-10 13:51:48 +0800 | [diff] [blame] | 2810 | } else if ((drv == DRIVER_MAC80211 || drv == DRIVER_LINUX_WCN) && | 
|  | 2811 | wlan_tag == 2) { | 
| Jouni Malinen | f898464 | 2017-10-12 00:02:37 +0300 | [diff] [blame] | 2812 | snprintf(ifname_str, str_size, "%s_1", ifname); | 
| Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 2813 | } else { | 
|  | 2814 | snprintf(ifname_str, str_size, "%s", ifname); | 
|  | 2815 | } | 
|  | 2816 | } | 
|  | 2817 |  | 
|  | 2818 |  | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2819 | static int owrt_ap_config_vap(struct sigma_dut *dut) | 
|  | 2820 | { | 
|  | 2821 | char buf[256], *temp; | 
| Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 2822 | int vap_id = 0, vap_count, i, j; | 
| priyadharshini gowthaman | 0454706 | 2018-01-15 11:59:55 -0800 | [diff] [blame] | 2823 | const char *ifname; | 
|  | 2824 | char ifname2[50]; | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2825 |  | 
| priyadharshini gowthaman | 7356126 | 2018-02-20 13:24:59 -0800 | [diff] [blame] | 2826 | if (sigma_radio_ifname[0] && | 
|  | 2827 | strcmp(sigma_radio_ifname[0], "wifi2") == 0) | 
|  | 2828 | ifname = "ath2"; | 
|  | 2829 | else if (sigma_radio_ifname[0] && | 
|  | 2830 | strcmp(sigma_radio_ifname[0], "wifi1") == 0) | 
|  | 2831 | ifname = "ath1"; | 
|  | 2832 | else | 
|  | 2833 | ifname = "ath0"; | 
|  | 2834 |  | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2835 | for (vap_count = 0; vap_count < OPENWRT_MAX_NUM_RADIOS; vap_count++) { | 
| Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 2836 | snprintf(buf, sizeof(buf), "wifi%d", vap_count); | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2837 |  | 
|  | 2838 | for (vap_id = 0; vap_id < MAX_RADIO; vap_id++) { | 
|  | 2839 | if (sigma_radio_ifname[vap_id] && | 
|  | 2840 | strcmp(sigma_radio_ifname[vap_id], buf) == 0) | 
|  | 2841 | break; | 
|  | 2842 | } | 
|  | 2843 | if (vap_id == MAX_RADIO) | 
|  | 2844 | continue; | 
|  | 2845 |  | 
|  | 2846 | /* Single VAP configuration */ | 
|  | 2847 | if (!dut->ap_is_dual) | 
|  | 2848 | vap_id = vap_count; | 
|  | 2849 |  | 
| Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 2850 | for (j = 0; j < MAX_WLAN_TAGS - 1; j++) { | 
|  | 2851 | /* | 
|  | 2852 | * We keep a separate array of ap_tag_ssid and | 
|  | 2853 | * ap_tag_key_mgmt for tags starting from WLAN_TAG=2. | 
|  | 2854 | * So j=0 => WLAN_TAG = 2 | 
|  | 2855 | */ | 
|  | 2856 | int wlan_tag = j + 2; | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2857 |  | 
| priyadharshini gowthaman | 0e209fc | 2018-01-26 15:15:37 -0800 | [diff] [blame] | 2858 | if (wlan_tag == 2 && dut->program == PROGRAM_WPA3 && | 
|  | 2859 | (dut->ap_interface_5g || dut->ap_interface_2g)) { | 
|  | 2860 | snprintf(dut->ap_tag_ssid[wlan_tag - 2], | 
|  | 2861 | sizeof(dut->ap_tag_ssid[wlan_tag - 2]), | 
|  | 2862 | "%s-owe", dut->ap_ssid); | 
|  | 2863 | } | 
|  | 2864 |  | 
| Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 2865 | if (dut->ap_tag_ssid[j][0] == '\0') | 
|  | 2866 | continue; | 
|  | 2867 |  | 
|  | 2868 | snprintf(buf, sizeof(buf), "%s%d", "wifi", vap_count); | 
|  | 2869 | owrt_ap_add_vap(dut, vap_count + (wlan_tag - 1), | 
|  | 2870 | "device", buf); | 
|  | 2871 | /* SSID */ | 
|  | 2872 | snprintf(buf, sizeof(buf), "\"%s\"", | 
|  | 2873 | dut->ap_tag_ssid[j]); | 
|  | 2874 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), | 
|  | 2875 | "ssid", buf); | 
|  | 2876 |  | 
| priyadharshini gowthaman | 0454706 | 2018-01-15 11:59:55 -0800 | [diff] [blame] | 2877 | if (dut->ap_key_mgmt == AP_WPA2_OWE && | 
|  | 2878 | dut->ap_tag_ssid[0][0] && | 
|  | 2879 | dut->ap_tag_key_mgmt[0] == AP2_OPEN) { | 
|  | 2880 | /* OWE transition mode */ | 
|  | 2881 | snprintf(buf, sizeof(buf), "%s", ifname); | 
|  | 2882 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), | 
|  | 2883 | "owe_transition_ifname", buf); | 
|  | 2884 | } | 
|  | 2885 |  | 
|  | 2886 | if (dut->ap_key_mgmt == AP_OPEN && | 
|  | 2887 | dut->ap_tag_key_mgmt[0] == AP2_WPA2_OWE) { | 
|  | 2888 | /* OWE transition mode */ | 
|  | 2889 | snprintf(buf, sizeof(buf), "%s", ifname); | 
|  | 2890 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), | 
|  | 2891 | "owe_transition_ifname", buf); | 
|  | 2892 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), | 
|  | 2893 | "hidden", "1"); | 
|  | 2894 | } | 
|  | 2895 |  | 
| Jouni Malinen | 6be21c8 | 2018-08-01 18:47:24 +0300 | [diff] [blame] | 2896 | if (ap_ft_enabled(dut)) { | 
| priyadharshini gowthaman | 47189f5 | 2017-12-28 12:37:46 -0800 | [diff] [blame] | 2897 | unsigned char self_mac[ETH_ALEN]; | 
|  | 2898 | char mac_str[20]; | 
|  | 2899 |  | 
|  | 2900 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), | 
|  | 2901 | "mobility_domain", | 
|  | 2902 | dut->ap_mobility_domain); | 
|  | 2903 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), | 
|  | 2904 | "ft_over_ds", "0"); | 
|  | 2905 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), | 
|  | 2906 | "ieee80211r", "1"); | 
|  | 2907 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), | 
|  | 2908 | "nasid", "nas1.example.com"); | 
|  | 2909 | get_hwaddr(sigma_radio_ifname[0], self_mac); | 
|  | 2910 | snprintf(mac_str, sizeof(mac_str), | 
|  | 2911 | "%02x:%02x:%02x:%02x:%02x:%02x", | 
|  | 2912 | self_mac[0], self_mac[1], self_mac[2], | 
|  | 2913 | self_mac[3], self_mac[4], self_mac[5]); | 
|  | 2914 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), | 
|  | 2915 | "ap_macaddr", mac_str); | 
|  | 2916 | snprintf(mac_str, sizeof(mac_str), | 
|  | 2917 | "%02x%02x%02x%02x%02x%02x", | 
|  | 2918 | self_mac[0], self_mac[1], self_mac[2], | 
|  | 2919 | self_mac[3], self_mac[4], self_mac[5]); | 
|  | 2920 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), | 
|  | 2921 | "r1_key_holder", mac_str); | 
|  | 2922 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), | 
|  | 2923 | "ft_psk_generate_local", "1"); | 
|  | 2924 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), | 
|  | 2925 | "kh_key_hex", | 
|  | 2926 | "000102030405060708090a0b0c0d0e0f"); | 
|  | 2927 | snprintf(mac_str, sizeof(mac_str), | 
|  | 2928 | "%02x:%02x:%02x:%02x:%02x:%02x", | 
|  | 2929 | dut->ft_bss_mac_list[0][0], | 
|  | 2930 | dut->ft_bss_mac_list[0][1], | 
|  | 2931 | dut->ft_bss_mac_list[0][2], | 
|  | 2932 | dut->ft_bss_mac_list[0][3], | 
|  | 2933 | dut->ft_bss_mac_list[0][4], | 
|  | 2934 | dut->ft_bss_mac_list[0][5]); | 
|  | 2935 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), | 
|  | 2936 | "ap2_macaddr", mac_str); | 
|  | 2937 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), | 
|  | 2938 | "ap2_r1_key_holder", mac_str); | 
|  | 2939 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), | 
|  | 2940 | "nasid2", "nas2.example.com"); | 
|  | 2941 | } | 
|  | 2942 |  | 
| Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 2943 | if (dut->ap_tag_key_mgmt[j] == AP2_OSEN && | 
|  | 2944 | wlan_tag == 2) { | 
|  | 2945 | /* Only supported for WLAN_TAG=2 */ | 
|  | 2946 | owrt_ap_set_vap(dut, vap_count + 1, "osen", | 
|  | 2947 | "1"); | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2948 | snprintf(buf, sizeof(buf), "wpa2"); | 
|  | 2949 | owrt_ap_set_vap(dut, vap_count + 1, | 
|  | 2950 | "encryption", buf); | 
|  | 2951 | snprintf(buf, sizeof(buf), "%s", | 
|  | 2952 | dut->ap2_radius_ipaddr); | 
|  | 2953 | owrt_ap_set_vap(dut, vap_count + 1, | 
|  | 2954 | "auth_server", buf); | 
|  | 2955 | snprintf(buf, sizeof(buf), "%d", | 
|  | 2956 | dut->ap2_radius_port); | 
|  | 2957 | owrt_ap_set_vap(dut, vap_count + 1, | 
|  | 2958 | "auth_port", buf); | 
|  | 2959 | snprintf(buf, sizeof(buf), "%s", | 
| Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 2960 | dut->ap2_radius_password); | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2961 | owrt_ap_set_vap(dut, vap_count + 1, | 
|  | 2962 | "auth_secret", buf); | 
| Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 2963 | } else if (dut->ap_tag_key_mgmt[j] == AP2_WPA2_PSK) { | 
|  | 2964 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), | 
|  | 2965 | "encryption", "psk2+ccmp"); | 
|  | 2966 | snprintf(buf, sizeof(buf), "\"%s\"", | 
|  | 2967 | dut->ap_passphrase); | 
|  | 2968 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), | 
|  | 2969 | "key", buf); | 
|  | 2970 | snprintf(buf, sizeof(buf), "%d", dut->ap_pmf); | 
| priyadharshini gowthaman | 47189f5 | 2017-12-28 12:37:46 -0800 | [diff] [blame] | 2971 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), | 
| Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 2972 | "ieee80211w", buf); | 
| priyadharshini gowthaman | 0454706 | 2018-01-15 11:59:55 -0800 | [diff] [blame] | 2973 | } else if (dut->ap_tag_key_mgmt[0] == AP2_WPA2_OWE) { | 
|  | 2974 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), | 
|  | 2975 | "owe", "1"); | 
|  | 2976 | snprintf(buf, sizeof(buf), "ccmp"); | 
|  | 2977 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), | 
|  | 2978 | "encryption", buf); | 
|  | 2979 | owrt_ap_set_vap(dut, vap_count + (wlan_tag - 1), | 
|  | 2980 | "ieee80211w", "2"); | 
|  | 2981 | if (dut->ap_sae_groups) { | 
|  | 2982 | snprintf(buf, sizeof(buf), "\'%s\'", | 
|  | 2983 | dut->ap_sae_groups); | 
| priyadharshini gowthaman | b59bfe4 | 2018-08-30 15:14:08 -0700 | [diff] [blame] | 2984 | owrt_ap_set_list_vap(dut, vap_count + | 
|  | 2985 | (wlan_tag - 1), | 
|  | 2986 | "owe_groups", buf); | 
| priyadharshini gowthaman | 0454706 | 2018-01-15 11:59:55 -0800 | [diff] [blame] | 2987 | } | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 2988 | } | 
|  | 2989 | } | 
|  | 2990 |  | 
| priyadharshini gowthaman | 47189f5 | 2017-12-28 12:37:46 -0800 | [diff] [blame] | 2991 | /* Now set anqp_elem and ft_oa for wlan_tag = 1 */ | 
| Adil Saeed Musthafa | a8d7484 | 2017-04-10 23:13:39 -0700 | [diff] [blame] | 2992 | if (dut->program == PROGRAM_MBO && | 
|  | 2993 | get_driver_type() == DRIVER_OPENWRT) { | 
| priyadharshini gowthaman | 47189f5 | 2017-12-28 12:37:46 -0800 | [diff] [blame] | 2994 | unsigned char self_mac[ETH_ALEN]; | 
|  | 2995 | char mac_str[20]; | 
| Adil Saeed Musthafa | a8d7484 | 2017-04-10 23:13:39 -0700 | [diff] [blame] | 2996 | char anqp_string[200]; | 
|  | 2997 |  | 
|  | 2998 | set_anqp_elem_value(dut, sigma_radio_ifname[0], | 
|  | 2999 | anqp_string, sizeof(anqp_string)); | 
|  | 3000 | owrt_ap_set_list_vap(dut, vap_count, "anqp_elem", | 
|  | 3001 | anqp_string); | 
| priyadharshini gowthaman | 47189f5 | 2017-12-28 12:37:46 -0800 | [diff] [blame] | 3002 |  | 
| Jouni Malinen | 6be21c8 | 2018-08-01 18:47:24 +0300 | [diff] [blame] | 3003 | if (ap_ft_enabled(dut)) { | 
| priyadharshini gowthaman | 47189f5 | 2017-12-28 12:37:46 -0800 | [diff] [blame] | 3004 | owrt_ap_set_vap(dut, vap_count, | 
|  | 3005 | "mobility_domain", | 
|  | 3006 | dut->ap_mobility_domain); | 
|  | 3007 | owrt_ap_set_vap(dut, vap_count, | 
|  | 3008 | "ft_over_ds", "0"); | 
|  | 3009 | owrt_ap_set_vap(dut, vap_count, | 
|  | 3010 | "ieee80211r", "1"); | 
|  | 3011 | owrt_ap_set_vap(dut, vap_count, | 
|  | 3012 | "nasid", "nas1.example.com"); | 
|  | 3013 | get_hwaddr(sigma_radio_ifname[0], self_mac); | 
|  | 3014 | snprintf(mac_str, sizeof(mac_str), | 
|  | 3015 | "%02x:%02x:%02x:%02x:%02x:%02x", | 
|  | 3016 | self_mac[0], self_mac[1], self_mac[2], | 
|  | 3017 | self_mac[3], self_mac[4], self_mac[5]); | 
|  | 3018 | owrt_ap_set_vap(dut, vap_count, | 
|  | 3019 | "ap_macaddr", mac_str); | 
|  | 3020 | snprintf(mac_str, sizeof(mac_str), | 
|  | 3021 | "%02x%02x%02x%02x%02x%02x", | 
|  | 3022 | self_mac[0], self_mac[1], self_mac[2], | 
|  | 3023 | self_mac[3], self_mac[4], self_mac[5]); | 
|  | 3024 | owrt_ap_set_vap(dut, vap_count, | 
|  | 3025 | "r1_key_holder", mac_str); | 
|  | 3026 | owrt_ap_set_vap(dut, vap_count, | 
|  | 3027 | "ft_psk_generate_local", "1"); | 
|  | 3028 | owrt_ap_set_vap(dut, vap_count, | 
|  | 3029 | "kh_key_hex", | 
|  | 3030 | "000102030405060708090a0b0c0d0e0f"); | 
|  | 3031 | snprintf(mac_str, sizeof(mac_str), | 
|  | 3032 | "%02x:%02x:%02x:%02x:%02x:%02x", | 
|  | 3033 | dut->ft_bss_mac_list[0][0], | 
|  | 3034 | dut->ft_bss_mac_list[0][1], | 
|  | 3035 | dut->ft_bss_mac_list[0][2], | 
|  | 3036 | dut->ft_bss_mac_list[0][3], | 
|  | 3037 | dut->ft_bss_mac_list[0][4], | 
|  | 3038 | dut->ft_bss_mac_list[0][5]); | 
|  | 3039 | owrt_ap_set_vap(dut, vap_count, | 
|  | 3040 | "ap2_macaddr", mac_str); | 
|  | 3041 | owrt_ap_set_vap(dut, vap_count, | 
|  | 3042 | "ap2_r1_key_holder", mac_str); | 
|  | 3043 | owrt_ap_set_vap(dut, vap_count, | 
|  | 3044 | "nasid2", "nas2.example.com"); | 
|  | 3045 | } | 
| Adil Saeed Musthafa | a8d7484 | 2017-04-10 23:13:39 -0700 | [diff] [blame] | 3046 | } | 
|  | 3047 |  | 
| priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 3048 | if (dut->ap_oce == VALUE_ENABLED && | 
|  | 3049 | get_driver_type() == DRIVER_OPENWRT) { | 
|  | 3050 | owrt_ap_set_vap(dut, vap_id, "oce", "1"); | 
|  | 3051 | owrt_ap_set_vap(dut, vap_id, "qbssload", "1"); | 
|  | 3052 | owrt_ap_set_vap(dut, vap_id, "bpr_enable", "1"); | 
|  | 3053 |  | 
| priyadharshini gowthaman | 63ab848 | 2017-12-28 15:32:55 -0800 | [diff] [blame] | 3054 | if (dut->ap_80plus80 == 1) | 
|  | 3055 | owrt_ap_set_vap(dut, vap_id, "cfreq2", "5775"); | 
|  | 3056 |  | 
| priyadharshini gowthaman | de81f39 | 2017-12-28 15:28:49 -0800 | [diff] [blame] | 3057 | if (dut->ap_akm == 1) { | 
|  | 3058 | owrt_ap_set_vap(dut, vap_id, "wpa_group_rekey", | 
|  | 3059 | "3600"); | 
|  | 3060 | owrt_ap_set_vap(dut, vap_id, "key", "12345678"); | 
|  | 3061 | owrt_ap_set_vap(dut, vap_id, "ieee80211ai", | 
|  | 3062 | "1"); | 
|  | 3063 | owrt_ap_set_vap(dut, vap_id, "fils_cache_id", | 
|  | 3064 | "1234"); | 
|  | 3065 | owrt_ap_set_vap(dut, vap_id, | 
|  | 3066 | "erp_send_reauth_start", "1"); | 
|  | 3067 | } | 
|  | 3068 |  | 
| priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 3069 | if (dut->ap_filshlp == VALUE_ENABLED) { | 
|  | 3070 | struct ifreq ifr; | 
|  | 3071 | char *ifname; | 
|  | 3072 | int s; | 
|  | 3073 | struct sockaddr_in *ipaddr; | 
|  | 3074 |  | 
|  | 3075 | s = socket(AF_INET, SOCK_DGRAM, 0); | 
|  | 3076 | if (s < 0) { | 
|  | 3077 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 3078 | "Failed to open socket"); | 
|  | 3079 | return -1; | 
|  | 3080 | } | 
|  | 3081 | ifr.ifr_addr.sa_family = AF_INET; | 
|  | 3082 |  | 
|  | 3083 | memset(&ifr, 0, sizeof(ifr)); | 
|  | 3084 | ifname = "br-lan"; | 
|  | 3085 | strlcpy(ifr.ifr_name, ifname, | 
|  | 3086 | sizeof(ifr.ifr_name)); | 
|  | 3087 | if (ioctl(s, SIOCGIFADDR, &ifr) < 0) { | 
|  | 3088 | perror("ioctl"); | 
|  | 3089 | close(s); | 
|  | 3090 | return -1; | 
|  | 3091 | } | 
|  | 3092 |  | 
|  | 3093 | ipaddr = (struct sockaddr_in*)&ifr.ifr_addr; | 
|  | 3094 | snprintf(buf, sizeof(buf), "%s", | 
|  | 3095 | inet_ntoa(ipaddr->sin_addr)); | 
|  | 3096 | owrt_ap_set_vap(dut, vap_id, "own_ip_addr", | 
|  | 3097 | buf); | 
|  | 3098 | snprintf(buf, sizeof(buf), "%s", | 
|  | 3099 | dut->ap_dhcpserv_ipaddr); | 
|  | 3100 | owrt_ap_set_vap(dut, vap_id, "dhcp_server", | 
|  | 3101 | buf); | 
|  | 3102 | owrt_ap_set_vap(dut, vap_id, | 
|  | 3103 | "dhcp_rapid_commit_proxy", "1"); | 
|  | 3104 | owrt_ap_set_vap(dut, vap_id, | 
|  | 3105 | "fils_hlp_wait_time", "300"); | 
|  | 3106 | } | 
|  | 3107 |  | 
|  | 3108 | if (dut->ap_filsdscv == VALUE_ENABLED) { | 
|  | 3109 | owrt_ap_set_vap(dut, vap_id, "ieee80211ai", | 
|  | 3110 | "1"); | 
|  | 3111 | owrt_ap_set_vap(dut, vap_id, "fils_fd_period", | 
|  | 3112 | "20"); | 
|  | 3113 | } | 
|  | 3114 | } | 
|  | 3115 |  | 
|  | 3116 | if (dut->ap_filsdscv == VALUE_DISABLED) { | 
|  | 3117 | owrt_ap_set_vap(dut, vap_id, "ieee80211ai", "0"); | 
|  | 3118 | owrt_ap_set_vap(dut, vap_id, "fils_fd_period", "0"); | 
|  | 3119 | } | 
|  | 3120 |  | 
|  | 3121 | if (dut->ap_oce == VALUE_DISABLED && | 
|  | 3122 | get_driver_type() == DRIVER_OPENWRT) { | 
|  | 3123 | owrt_ap_set_vap(dut, vap_id, "oce", "0"); | 
|  | 3124 | owrt_ap_set_vap(dut, vap_id, "qbssload", "0"); | 
|  | 3125 | owrt_ap_set_vap(dut, vap_id, "bpr_enable", "0"); | 
|  | 3126 |  | 
|  | 3127 | if (dut->ap_filsdscv == VALUE_DISABLED) { | 
|  | 3128 | owrt_ap_set_vap(dut, vap_id, "ieee80211ai", | 
|  | 3129 | "0"); | 
|  | 3130 | owrt_ap_set_vap(dut, vap_id, "fils_fd_period", | 
|  | 3131 | "0"); | 
|  | 3132 | } | 
|  | 3133 |  | 
|  | 3134 | if (dut->device_type == AP_testbed) | 
|  | 3135 | owrt_ap_set_vap(dut, vap_id, "mbo", "1"); | 
|  | 3136 | } | 
|  | 3137 |  | 
|  | 3138 | /* NAIRealm */ | 
|  | 3139 | if (dut->ap_nairealm_int == 1) { | 
|  | 3140 | snprintf(buf, sizeof(buf), "\"%s\"", dut->ap_nairealm); | 
|  | 3141 | owrt_ap_set_vap(dut, vap_id, "fils_realm", buf); | 
|  | 3142 | owrt_ap_set_vap(dut, vap_id, "erp_domain", buf); | 
|  | 3143 | } | 
|  | 3144 |  | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3145 | /* SSID */ | 
|  | 3146 | snprintf(buf, sizeof(buf), "\"%s\"", dut->ap_ssid); | 
|  | 3147 | owrt_ap_set_vap(dut, vap_count, "ssid", buf); | 
|  | 3148 |  | 
|  | 3149 | /* Encryption */ | 
|  | 3150 | switch (dut->ap_key_mgmt) { | 
|  | 3151 | case AP_OPEN: | 
|  | 3152 | if (dut->ap_cipher == AP_WEP) { | 
|  | 3153 | owrt_ap_set_vap(dut, vap_count, "encryption", | 
|  | 3154 | "wep-mixed"); | 
|  | 3155 | owrt_ap_set_vap(dut, vap_count, "key", | 
|  | 3156 | dut->ap_wepkey); | 
|  | 3157 | } else { | 
|  | 3158 | owrt_ap_set_vap(dut, vap_count, "encryption", | 
|  | 3159 | "none"); | 
|  | 3160 | } | 
| priyadharshini gowthaman | 0454706 | 2018-01-15 11:59:55 -0800 | [diff] [blame] | 3161 | if (dut->ap_key_mgmt == AP_OPEN && | 
|  | 3162 | dut->ap_tag_key_mgmt[0] == AP2_WPA2_OWE) { | 
|  | 3163 | /* OWE transition mode */ | 
|  | 3164 | snprintf(ifname2, sizeof(ifname2), "%s1", | 
|  | 3165 | ifname); | 
|  | 3166 | owrt_ap_set_vap(dut, vap_count, | 
|  | 3167 | "owe_transition_ifname", | 
|  | 3168 | ifname2); | 
|  | 3169 | } | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3170 | break; | 
|  | 3171 | case AP_WPA2_PSK: | 
|  | 3172 | case AP_WPA2_PSK_MIXED: | 
|  | 3173 | case AP_WPA_PSK: | 
| Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 3174 | case AP_WPA2_SAE: | 
|  | 3175 | case AP_WPA2_PSK_SAE: | 
| priyadharshini gowthaman | cce6ca0 | 2018-01-15 11:12:45 -0800 | [diff] [blame] | 3176 | if (dut->ap_key_mgmt == AP_WPA2_PSK || | 
|  | 3177 | dut->ap_key_mgmt == AP_WPA2_PSK_SAE) { | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3178 | snprintf(buf, sizeof(buf), "psk2"); | 
|  | 3179 | } else if (dut->ap_key_mgmt == AP_WPA2_PSK_MIXED) { | 
|  | 3180 | snprintf(buf, sizeof(buf), "psk-mixed"); | 
| priyadharshini gowthaman | cce6ca0 | 2018-01-15 11:12:45 -0800 | [diff] [blame] | 3181 | } else if (dut->ap_key_mgmt == AP_WPA2_SAE) { | 
|  | 3182 | snprintf(buf, sizeof(buf), "ccmp"); | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3183 | } else { | 
|  | 3184 | snprintf(buf, sizeof(buf), "psk"); | 
|  | 3185 | } | 
|  | 3186 |  | 
| priyadharshini gowthaman | cce6ca0 | 2018-01-15 11:12:45 -0800 | [diff] [blame] | 3187 | if (dut->ap_key_mgmt != AP_WPA2_SAE) { | 
|  | 3188 | if (dut->ap_cipher == AP_CCMP_TKIP) | 
|  | 3189 | strlcat(buf, "+ccmp+tkip", sizeof(buf)); | 
|  | 3190 | else if (dut->ap_cipher == AP_TKIP) | 
|  | 3191 | strlcat(buf, "+tkip", sizeof(buf)); | 
| Alexei Avshalom Lazar | 2712cc8 | 2018-12-23 16:29:14 +0200 | [diff] [blame] | 3192 | else if (dut->ap_cipher == AP_GCMP_128) | 
|  | 3193 | strlcat(buf, "+gcmp", sizeof(buf)); | 
| priyadharshini gowthaman | cce6ca0 | 2018-01-15 11:12:45 -0800 | [diff] [blame] | 3194 | else | 
|  | 3195 | strlcat(buf, "+ccmp", sizeof(buf)); | 
|  | 3196 | } | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3197 |  | 
|  | 3198 | owrt_ap_set_vap(dut, vap_count, "encryption", buf); | 
| priyadharshini gowthaman | cce6ca0 | 2018-01-15 11:12:45 -0800 | [diff] [blame] | 3199 |  | 
|  | 3200 | if (!dut->ap_passphrase[0] && dut->ap_psk[0]) { | 
|  | 3201 | snprintf(buf, sizeof(buf), "\"%s\"", | 
|  | 3202 | dut->ap_psk); | 
|  | 3203 | owrt_ap_set_vap(dut, vap_count, "key", buf); | 
|  | 3204 | } else { | 
|  | 3205 | snprintf(buf, sizeof(buf), "\"%s\"", | 
|  | 3206 | dut->ap_passphrase); | 
|  | 3207 | owrt_ap_set_vap(dut, vap_count, "key", buf); | 
|  | 3208 | } | 
|  | 3209 |  | 
|  | 3210 | if (dut->ap_key_mgmt == AP_WPA2_SAE || | 
|  | 3211 | dut->ap_key_mgmt == AP_WPA2_PSK_SAE) | 
|  | 3212 | owrt_ap_set_vap(dut, vap_count, "sae", "1"); | 
|  | 3213 | else | 
|  | 3214 | owrt_ap_set_vap(dut, vap_count, "sae", "0"); | 
|  | 3215 |  | 
|  | 3216 | if (dut->ap_key_mgmt == AP_WPA2_SAE) { | 
|  | 3217 | snprintf(buf, sizeof(buf), "%s", | 
|  | 3218 | dut->ap_passphrase); | 
|  | 3219 | owrt_ap_set_vap(dut, vap_count, "sae_password", | 
|  | 3220 | buf); | 
|  | 3221 | } else { | 
|  | 3222 | snprintf(buf, sizeof(buf), "%s", | 
|  | 3223 | dut->ap_passphrase); | 
|  | 3224 | owrt_ap_set_vap(dut, vap_count, | 
|  | 3225 | "wpa_passphrase", buf); | 
|  | 3226 | } | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3227 | break; | 
|  | 3228 | case AP_WPA2_EAP: | 
|  | 3229 | case AP_WPA2_EAP_MIXED: | 
|  | 3230 | case AP_WPA_EAP: | 
|  | 3231 | if (dut->ap_key_mgmt == AP_WPA2_EAP) { | 
|  | 3232 | snprintf(buf, sizeof(buf), "wpa2"); | 
|  | 3233 | } else if (dut->ap_key_mgmt == AP_WPA2_EAP_MIXED) { | 
|  | 3234 | snprintf(buf, sizeof(buf), "wpa-mixed"); | 
|  | 3235 | } else { | 
|  | 3236 | snprintf(buf, sizeof(buf), "wpa"); | 
|  | 3237 | } | 
|  | 3238 |  | 
| Peng Xu | 591be45 | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 3239 | if (dut->ap_cipher == AP_CCMP_TKIP) | 
|  | 3240 | strlcat(buf, "+ccmp+tkip", sizeof(buf)); | 
|  | 3241 | else if (dut->ap_cipher == AP_TKIP) | 
|  | 3242 | strlcat(buf, "+tkip", sizeof(buf)); | 
|  | 3243 | else | 
|  | 3244 | strlcat(buf, "+ccmp", sizeof(buf)); | 
|  | 3245 |  | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3246 | owrt_ap_set_vap(dut, vap_count, "encryption", buf); | 
|  | 3247 | snprintf(buf, sizeof(buf), "%s", dut->ap_radius_ipaddr); | 
|  | 3248 | owrt_ap_set_vap(dut, vap_count, "auth_server", buf); | 
|  | 3249 | snprintf(buf, sizeof(buf), "%d", dut->ap_radius_port); | 
|  | 3250 | owrt_ap_set_vap(dut, vap_count, "auth_port", buf); | 
|  | 3251 | snprintf(buf, sizeof(buf), "%s", | 
|  | 3252 | dut->ap_radius_password); | 
|  | 3253 | owrt_ap_set_vap(dut, vap_count, "auth_secret", buf); | 
|  | 3254 | break; | 
| Jouni Malinen | 4cf699f | 2018-06-19 00:46:27 +0300 | [diff] [blame] | 3255 | case AP_WPA2_EAP_OSEN: | 
| Jouni Malinen | c2b9121 | 2018-09-12 02:26:39 +0300 | [diff] [blame] | 3256 | case AP_OSEN: | 
| Jouni Malinen | 6be21c8 | 2018-08-01 18:47:24 +0300 | [diff] [blame] | 3257 | case AP_WPA2_FT_EAP: | 
|  | 3258 | case AP_WPA2_FT_PSK: | 
|  | 3259 | case AP_WPA2_EAP_SHA256: | 
|  | 3260 | case AP_WPA2_PSK_SHA256: | 
|  | 3261 | case AP_WPA2_ENT_FT_EAP: | 
| Jouni Malinen | 4cf699f | 2018-06-19 00:46:27 +0300 | [diff] [blame] | 3262 | /* TODO */ | 
|  | 3263 | break; | 
| Jouni Malinen | ad395a2 | 2017-09-01 21:13:46 +0300 | [diff] [blame] | 3264 | case AP_SUITEB: | 
| priyadharshini gowthaman | 2136bd5 | 2018-01-15 11:28:55 -0800 | [diff] [blame] | 3265 | owrt_ap_set_vap(dut, vap_count, "suite_b", "192"); | 
|  | 3266 | snprintf(buf, sizeof(buf), "gcmp"); | 
|  | 3267 | owrt_ap_set_vap(dut, vap_count, "encryption", buf); | 
|  | 3268 | snprintf(buf, sizeof(buf), "%s", dut->ap_radius_ipaddr); | 
|  | 3269 | owrt_ap_set_vap(dut, vap_count, "auth_server", buf); | 
|  | 3270 | snprintf(buf, sizeof(buf), "%d", dut->ap_radius_port); | 
|  | 3271 | owrt_ap_set_vap(dut, vap_count, "auth_port", buf); | 
|  | 3272 | snprintf(buf, sizeof(buf), "%s", | 
|  | 3273 | dut->ap_radius_password); | 
|  | 3274 | owrt_ap_set_vap(dut, vap_count, "auth_secret", buf); | 
|  | 3275 | snprintf(buf, sizeof(buf), "%d", | 
|  | 3276 | dut->ap_group_mgmt_cipher); | 
|  | 3277 | owrt_ap_set_vap(dut, vap_count, "group_mgmt_cipher", | 
|  | 3278 | buf); | 
| Jouni Malinen | ad395a2 | 2017-09-01 21:13:46 +0300 | [diff] [blame] | 3279 | break; | 
| Jouni Malinen | 147b3c3 | 2017-10-09 16:51:54 +0300 | [diff] [blame] | 3280 | case AP_WPA2_OWE: | 
| priyadharshini gowthaman | 0454706 | 2018-01-15 11:59:55 -0800 | [diff] [blame] | 3281 | owrt_ap_set_vap(dut, vap_count, "owe", "1"); | 
|  | 3282 | snprintf(buf, sizeof(buf), "ccmp"); | 
|  | 3283 | owrt_ap_set_vap(dut, vap_count, "encryption", buf); | 
|  | 3284 | if (dut->ap_sae_groups) { | 
|  | 3285 | snprintf(buf, sizeof(buf), "\'%s\'", | 
|  | 3286 | dut->ap_sae_groups); | 
| priyadharshini gowthaman | b59bfe4 | 2018-08-30 15:14:08 -0700 | [diff] [blame] | 3287 | owrt_ap_set_list_vap(dut, vap_count, | 
|  | 3288 | "owe_groups", buf); | 
| priyadharshini gowthaman | 0454706 | 2018-01-15 11:59:55 -0800 | [diff] [blame] | 3289 | } | 
|  | 3290 |  | 
|  | 3291 | if (dut->ap_key_mgmt == AP_WPA2_OWE && | 
|  | 3292 | dut->ap_tag_ssid[0][0] && | 
|  | 3293 | dut->ap_tag_key_mgmt[0] == AP2_OPEN) { | 
|  | 3294 | /* OWE transition mode */ | 
|  | 3295 | snprintf(ifname2, sizeof(ifname2), "%s1", | 
|  | 3296 | ifname); | 
|  | 3297 | owrt_ap_set_vap(dut, vap_count, | 
|  | 3298 | "owe_transition_ifname", | 
|  | 3299 | ifname2); | 
|  | 3300 | owrt_ap_set_vap(dut, vap_count, "hidden", "1"); | 
|  | 3301 | } | 
| Jouni Malinen | 147b3c3 | 2017-10-09 16:51:54 +0300 | [diff] [blame] | 3302 | break; | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3303 | } | 
|  | 3304 |  | 
|  | 3305 | if (!dut->ap_is_dual) | 
|  | 3306 | break; | 
|  | 3307 | } | 
|  | 3308 |  | 
|  | 3309 | if (dut->ap_is_dual) | 
|  | 3310 | return 1; | 
|  | 3311 |  | 
|  | 3312 | /* PMF */ | 
|  | 3313 | snprintf(buf, sizeof(buf), "%d", dut->ap_pmf); | 
|  | 3314 | owrt_ap_set_vap(dut, vap_id, "ieee80211w", buf); | 
|  | 3315 |  | 
|  | 3316 | /* Add SHA256 */ | 
|  | 3317 | snprintf(buf, sizeof(buf), "%d", dut->ap_add_sha256); | 
|  | 3318 | owrt_ap_set_vap(dut, vap_id, "add_sha256", buf); | 
|  | 3319 |  | 
| priyadharshini gowthaman | de81f39 | 2017-12-28 15:28:49 -0800 | [diff] [blame] | 3320 | /* Add SHA384 for akmsuitetype 15 */ | 
|  | 3321 | if (dut->ap_akm == 1) { | 
|  | 3322 | snprintf(buf, sizeof(buf), "%d", dut->ap_add_sha384); | 
|  | 3323 | owrt_ap_set_vap(dut, vap_id, "add_sha384", buf); | 
|  | 3324 | } | 
|  | 3325 |  | 
| Sarvepalli, Rajesh Babu | 24dc7e4 | 2016-03-18 21:27:26 +0530 | [diff] [blame] | 3326 | /* Enable RSN preauthentication, if asked to */ | 
|  | 3327 | snprintf(buf, sizeof(buf), "%d", dut->ap_rsn_preauth); | 
|  | 3328 | owrt_ap_set_vap(dut, vap_id, "rsn_preauth", buf); | 
|  | 3329 |  | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3330 | /* Hotspot 2.0 */ | 
|  | 3331 | if (dut->ap_hs2) { | 
|  | 3332 | int ret; | 
|  | 3333 |  | 
|  | 3334 | ret = owrt_ap_config_vap_hs2(dut, vap_id); | 
|  | 3335 | if (ret) | 
|  | 3336 | return ret; | 
|  | 3337 | } | 
|  | 3338 |  | 
|  | 3339 | /* Interworking */ | 
|  | 3340 | if (dut->ap_interworking) { | 
|  | 3341 | snprintf(buf, sizeof(buf), "%d", dut->ap_access_net_type); | 
|  | 3342 | owrt_ap_set_vap(dut, vap_id, "access_network_type", buf); | 
|  | 3343 | snprintf(buf, sizeof(buf), "%d", dut->ap_internet); | 
|  | 3344 | owrt_ap_set_vap(dut, vap_id, "internet", buf); | 
|  | 3345 | snprintf(buf, sizeof(buf), "%d", dut->ap_venue_group); | 
|  | 3346 | owrt_ap_set_vap(dut, vap_id, "venue_group", buf); | 
|  | 3347 | snprintf(buf, sizeof(buf), "%d", dut->ap_venue_type); | 
|  | 3348 | owrt_ap_set_vap(dut, vap_id, "venue_type", buf); | 
|  | 3349 | snprintf(buf, sizeof(buf), "%s", dut->ap_hessid); | 
|  | 3350 | owrt_ap_set_vap(dut, vap_id, "hessid", buf); | 
|  | 3351 |  | 
|  | 3352 | if (dut->ap_gas_cb_delay > 0) { | 
|  | 3353 | snprintf(buf, sizeof(buf), "%d", dut->ap_gas_cb_delay); | 
|  | 3354 | owrt_ap_set_vap(dut, vap_id, "gas_comeback_delay", buf); | 
|  | 3355 | } | 
|  | 3356 |  | 
|  | 3357 | if (dut->ap_roaming_cons[0]) { | 
|  | 3358 | char *rcons, *temp_ptr; | 
|  | 3359 |  | 
|  | 3360 | rcons = strdup(dut->ap_roaming_cons); | 
|  | 3361 | if (rcons == NULL) | 
|  | 3362 | return 0; | 
|  | 3363 |  | 
|  | 3364 | temp_ptr = strchr(rcons, ';'); | 
|  | 3365 |  | 
|  | 3366 | if (temp_ptr) | 
|  | 3367 | *temp_ptr++ = '\0'; | 
|  | 3368 |  | 
|  | 3369 | owrt_ap_set_list_vap(dut, vap_id, "roaming_consortium", | 
|  | 3370 | rcons); | 
|  | 3371 |  | 
|  | 3372 | if (temp_ptr) | 
|  | 3373 | owrt_ap_set_list_vap(dut, vap_id, | 
|  | 3374 | "roaming_consortium", | 
|  | 3375 | temp_ptr); | 
|  | 3376 |  | 
|  | 3377 | free(rcons); | 
|  | 3378 | } | 
|  | 3379 | } | 
|  | 3380 |  | 
|  | 3381 | if (dut->ap_venue_name) { | 
|  | 3382 | owrt_ap_set_list_vap(dut, vap_id, "venue_name", | 
|  | 3383 | "'P\"eng:Wi-Fi Alliance\\n2989 Copper Road\\nSanta Clara, CA 95051, USA\"'"); | 
|  | 3384 | owrt_ap_set_list_vap(dut, vap_id, "venue_name", | 
|  | 3385 | "\'"ANQP_VENUE_NAME_1_CHI"\'"); | 
|  | 3386 | } | 
|  | 3387 |  | 
|  | 3388 | if (dut->ap_net_auth_type == 1) { | 
| priyadharshini gowthaman | 9b8a8c3 | 2018-08-31 10:49:24 -0700 | [diff] [blame] | 3389 | owrt_ap_set_list_vap(dut, vap_id, "network_auth_type", | 
|  | 3390 | "'00https://tandc-server.wi-fi.org'"); | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3391 | } else if (dut->ap_net_auth_type == 2) { | 
| priyadharshini gowthaman | 9b8a8c3 | 2018-08-31 10:49:24 -0700 | [diff] [blame] | 3392 | owrt_ap_set_list_vap(dut, vap_id, "network_auth_type", "'01'"); | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3393 | } | 
|  | 3394 |  | 
|  | 3395 | if (dut->ap_nai_realm_list == 1) { | 
|  | 3396 | owrt_ap_set_list_vap(dut, vap_id, "nai_realm", | 
|  | 3397 | "'0,mail.example.com;cisco.com;wi-fi.org,21[2:4][5:7]'"); | 
|  | 3398 | owrt_ap_set_list_vap(dut, vap_id, "nai_realm", | 
|  | 3399 | "'0,wi-fi.org;example.com,13[5:6]'"); | 
|  | 3400 |  | 
|  | 3401 | } else if (dut->ap_nai_realm_list == 2) { | 
|  | 3402 | owrt_ap_set_list_vap(dut, vap_id, "nai_realm", | 
|  | 3403 | "'0,wi-fi.org,21[2:4][5:7]'"); | 
|  | 3404 | } else if (dut->ap_nai_realm_list == 3) { | 
|  | 3405 | owrt_ap_set_list_vap(dut, vap_id, "nai_realm", | 
|  | 3406 | "'0,cisco.com;wi-fi.org,21[2:4][5:7]'"); | 
|  | 3407 | owrt_ap_set_list_vap(dut, vap_id, "nai_realm", | 
|  | 3408 | "'0,wi-fi.org;example.com,13[5:6]'"); | 
|  | 3409 | } else if (dut->ap_nai_realm_list == 4) { | 
|  | 3410 | owrt_ap_set_list_vap(dut, vap_id, "nai_realm", | 
|  | 3411 | "'0,mail.example.com,21[2:4][5:7],13[5:6]'"); | 
|  | 3412 | } else if (dut->ap_nai_realm_list == 5) { | 
|  | 3413 | owrt_ap_set_list_vap(dut, vap_id, "nai_realm", | 
|  | 3414 | "'0,wi-fi.org;ruckuswireless.com,21[2:4][5:7]'"); | 
|  | 3415 | } else if (dut->ap_nai_realm_list == 6) { | 
|  | 3416 | owrt_ap_set_list_vap(dut, vap_id, "nai_realm", | 
|  | 3417 | "'0,wi-fi.org;mail.example.com,21[2:4][5:7]'"); | 
|  | 3418 | } else if (dut->ap_nai_realm_list == 7) { | 
|  | 3419 | owrt_ap_set_list_vap(dut, vap_id, "nai_realm", | 
|  | 3420 | "'0,wi-fi.org,13[5:6]'"); | 
|  | 3421 | owrt_ap_set_list_vap(dut, vap_id, "nai_realm", | 
|  | 3422 | "'0,wi-fi.org,21[2:4][5:7]'"); | 
|  | 3423 | } | 
|  | 3424 |  | 
|  | 3425 | if (dut->ap_domain_name_list[0]) | 
|  | 3426 | owrt_ap_set_list_vap(dut, vap_id, "domain_name", | 
|  | 3427 | dut->ap_domain_name_list); | 
|  | 3428 |  | 
|  | 3429 | if (dut->ap_ip_addr_type_avail) | 
|  | 3430 | owrt_ap_set_vap(dut, vap_id, "ipaddr_type_availability", | 
|  | 3431 | "'0c'"); | 
|  | 3432 |  | 
|  | 3433 | temp = buf; | 
|  | 3434 |  | 
|  | 3435 | *temp++ = '\''; | 
|  | 3436 |  | 
|  | 3437 | for (i = 0; dut->ap_plmn_mcc[i][0] && dut->ap_plmn_mnc[i][0]; i++) { | 
|  | 3438 | if (i) | 
|  | 3439 | *temp++ = ';'; | 
|  | 3440 |  | 
|  | 3441 | snprintf(temp, | 
|  | 3442 | sizeof(dut->ap_plmn_mcc[i]) + | 
|  | 3443 | sizeof(dut->ap_plmn_mnc[i]) + 1, | 
|  | 3444 | "%s,%s", | 
|  | 3445 | dut->ap_plmn_mcc[i], | 
|  | 3446 | dut->ap_plmn_mnc[i]); | 
|  | 3447 |  | 
|  | 3448 | temp += strlen(dut->ap_plmn_mcc[i]) + | 
|  | 3449 | strlen(dut->ap_plmn_mnc[i]) + 1; | 
|  | 3450 | } | 
|  | 3451 |  | 
|  | 3452 | *temp++ = '\''; | 
|  | 3453 | *temp++ = '\0'; | 
|  | 3454 |  | 
|  | 3455 | if (i) | 
|  | 3456 | owrt_ap_set_vap(dut, vap_id, "anqp_3gpp_cell_net", buf); | 
|  | 3457 |  | 
|  | 3458 | if (dut->ap_qos_map_set == 1) | 
|  | 3459 | owrt_ap_set_vap(dut, vap_id, "qos_map_set", QOS_MAP_SET_1); | 
|  | 3460 | else if (dut->ap_qos_map_set == 2) | 
|  | 3461 | owrt_ap_set_vap(dut, vap_id, "qos_map_set", QOS_MAP_SET_2); | 
|  | 3462 |  | 
|  | 3463 | /* Proxy-ARP */ | 
|  | 3464 | snprintf(buf, sizeof(buf), "%d", dut->ap_proxy_arp); | 
|  | 3465 | owrt_ap_set_vap(dut, vap_id, "proxyarp", buf); | 
|  | 3466 |  | 
|  | 3467 | /* DGAF */ | 
|  | 3468 | snprintf(buf, sizeof(buf), "%d", dut->ap_dgaf_disable); | 
|  | 3469 | /* parse to hostapd */ | 
|  | 3470 | owrt_ap_set_vap(dut, vap_id, "disable_dgaf", buf); | 
|  | 3471 | /* parse to wifi driver */ | 
|  | 3472 | owrt_ap_set_vap(dut, vap_id, "dgaf_disable", buf); | 
|  | 3473 |  | 
|  | 3474 | /* HCBSSLoad */ | 
|  | 3475 | if (dut->ap_bss_load) { | 
|  | 3476 | unsigned int bssload = 0; | 
|  | 3477 |  | 
|  | 3478 | if (dut->ap_bss_load == 1) { | 
|  | 3479 | /* STA count: 1, CU: 50, AAC: 65535 */ | 
|  | 3480 | bssload = 0x0132ffff; | 
|  | 3481 | } else if (dut->ap_bss_load == 2) { | 
|  | 3482 | /* STA count: 1, CU: 200, AAC: 65535 */ | 
|  | 3483 | bssload = 0x01c8ffff; | 
|  | 3484 | } else if (dut->ap_bss_load == 3) { | 
|  | 3485 | /* STA count: 1, CU: 75, AAC: 65535 */ | 
|  | 3486 | bssload = 0x014bffff; | 
|  | 3487 | } | 
|  | 3488 |  | 
|  | 3489 | snprintf(buf, sizeof(buf), "%d", bssload); | 
|  | 3490 | owrt_ap_set_vap(dut, vap_id, "hcbssload", buf); | 
|  | 3491 | } | 
|  | 3492 |  | 
|  | 3493 | /* L2TIF */ | 
|  | 3494 | if  (dut->ap_l2tif) | 
|  | 3495 | owrt_ap_set_vap(dut, vap_id, "l2tif", "1"); | 
|  | 3496 |  | 
|  | 3497 | if (dut->ap_disable_protection == 1) | 
|  | 3498 | owrt_ap_set_vap(dut, vap_id, "enablertscts", "0"); | 
|  | 3499 |  | 
| Sunil Dutt | 77b213d | 2017-09-14 18:24:40 +0300 | [diff] [blame] | 3500 | if (dut->ap_txBF) { | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3501 | owrt_ap_set_vap(dut, vap_id, "vhtsubfee", "1"); | 
|  | 3502 | owrt_ap_set_vap(dut, vap_id, "vhtsubfer", "1"); | 
|  | 3503 | } | 
|  | 3504 |  | 
| Mohammed Shafi Shajakhan | 061af00 | 2016-06-02 20:10:54 +0530 | [diff] [blame] | 3505 | if (dut->ap_mu_txBF) | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3506 | owrt_ap_set_vap(dut, vap_id, "vhtmubfer", "1"); | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3507 |  | 
| Vasanthakumar Pandurangan | 2b5431d | 2016-01-12 15:52:48 +0530 | [diff] [blame] | 3508 | if (dut->ap_tx_stbc) { | 
|  | 3509 | /* STBC and beamforming are mutually exclusive features */ | 
|  | 3510 | owrt_ap_set_vap(dut, vap_id, "implicitbf", "0"); | 
|  | 3511 | } | 
|  | 3512 |  | 
| Priyadharshini Gowthaman | 8fb1504 | 2015-11-25 18:27:41 +0530 | [diff] [blame] | 3513 | /* enable dfsmode */ | 
|  | 3514 | snprintf(buf, sizeof(buf), "%d", dut->ap_dfs_mode); | 
|  | 3515 | owrt_ap_set_vap(dut, vap_id, "doth", buf); | 
|  | 3516 |  | 
| priyadharshini gowthaman | 2323d0a | 2016-09-02 15:48:02 -0700 | [diff] [blame] | 3517 | if (dut->program == PROGRAM_LOC && dut->ap_interworking) { | 
|  | 3518 | char anqpval[1024]; | 
|  | 3519 |  | 
|  | 3520 | owrt_ap_set_vap(dut, vap_id, "interworking", "1"); | 
|  | 3521 |  | 
| Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 3522 | if (dut->ap_lci == 1 && strlen(dut->ap_tag_ssid[0]) == 0) { | 
| Pradeep Reddy Potteti | b48012a | 2016-11-28 16:58:54 +0530 | [diff] [blame] | 3523 | snprintf(anqpval, sizeof(anqpval), | 
|  | 3524 | "'265:0010%s%s060101'", | 
| priyadharshini gowthaman | 2323d0a | 2016-09-02 15:48:02 -0700 | [diff] [blame] | 3525 | dut->ap_val_lci, dut->ap_infoz); | 
|  | 3526 | owrt_ap_set_list_vap(dut, vap_id, "anqp_elem", anqpval); | 
|  | 3527 | } | 
|  | 3528 |  | 
|  | 3529 | if (dut->ap_lcr == 1) { | 
| Pradeep Reddy Potteti | b48012a | 2016-11-28 16:58:54 +0530 | [diff] [blame] | 3530 | snprintf(anqpval, sizeof(anqpval), | 
|  | 3531 | "'266:0000b2555302ae%s'", | 
| priyadharshini gowthaman | 2323d0a | 2016-09-02 15:48:02 -0700 | [diff] [blame] | 3532 | dut->ap_val_lcr); | 
|  | 3533 | owrt_ap_set_list_vap(dut, vap_id, "anqp_elem", anqpval); | 
|  | 3534 | } | 
|  | 3535 |  | 
|  | 3536 | if (dut->ap_fqdn_held == 1 && dut->ap_fqdn_supl == 1) | 
|  | 3537 | owrt_ap_set_list_vap(dut, vap_id, "anqp_elem", | 
|  | 3538 | "'267:00110168656c642e6578616d706c652e636f6d0011027375706c2e6578616d706c652e636f6d'"); | 
|  | 3539 | } | 
|  | 3540 |  | 
| priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 3541 | if (dut->program == PROGRAM_MBO) { | 
|  | 3542 | owrt_ap_set_vap(dut, vap_id, "interworking", "1"); | 
|  | 3543 | owrt_ap_set_vap(dut, vap_id, "mbo", "1"); | 
|  | 3544 | owrt_ap_set_vap(dut, vap_id, "rrm", "1"); | 
| Adil Saeed Musthafa | 65160c0 | 2017-04-10 23:13:38 -0700 | [diff] [blame] | 3545 | owrt_ap_set_vap(dut, vap_id, "mbo_cell_conn_pref", "1"); | 
| priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 3546 |  | 
|  | 3547 | owrt_ap_set_list_vap(dut, vap_id, "anqp_elem", | 
|  | 3548 | "'272:34108cfdf0020df1f7000000733000030101'"); | 
| Adil Saeed Musthafa | ed5faae | 2017-04-10 23:13:36 -0700 | [diff] [blame] | 3549 | snprintf(buf, sizeof(buf), "%d", dut->ap_gas_cb_delay); | 
|  | 3550 | owrt_ap_set_vap(dut, vap_id, "gas_comeback_delay", buf); | 
| priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 3551 | } | 
|  | 3552 |  | 
| Jouni Malinen | 6be21c8 | 2018-08-01 18:47:24 +0300 | [diff] [blame] | 3553 | if (ap_ft_enabled(dut)) { | 
| Adil Saeed Musthafa | 4ec61bd | 2017-04-10 23:13:41 -0700 | [diff] [blame] | 3554 | unsigned char self_mac[ETH_ALEN]; | 
|  | 3555 | char mac_str[20]; | 
|  | 3556 |  | 
|  | 3557 | owrt_ap_set_vap(dut, vap_id, "ft_over_ds", "0"); | 
|  | 3558 | owrt_ap_set_vap(dut, vap_id, "ieee80211r", "1"); | 
|  | 3559 | get_hwaddr(sigma_radio_ifname[0], self_mac); | 
|  | 3560 | snprintf(mac_str, sizeof(mac_str), | 
|  | 3561 | "%02x:%02x:%02x:%02x:%02x:%02x", | 
|  | 3562 | self_mac[0], self_mac[1], self_mac[2], | 
|  | 3563 | self_mac[3], self_mac[4], self_mac[5]); | 
|  | 3564 | owrt_ap_set_vap(dut, vap_id, "ap_macaddr", mac_str); | 
| priyadharshini gowthaman | 47189f5 | 2017-12-28 12:37:46 -0800 | [diff] [blame] | 3565 | snprintf(mac_str, sizeof(mac_str), | 
|  | 3566 | "%02x:%02x:%02x:%02x:%02x:%02x", | 
|  | 3567 | self_mac[0], self_mac[1], self_mac[2], | 
|  | 3568 | self_mac[3], self_mac[4], self_mac[5]); | 
|  | 3569 | owrt_ap_set_vap(dut, vap_id, "r1_key_holder", mac_str); | 
| Adil Saeed Musthafa | 4ec61bd | 2017-04-10 23:13:41 -0700 | [diff] [blame] | 3570 | owrt_ap_set_vap(dut, vap_id, "ft_psk_generate_local", "1"); | 
|  | 3571 | owrt_ap_set_vap(dut, vap_id, "kh_key_hex", | 
|  | 3572 | "000102030405060708090a0b0c0d0e0f"); | 
|  | 3573 | snprintf(mac_str, sizeof(mac_str), | 
|  | 3574 | "%02x:%02x:%02x:%02x:%02x:%02x", | 
|  | 3575 | dut->ft_bss_mac_list[0][0], | 
|  | 3576 | dut->ft_bss_mac_list[0][1], | 
|  | 3577 | dut->ft_bss_mac_list[0][2], | 
|  | 3578 | dut->ft_bss_mac_list[0][3], | 
|  | 3579 | dut->ft_bss_mac_list[0][4], | 
|  | 3580 | dut->ft_bss_mac_list[0][5]); | 
|  | 3581 | owrt_ap_set_vap(dut, vap_id, "ap2_macaddr", mac_str); | 
| priyadharshini gowthaman | 47189f5 | 2017-12-28 12:37:46 -0800 | [diff] [blame] | 3582 | owrt_ap_set_vap(dut, vap_id, "mobility_domain", | 
|  | 3583 | dut->ap_mobility_domain); | 
|  | 3584 | owrt_ap_set_vap(dut, vap_id, "ap2_r1_key_holder", mac_str); | 
| Adil Saeed Musthafa | 4ec61bd | 2017-04-10 23:13:41 -0700 | [diff] [blame] | 3585 | } | 
|  | 3586 |  | 
| Jouni Malinen | 6be21c8 | 2018-08-01 18:47:24 +0300 | [diff] [blame] | 3587 | if ((ap_ft_enabled(dut) && dut->ap_name == 0) || | 
|  | 3588 | (ap_ft_enabled(dut) && dut->ap_name == 2)) { | 
| Adil Saeed Musthafa | 4ec61bd | 2017-04-10 23:13:41 -0700 | [diff] [blame] | 3589 | owrt_ap_set_vap(dut, vap_id, "nasid2", "nas2.example.com"); | 
|  | 3590 | owrt_ap_set_vap(dut, vap_id, "nasid", "nas1.example.com"); | 
| Adil Saeed Musthafa | 4ec61bd | 2017-04-10 23:13:41 -0700 | [diff] [blame] | 3591 | } | 
|  | 3592 |  | 
| Jouni Malinen | 6be21c8 | 2018-08-01 18:47:24 +0300 | [diff] [blame] | 3593 | if (ap_ft_enabled(dut) && dut->ap_name == 1) { | 
| Adil Saeed Musthafa | 4ec61bd | 2017-04-10 23:13:41 -0700 | [diff] [blame] | 3594 | owrt_ap_set_vap(dut, vap_id, "nasid2", "nas1.example.com"); | 
|  | 3595 | owrt_ap_set_vap(dut, vap_id, "nasid", "nas2.example.com"); | 
| Adil Saeed Musthafa | 4ec61bd | 2017-04-10 23:13:41 -0700 | [diff] [blame] | 3596 | } | 
|  | 3597 |  | 
| priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 3598 | if (dut->ap_broadcast_ssid == VALUE_DISABLED) | 
|  | 3599 | owrt_ap_set_vap(dut, vap_id, "hidden", "1"); | 
|  | 3600 |  | 
| priyadharshini gowthaman | de81f39 | 2017-12-28 15:28:49 -0800 | [diff] [blame] | 3601 | /* Enable/disable PMKSA caching, if asked to */ | 
|  | 3602 | if (dut->ap_pmksa == 1) { | 
|  | 3603 | snprintf(buf, sizeof(buf), "%d", dut->ap_pmksa_caching); | 
|  | 3604 | owrt_ap_set_vap(dut, vap_id, "disable_pmksa_caching", buf); | 
|  | 3605 | } | 
|  | 3606 |  | 
| priyadharshini gowthaman | cce6ca0 | 2018-01-15 11:12:45 -0800 | [diff] [blame] | 3607 | if (dut->rsne_override) { | 
|  | 3608 | snprintf(buf, sizeof(buf), "%s", dut->rsne_override); | 
|  | 3609 | owrt_ap_set_vap(dut, vap_count, "own_ie_override", buf); | 
|  | 3610 | } | 
|  | 3611 |  | 
|  | 3612 | if (dut->sae_commit_override) { | 
|  | 3613 | snprintf(buf, sizeof(buf), "%s", dut->sae_commit_override); | 
|  | 3614 | owrt_ap_set_vap(dut, vap_count, "sae_commit_override", buf); | 
|  | 3615 | } | 
|  | 3616 |  | 
|  | 3617 | if (dut->ap_sae_groups) { | 
|  | 3618 | snprintf(buf, sizeof(buf), "\'%s\'", dut->ap_sae_groups); | 
| priyadharshini gowthaman | b59bfe4 | 2018-08-30 15:14:08 -0700 | [diff] [blame] | 3619 | owrt_ap_set_list_vap(dut, vap_count, "sae_groups", buf); | 
| priyadharshini gowthaman | cce6ca0 | 2018-01-15 11:12:45 -0800 | [diff] [blame] | 3620 | } | 
|  | 3621 |  | 
|  | 3622 | if (dut->sae_anti_clogging_threshold >= 0) { | 
|  | 3623 | snprintf(buf, sizeof(buf), "%d", | 
|  | 3624 | dut->sae_anti_clogging_threshold); | 
|  | 3625 | owrt_ap_set_vap(dut, vap_count, "sae_anti_clogging_threshold", | 
|  | 3626 | buf); | 
|  | 3627 | } | 
|  | 3628 |  | 
|  | 3629 | if (dut->sae_reflection) | 
|  | 3630 | owrt_ap_set_vap(dut, vap_count, "sae_reflection_attack", "1"); | 
|  | 3631 |  | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3632 | return 1; | 
|  | 3633 | } | 
|  | 3634 |  | 
|  | 3635 |  | 
| priyadharshini gowthaman | 2500f20 | 2016-10-13 17:13:55 -0700 | [diff] [blame] | 3636 | static int owrt_ap_config_vap_anqp(struct sigma_dut *dut) | 
|  | 3637 | { | 
|  | 3638 | char anqpval[1024]; | 
|  | 3639 | unsigned char addr[6]; | 
|  | 3640 | unsigned char addr2[6]; | 
|  | 3641 | struct ifreq ifr; | 
|  | 3642 | char *ifname; | 
|  | 3643 | int s; | 
|  | 3644 | int vap_id = 0; | 
|  | 3645 |  | 
|  | 3646 | s = socket(AF_INET, SOCK_DGRAM, 0); | 
|  | 3647 | if (s < 0) { | 
|  | 3648 | sigma_dut_print(dut, DUT_MSG_ERROR, "Failed to open socket"); | 
|  | 3649 | return -1; | 
|  | 3650 | } | 
|  | 3651 |  | 
|  | 3652 | memset(&ifr, 0, sizeof(ifr)); | 
|  | 3653 | ifname = "ath0"; | 
| Peng Xu | b8fc5cc | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 3654 | strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); | 
| priyadharshini gowthaman | 2500f20 | 2016-10-13 17:13:55 -0700 | [diff] [blame] | 3655 | if (ioctl(s, SIOCGIFHWADDR, &ifr) < 0) { | 
|  | 3656 | perror("ioctl"); | 
|  | 3657 | close(s); | 
|  | 3658 | return -1; | 
|  | 3659 | } | 
|  | 3660 | memcpy(addr, ifr.ifr_hwaddr.sa_data, 6); | 
|  | 3661 |  | 
|  | 3662 | memset(&ifr, 0, sizeof(ifr)); | 
|  | 3663 | ifname = "ath01"; | 
| Peng Xu | b8fc5cc | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 3664 | strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); | 
| priyadharshini gowthaman | 2500f20 | 2016-10-13 17:13:55 -0700 | [diff] [blame] | 3665 | if (ioctl(s, SIOCGIFHWADDR, &ifr) < 0) { | 
|  | 3666 | perror("ioctl"); | 
|  | 3667 | close(s); | 
|  | 3668 | return -1; | 
|  | 3669 | } | 
|  | 3670 | close(s); | 
|  | 3671 | memcpy(addr2, ifr.ifr_hwaddr.sa_data, 6); | 
|  | 3672 |  | 
|  | 3673 | snprintf(anqpval, sizeof(anqpval), | 
|  | 3674 | "'265:0010%s%s060101070d00%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x'", | 
|  | 3675 | dut->ap_val_lci, dut->ap_infoz, | 
|  | 3676 | addr[0], addr[1], addr[2], addr[3], addr[4], addr[5], | 
|  | 3677 | addr2[0], addr2[1], addr2[2], addr2[3], addr2[4], addr2[5]); | 
|  | 3678 |  | 
|  | 3679 | owrt_ap_set_list_vap(dut, vap_id, "anqp_elem", anqpval); | 
|  | 3680 | return 0; | 
|  | 3681 | } | 
|  | 3682 |  | 
|  | 3683 |  | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3684 | static int owrt_ap_post_config_commit(struct sigma_dut *dut, | 
|  | 3685 | struct sigma_conn *conn, | 
|  | 3686 | struct sigma_cmd *cmd) | 
|  | 3687 | { | 
| Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 3688 | int ap_security = 0; | 
|  | 3689 | int i; | 
|  | 3690 |  | 
|  | 3691 | for (i = 0; i < MAX_WLAN_TAGS - 1; i++) { | 
|  | 3692 | if (dut->ap_tag_key_mgmt[i] != AP2_OPEN) | 
|  | 3693 | ap_security = 1; | 
|  | 3694 | } | 
|  | 3695 | if (dut->ap_key_mgmt != AP_OPEN) | 
|  | 3696 | ap_security = 1; | 
|  | 3697 | if (ap_security) { | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3698 | /* allow some time for hostapd to start before returning | 
|  | 3699 | * success */ | 
|  | 3700 | usleep(500000); | 
|  | 3701 |  | 
|  | 3702 | if (run_hostapd_cli(dut, "ping") != 0) { | 
|  | 3703 | send_resp(dut, conn, SIGMA_ERROR, | 
|  | 3704 | "errorCode,Failed to talk to hostapd"); | 
|  | 3705 | return 0; | 
|  | 3706 | } | 
|  | 3707 | } | 
|  | 3708 |  | 
|  | 3709 | if (get_openwrt_driver_type() == OPENWRT_DRIVER_ATHEROS) | 
|  | 3710 | ath_ap_set_params(dut); | 
|  | 3711 |  | 
|  | 3712 | /* Send response */ | 
|  | 3713 | return 1; | 
|  | 3714 | } | 
|  | 3715 |  | 
|  | 3716 |  | 
|  | 3717 | static int cmd_owrt_ap_config_commit(struct sigma_dut *dut, | 
|  | 3718 | struct sigma_conn *conn, | 
|  | 3719 | struct sigma_cmd *cmd) | 
|  | 3720 | { | 
| priyadharshini gowthaman | b4de196 | 2018-01-15 12:21:04 -0800 | [diff] [blame] | 3721 | if (dut->program == PROGRAM_DPP && | 
|  | 3722 | get_driver_type() == DRIVER_OPENWRT) { | 
|  | 3723 | wpa_command(dut->hostapd_ifname, "DPP_BOOTSTRAP_REMOVE *"); | 
|  | 3724 | wpa_command(dut->hostapd_ifname, "DPP_PKEX_REMOVE *"); | 
|  | 3725 | } | 
|  | 3726 |  | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3727 | /* Stop the AP */ | 
|  | 3728 | run_system(dut, "wifi down"); | 
|  | 3729 |  | 
|  | 3730 | /* Reset the wireless configuration */ | 
| Mohammed Shafi Shajakhan | f789f82 | 2016-04-07 18:53:16 +0530 | [diff] [blame] | 3731 | run_system(dut, "rm -rf /etc/config/wireless"); | 
|  | 3732 | switch (get_openwrt_driver_type()) { | 
|  | 3733 | case OPENWRT_DRIVER_ATHEROS: | 
|  | 3734 | run_system(dut, "wifi detect qcawifi > /etc/config/wireless"); | 
|  | 3735 | break; | 
|  | 3736 | default: | 
|  | 3737 | run_system(dut, "wifi detect > /etc/config/wireless"); | 
|  | 3738 | break; | 
|  | 3739 | } | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3740 |  | 
|  | 3741 | /* Configure Radio & VAP, commit the config */ | 
|  | 3742 | owrt_ap_config_radio(dut); | 
|  | 3743 | owrt_ap_config_vap(dut); | 
|  | 3744 | run_system(dut, "uci commit"); | 
|  | 3745 |  | 
|  | 3746 | /* Start AP */ | 
|  | 3747 | run_system(dut, "wifi up"); | 
| Adil Saeed Musthafa | a8d7484 | 2017-04-10 23:13:39 -0700 | [diff] [blame] | 3748 | if (dut->program != PROGRAM_MBO && | 
|  | 3749 | dut->ap_lci == 1 && dut->ap_interworking && | 
| Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 3750 | strlen(dut->ap_tag_ssid[0]) > 0) { | 
| Adil Saeed Musthafa | a8d7484 | 2017-04-10 23:13:39 -0700 | [diff] [blame] | 3751 | /* | 
|  | 3752 | * MBO has a different ANQP element value which is set in | 
|  | 3753 | * owrt_ap_config_vap(). | 
|  | 3754 | */ | 
| priyadharshini gowthaman | 2500f20 | 2016-10-13 17:13:55 -0700 | [diff] [blame] | 3755 | owrt_ap_config_vap_anqp(dut); | 
|  | 3756 | run_system(dut, "uci commit"); | 
|  | 3757 | run_system(dut, "wifi"); | 
|  | 3758 | } | 
|  | 3759 |  | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3760 | return owrt_ap_post_config_commit(dut, conn, cmd); | 
|  | 3761 | } | 
|  | 3762 |  | 
|  | 3763 |  | 
|  | 3764 | static void cmd_owrt_ap_hs2_reset(struct sigma_dut *dut) | 
|  | 3765 | { | 
|  | 3766 | unsigned char bssid[6]; | 
|  | 3767 | char buf[100]; | 
|  | 3768 | char *ifname, *radio_name; | 
|  | 3769 | int vap_id = 0; | 
|  | 3770 |  | 
|  | 3771 | if (sigma_radio_ifname[0] && | 
|  | 3772 | strcmp(sigma_radio_ifname[0], "wifi2") == 0) { | 
|  | 3773 | ifname = "ath2"; | 
|  | 3774 | radio_name = "wifi2"; | 
|  | 3775 | vap_id = 2; | 
|  | 3776 | } else if (sigma_radio_ifname[0] && | 
|  | 3777 | strcmp(sigma_radio_ifname[0], "wifi1") == 0) { | 
|  | 3778 | ifname = "ath1"; | 
|  | 3779 | radio_name = "wifi1"; | 
|  | 3780 | vap_id = 1; | 
|  | 3781 | } else { | 
|  | 3782 | ifname = "ath0"; | 
|  | 3783 | radio_name = "wifi0"; | 
|  | 3784 | vap_id = 0; | 
|  | 3785 | } | 
|  | 3786 |  | 
|  | 3787 | if (!get_hwaddr(ifname, bssid)) { | 
|  | 3788 | snprintf(buf, sizeof(buf), "%s", bssid); | 
|  | 3789 | owrt_ap_set_vap(dut, vap_id, "hessid", buf); | 
|  | 3790 | snprintf(dut->ap_hessid, sizeof(dut->ap_hessid), | 
|  | 3791 | "%02x:%02x:%02x:%02x:%02x:%02x", | 
|  | 3792 | bssid[0], bssid[1], bssid[2], bssid[3], | 
|  | 3793 | bssid[4], bssid[5]); | 
|  | 3794 | } else { | 
|  | 3795 | if (!get_hwaddr(radio_name, bssid)) { | 
|  | 3796 | snprintf(buf, sizeof(buf), "%s", dut->ap_hessid); | 
|  | 3797 | owrt_ap_set_vap(dut, vap_id, "hessid", buf); | 
|  | 3798 | snprintf(dut->ap_hessid, sizeof(dut->ap_hessid), | 
|  | 3799 | "%02x:%02x:%02x:%02x:%02x:%02x", | 
|  | 3800 | bssid[0], bssid[1], bssid[2], bssid[3], | 
|  | 3801 | bssid[4], bssid[5]); | 
|  | 3802 | } else { | 
|  | 3803 | /* Select & enable/disable radios */ | 
|  | 3804 | if (sigma_radio_ifname[0] && | 
|  | 3805 | strcmp(sigma_radio_ifname[0], "wifi2") == 0) { | 
|  | 3806 | /* We want to use wifi2 */ | 
|  | 3807 | owrt_ap_set_radio(dut, 0, "disabled", "1"); | 
|  | 3808 | owrt_ap_set_radio(dut, 1, "disabled", "1"); | 
|  | 3809 | owrt_ap_set_radio(dut, 2, "disabled", "0"); | 
|  | 3810 | owrt_ap_set_vap(dut, vap_id, "device", "wifi2"); | 
|  | 3811 | } else if (sigma_radio_ifname[0] && | 
|  | 3812 | strcmp(sigma_radio_ifname[0], "wifi1") == 0) { | 
|  | 3813 | /* We want to use wifi1 */ | 
|  | 3814 | owrt_ap_set_radio(dut, 0, "disabled", "1"); | 
|  | 3815 | owrt_ap_set_radio(dut, 1, "disabled", "0"); | 
|  | 3816 | owrt_ap_set_vap(dut, vap_id, "device", "wifi1"); | 
|  | 3817 | } else { | 
|  | 3818 | /* We want to use wifi0 */ | 
|  | 3819 | owrt_ap_set_radio(dut, 0, "disabled", "0"); | 
|  | 3820 | owrt_ap_set_radio(dut, 1, "disabled", "1"); | 
|  | 3821 | owrt_ap_set_vap(dut, vap_id, "device", "wifi0"); | 
|  | 3822 | } | 
|  | 3823 |  | 
|  | 3824 | run_system(dut, "uci commit"); | 
|  | 3825 | run_system(dut, "wifi up"); | 
|  | 3826 |  | 
|  | 3827 | if (!get_hwaddr(radio_name, bssid)) { | 
|  | 3828 | snprintf(buf, sizeof(buf), "%s", | 
|  | 3829 | dut->ap_hessid); | 
|  | 3830 | owrt_ap_set_vap(dut, vap_id, "hessid", buf); | 
|  | 3831 | snprintf(dut->ap_hessid, sizeof(dut->ap_hessid), | 
|  | 3832 | "%02x:%02x:%02x:%02x:%02x:%02x", | 
|  | 3833 | bssid[0], bssid[1], bssid[2], bssid[3], | 
|  | 3834 | bssid[4], bssid[5]); | 
|  | 3835 | } | 
|  | 3836 | } | 
|  | 3837 | } | 
|  | 3838 | } | 
|  | 3839 |  | 
|  | 3840 |  | 
|  | 3841 | static int cmd_ap_reboot(struct sigma_dut *dut, struct sigma_conn *conn, | 
|  | 3842 | struct sigma_cmd *cmd) | 
|  | 3843 | { | 
|  | 3844 | switch (get_driver_type()) { | 
|  | 3845 | case DRIVER_ATHEROS: | 
|  | 3846 | run_system(dut, "apdown"); | 
|  | 3847 | sleep(1); | 
|  | 3848 | run_system(dut, "reboot"); | 
|  | 3849 | break; | 
|  | 3850 | case DRIVER_OPENWRT: | 
|  | 3851 | run_system(dut, "wifi down"); | 
|  | 3852 | sleep(1); | 
|  | 3853 | run_system(dut, "reboot"); | 
|  | 3854 | break; | 
|  | 3855 | default: | 
|  | 3856 | sigma_dut_print(dut, DUT_MSG_INFO, "Ignore ap_reboot command"); | 
|  | 3857 | break; | 
|  | 3858 | } | 
|  | 3859 |  | 
|  | 3860 | return 1; | 
|  | 3861 | } | 
|  | 3862 |  | 
|  | 3863 |  | 
|  | 3864 | int ascii2hexstr(const char *str, char *hex) | 
|  | 3865 | { | 
|  | 3866 | int i, length; | 
|  | 3867 |  | 
|  | 3868 | length = strlen(str); | 
|  | 3869 |  | 
|  | 3870 | for (i = 0; i < length; i++) | 
|  | 3871 | snprintf(hex + i * 2, 3, "%X", str[i]); | 
|  | 3872 |  | 
|  | 3873 | hex[length * 2] = '\0'; | 
|  | 3874 | return 1; | 
|  | 3875 | } | 
|  | 3876 |  | 
|  | 3877 |  | 
|  | 3878 | static int kill_process(struct sigma_dut *dut, char *proc_name, | 
|  | 3879 | unsigned char is_proc_instance_one, int sig) | 
|  | 3880 | { | 
|  | 3881 | #ifdef __linux__ | 
|  | 3882 | struct dirent *dp, *dp_in; | 
|  | 3883 | const char *direc = "/proc/"; | 
|  | 3884 | char buf[100]; | 
|  | 3885 | DIR *dir = opendir(direc); | 
|  | 3886 | DIR *dir_in; | 
|  | 3887 | FILE *fp; | 
|  | 3888 | char *pid, *temp; | 
| Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 3889 | char *saveptr; | 
| Pradeep Reddy Potteti | d068e64 | 2017-02-17 20:03:12 +0530 | [diff] [blame] | 3890 | int ret = -1; | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3891 |  | 
|  | 3892 | if (dir == NULL) | 
| Pradeep Reddy Potteti | d068e64 | 2017-02-17 20:03:12 +0530 | [diff] [blame] | 3893 | return ret; | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3894 |  | 
|  | 3895 | while ((dp = readdir(dir)) != NULL) { | 
|  | 3896 | if (dp->d_type != DT_DIR) | 
|  | 3897 | continue; | 
|  | 3898 |  | 
|  | 3899 | snprintf(buf, sizeof(buf), "%s%s", direc, dp->d_name); | 
|  | 3900 | dir_in = opendir(buf); | 
|  | 3901 | if (dir_in == NULL) | 
|  | 3902 | continue; | 
|  | 3903 | dp_in = readdir(dir_in); | 
|  | 3904 | closedir(dir_in); | 
|  | 3905 | if (dp_in == NULL) | 
|  | 3906 | continue; | 
|  | 3907 | snprintf(buf, sizeof(buf), "%s%s/stat", direc, dp->d_name); | 
|  | 3908 | fp = fopen(buf, "r"); | 
|  | 3909 | if (fp == NULL) | 
|  | 3910 | continue; | 
|  | 3911 | if (fgets(buf, 100, fp) == NULL) | 
|  | 3912 | buf[0] = '\0'; | 
|  | 3913 | fclose(fp); | 
| Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 3914 | pid = strtok_r(buf, " ", &saveptr); | 
|  | 3915 | temp = strtok_r(NULL, " ", &saveptr); | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3916 | if (pid && temp && | 
|  | 3917 | strncmp(temp, proc_name, strlen(proc_name)) == 0) { | 
|  | 3918 | sigma_dut_print(dut, DUT_MSG_INFO, | 
|  | 3919 | "killing %s process with PID %s", | 
|  | 3920 | proc_name, pid); | 
|  | 3921 | snprintf(buf, sizeof(buf), "kill -%d %d", sig, | 
|  | 3922 | atoi(pid)); | 
|  | 3923 | run_system(dut, buf); | 
| Pradeep Reddy Potteti | d068e64 | 2017-02-17 20:03:12 +0530 | [diff] [blame] | 3924 | ret = 0; | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3925 | if (is_proc_instance_one) | 
|  | 3926 | break; | 
|  | 3927 | } | 
|  | 3928 | } | 
|  | 3929 |  | 
|  | 3930 | closedir(dir); | 
|  | 3931 |  | 
| Pradeep Reddy Potteti | d068e64 | 2017-02-17 20:03:12 +0530 | [diff] [blame] | 3932 | return ret; | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 3933 | #else /* __linux__ */ | 
|  | 3934 | return -1; | 
|  | 3935 | #endif /* __linux__ */ | 
|  | 3936 | } | 
|  | 3937 |  | 
|  | 3938 |  | 
|  | 3939 | static int run_ndc(struct sigma_dut *dut, char *buf) | 
|  | 3940 | { | 
|  | 3941 | sigma_dut_print(dut, DUT_MSG_INFO, "CMD NDC:: %s", buf); | 
|  | 3942 | sleep(2); | 
|  | 3943 | return run_system(dut, buf); | 
|  | 3944 | } | 
|  | 3945 |  | 
|  | 3946 |  | 
|  | 3947 | static int sigma_write_cfg(struct sigma_dut *dut, const char *pfile, | 
|  | 3948 | const char *field, const char *value) | 
|  | 3949 | { | 
|  | 3950 | FILE *fcfg, *ftmp; | 
|  | 3951 | char buf[MAX_CONF_LINE_LEN + 1]; | 
|  | 3952 | int len, found = 0, res; | 
|  | 3953 |  | 
|  | 3954 | /* Open the configuration file */ | 
|  | 3955 | fcfg = fopen(pfile, "r"); | 
|  | 3956 | if (!fcfg) { | 
|  | 3957 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 3958 | "Failed to open hostapd conf file"); | 
|  | 3959 | return -1; | 
|  | 3960 | } | 
|  | 3961 |  | 
|  | 3962 | snprintf(buf, sizeof(buf), "%s~", pfile); | 
|  | 3963 | /* Open a temporary file */ | 
|  | 3964 | ftmp = fopen(buf, "w+"); | 
|  | 3965 | if (!ftmp) { | 
|  | 3966 | fclose(fcfg); | 
|  | 3967 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 3968 | "Failed to open temp buf"); | 
|  | 3969 | return -1; | 
|  | 3970 | } | 
|  | 3971 |  | 
|  | 3972 | /* Read the values from the configuration file */ | 
|  | 3973 | len = strlen(field); | 
|  | 3974 | while (fgets(buf, MAX_CONF_LINE_LEN, fcfg)) { | 
|  | 3975 | char *pline = buf; | 
|  | 3976 |  | 
|  | 3977 | /* commented line */ | 
|  | 3978 | if (buf[0] == '#') | 
|  | 3979 | pline++; | 
|  | 3980 |  | 
|  | 3981 | /* Identify the configuration parameter to be updated */ | 
|  | 3982 | if (!found && strncmp(pline, field, len) == 0 && | 
|  | 3983 | pline[len] == '=') { | 
|  | 3984 | snprintf(buf, sizeof(buf), "%s=%s\n", field, value); | 
|  | 3985 | found = 1; | 
|  | 3986 | sigma_dut_print(dut, DUT_MSG_INFO, | 
|  | 3987 | "Updated hostapd conf file"); | 
|  | 3988 | } | 
|  | 3989 |  | 
|  | 3990 | fprintf(ftmp, "%s", buf); | 
|  | 3991 | } | 
|  | 3992 |  | 
|  | 3993 | if (!found) { | 
|  | 3994 | /* Configuration line not found */ | 
|  | 3995 | /* Add the new line at the end of file */ | 
|  | 3996 | fprintf(ftmp, "%s=%s\n", field, value); | 
|  | 3997 | sigma_dut_print(dut, DUT_MSG_INFO, | 
|  | 3998 | "Adding a new line in hostapd conf file"); | 
|  | 3999 | } | 
|  | 4000 |  | 
|  | 4001 | fclose(fcfg); | 
|  | 4002 | fclose(ftmp); | 
|  | 4003 |  | 
|  | 4004 | snprintf(buf, sizeof(buf), "%s~", pfile); | 
|  | 4005 |  | 
|  | 4006 | /* Restore the updated configuration file */ | 
|  | 4007 | res = rename(buf, pfile); | 
|  | 4008 |  | 
|  | 4009 | /* Remove the temporary file. Ignore the return value */ | 
|  | 4010 | unlink(buf); | 
|  | 4011 |  | 
|  | 4012 | /* chmod is needed because open() may not set permissions properly | 
|  | 4013 | * depending on the current umask */ | 
|  | 4014 | if (chmod(pfile, 0660) < 0) { | 
|  | 4015 | unlink(pfile); | 
|  | 4016 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 4017 | "Error changing permissions"); | 
|  | 4018 | return -1; | 
|  | 4019 | } | 
|  | 4020 |  | 
|  | 4021 | if (res < 0) { | 
|  | 4022 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 4023 | "Error restoring conf file"); | 
|  | 4024 | return -1; | 
|  | 4025 | } | 
|  | 4026 |  | 
|  | 4027 | return 0; | 
|  | 4028 | } | 
|  | 4029 |  | 
|  | 4030 |  | 
|  | 4031 | static int cmd_wcn_ap_config_commit(struct sigma_dut *dut, | 
|  | 4032 | struct sigma_conn *conn, | 
|  | 4033 | struct sigma_cmd *cmd) | 
|  | 4034 | { | 
|  | 4035 | char buf[100]; | 
|  | 4036 | struct stat s; | 
|  | 4037 | int num_tries = 0, ret; | 
|  | 4038 |  | 
| Pradeep Reddy Potteti | d068e64 | 2017-02-17 20:03:12 +0530 | [diff] [blame] | 4039 | if (kill_process(dut, "(netd)", 1, SIGKILL) == 0 || | 
|  | 4040 | system("killall netd") == 0) { | 
|  | 4041 | /* Avoid Error: Error connecting (Connection refused) | 
|  | 4042 | * Wait some time to allow netd to reinitialize. | 
|  | 4043 | */ | 
|  | 4044 | usleep(1500000); | 
|  | 4045 | } | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4046 |  | 
|  | 4047 | while (num_tries < 10) { | 
|  | 4048 | ret = run_ndc(dut, "ndc softap stopap"); | 
|  | 4049 | num_tries++; | 
|  | 4050 | if (WIFEXITED(ret)) | 
|  | 4051 | ret = WEXITSTATUS(ret); | 
|  | 4052 | /* On success, NDC exits with 0 */ | 
|  | 4053 | if (ret == 0) | 
|  | 4054 | break; | 
|  | 4055 | sigma_dut_print(dut, DUT_MSG_INFO, | 
|  | 4056 | "Try No. %d: ndc softap stopap failed, exit code %d", | 
|  | 4057 | num_tries, ret); | 
|  | 4058 | } | 
|  | 4059 |  | 
|  | 4060 | if (ret != 0) | 
|  | 4061 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 4062 | "ndc softap stopap command failed for 10 times - giving up"); | 
|  | 4063 |  | 
|  | 4064 | #ifdef ANDROID | 
|  | 4065 | /* Unload/Load driver to cleanup the state of the driver */ | 
| Ajit Vaishya | 14d1f9a | 2017-09-04 23:24:25 +0530 | [diff] [blame] | 4066 | system("rmmod -f wlan"); | 
|  | 4067 | usleep(500000); | 
|  | 4068 | system("insmod /system/lib/modules/wlan.ko"); | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4069 | #else /* ANDROID */ | 
|  | 4070 | run_ndc(dut, "ndc softap qccmd set enable_softap=0"); | 
|  | 4071 | run_ndc(dut, "ndc softap qccmd set enable_softap=1"); | 
|  | 4072 | #endif /* ANDROID */ | 
|  | 4073 |  | 
|  | 4074 | switch (dut->ap_mode) { | 
|  | 4075 | case AP_11g: | 
|  | 4076 | run_ndc(dut, "ndc softap qccmd set hw_mode=g-only"); | 
|  | 4077 | break; | 
|  | 4078 | case AP_11b: | 
|  | 4079 | run_ndc(dut, "ndc softap qccmd set hw_mode=b-only"); | 
|  | 4080 | break; | 
|  | 4081 | case AP_11ng: | 
|  | 4082 | run_ndc(dut, "ndc softap qccmd set hw_mode=n"); | 
|  | 4083 | break; | 
|  | 4084 | case AP_11a: | 
|  | 4085 | run_ndc(dut, "ndc softap qccmd set hw_mode=a-only"); | 
|  | 4086 | break; | 
|  | 4087 | case AP_11na: | 
|  | 4088 | run_ndc(dut, "ndc softap qccmd set hw_mode=n"); | 
|  | 4089 | break; | 
|  | 4090 | case AP_11ac: | 
|  | 4091 | run_ndc(dut, "ndc softap qccmd set hw_mode=ac"); | 
|  | 4092 | break; | 
|  | 4093 | default: | 
|  | 4094 | break; | 
|  | 4095 | } | 
|  | 4096 |  | 
|  | 4097 | snprintf(buf, sizeof(buf), "ndc softap qccmd set channel=%d", | 
|  | 4098 | dut->ap_channel); | 
|  | 4099 | run_ndc(dut, buf); | 
|  | 4100 |  | 
|  | 4101 | /* | 
|  | 4102 | * ndc doesn't support double quotes as SSID string, so re-write | 
|  | 4103 | * hostapd configuration file to update SSID. | 
|  | 4104 | */ | 
|  | 4105 | if (dut->ap_ssid[0] != '\0') | 
|  | 4106 | sigma_write_cfg(dut, ANDROID_CONFIG_FILE, "ssid", dut->ap_ssid); | 
|  | 4107 |  | 
|  | 4108 | switch (dut->ap_key_mgmt) { | 
|  | 4109 | case AP_OPEN: | 
|  | 4110 | if (dut->ap_cipher == AP_WEP) { | 
|  | 4111 | run_ndc(dut, "ndc softap qccmd set security_mode=1"); | 
|  | 4112 | snprintf(buf, sizeof(buf), | 
|  | 4113 | "ndc softap qccmd set wep_key0=%s", | 
|  | 4114 | dut->ap_wepkey); | 
|  | 4115 | run_ndc(dut, buf); | 
|  | 4116 | } else { | 
|  | 4117 | run_ndc(dut, "ndc softap qccmd set security_mode=0"); | 
|  | 4118 | } | 
|  | 4119 | break; | 
|  | 4120 | case AP_WPA2_PSK: | 
|  | 4121 | case AP_WPA2_PSK_MIXED: | 
|  | 4122 | case AP_WPA_PSK: | 
|  | 4123 | if (dut->ap_key_mgmt == AP_WPA2_PSK) | 
|  | 4124 | run_ndc(dut, "ndc softap qccmd set security_mode=3"); | 
|  | 4125 | else if (dut->ap_key_mgmt == AP_WPA2_PSK_MIXED) | 
|  | 4126 | run_ndc(dut, "ndc softap qccmd set security_mode=4"); | 
|  | 4127 | else | 
|  | 4128 | run_ndc(dut, "ndc softap qccmd set security_mode=2"); | 
|  | 4129 |  | 
|  | 4130 | /* | 
|  | 4131 | * ndc doesn't support some special characters as passphrase, | 
|  | 4132 | * so re-write hostapd configuration file to update Passphrase. | 
|  | 4133 | */ | 
|  | 4134 | if (dut->ap_passphrase[0] != '\0') | 
|  | 4135 | sigma_write_cfg(dut, ANDROID_CONFIG_FILE, | 
|  | 4136 | "wpa_passphrase", dut->ap_passphrase); | 
|  | 4137 |  | 
|  | 4138 | if (dut->ap_cipher == AP_CCMP_TKIP) | 
|  | 4139 | run_ndc(dut, "ndc softap qccmd set wpa_pairwise=" | 
|  | 4140 | "TKIP CCMP"); | 
|  | 4141 | else if (dut->ap_cipher == AP_TKIP) | 
|  | 4142 | run_ndc(dut, "ndc softap qccmd set wpa_pairwise=" | 
|  | 4143 | "TKIP"); | 
|  | 4144 | else | 
|  | 4145 | run_ndc(dut, "ndc softap qccmd set wpa_pairwise=" | 
|  | 4146 | "CCMP &"); | 
|  | 4147 | break; | 
| Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 4148 | case AP_WPA2_SAE: | 
|  | 4149 | case AP_WPA2_PSK_SAE: | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4150 | case AP_WPA2_EAP: | 
|  | 4151 | case AP_WPA2_EAP_MIXED: | 
|  | 4152 | case AP_WPA_EAP: | 
| Jouni Malinen | ad395a2 | 2017-09-01 21:13:46 +0300 | [diff] [blame] | 4153 | case AP_SUITEB: | 
| Jouni Malinen | 147b3c3 | 2017-10-09 16:51:54 +0300 | [diff] [blame] | 4154 | case AP_WPA2_OWE: | 
| Jouni Malinen | 4cf699f | 2018-06-19 00:46:27 +0300 | [diff] [blame] | 4155 | case AP_WPA2_EAP_OSEN: | 
| Jouni Malinen | c2b9121 | 2018-09-12 02:26:39 +0300 | [diff] [blame] | 4156 | case AP_OSEN: | 
| Jouni Malinen | 6be21c8 | 2018-08-01 18:47:24 +0300 | [diff] [blame] | 4157 | case AP_WPA2_FT_EAP: | 
|  | 4158 | case AP_WPA2_FT_PSK: | 
|  | 4159 | case AP_WPA2_EAP_SHA256: | 
|  | 4160 | case AP_WPA2_PSK_SHA256: | 
|  | 4161 | case AP_WPA2_ENT_FT_EAP: | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4162 | /* Not supported */ | 
|  | 4163 | break; | 
|  | 4164 | } | 
|  | 4165 |  | 
|  | 4166 | switch (dut->ap_pmf) { | 
|  | 4167 | case AP_PMF_DISABLED: | 
|  | 4168 | run_ndc(dut, "ndc softap qccmd set ieee80211w=0"); | 
|  | 4169 | break; | 
|  | 4170 | case AP_PMF_OPTIONAL: | 
|  | 4171 | run_ndc(dut, "ndc softap qccmd set ieee80211w=1"); | 
|  | 4172 | if (dut->ap_add_sha256) | 
|  | 4173 | run_ndc(dut, "ndc softap qccmd set wpa_key_mgmt=WPA-PSK WPA-PSK-SHA256"); | 
|  | 4174 | else | 
|  | 4175 | run_ndc(dut, "ndc softap qccmd set wpa_key_mgmt=WPA-PSK"); | 
|  | 4176 | break; | 
|  | 4177 | case AP_PMF_REQUIRED: | 
|  | 4178 | run_ndc(dut, "ndc softap qccmd set ieee80211w=2"); | 
|  | 4179 | run_ndc(dut, "ndc softap qccmd set wpa_key_mgmt=WPA-PSK-SHA256"); | 
|  | 4180 | break; | 
|  | 4181 | } | 
|  | 4182 |  | 
|  | 4183 | if (dut->ap_countrycode[0]) { | 
|  | 4184 | snprintf(buf, sizeof(buf), | 
|  | 4185 | "ndc softap qccmd set country_code=%s", | 
|  | 4186 | dut->ap_countrycode); | 
|  | 4187 | run_ndc(dut, buf); | 
|  | 4188 | } | 
|  | 4189 |  | 
| Pradeep Reddy POTTETI | fba27db | 2015-11-20 16:42:22 +0530 | [diff] [blame] | 4190 | if (dut->ap_regulatory_mode == AP_80211D_MODE_ENABLED) | 
|  | 4191 | run_ndc(dut, "ndc softap qccmd set ieee80211d=1"); | 
|  | 4192 |  | 
|  | 4193 | if (dut->ap_dfs_mode == AP_DFS_MODE_ENABLED) | 
|  | 4194 | run_ndc(dut, "ndc softap qccmd set ieee80211h=1"); | 
|  | 4195 |  | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4196 | run_ndc(dut, "ndc softap startap"); | 
|  | 4197 |  | 
|  | 4198 | snprintf(buf, sizeof(buf), "%s%s", sigma_wpas_ctrl, sigma_main_ifname); | 
|  | 4199 | num_tries = 0; | 
|  | 4200 | while (num_tries < 10 && (ret = stat(buf, &s) != 0)) { | 
|  | 4201 | run_ndc(dut, "ndc softap stopap"); | 
|  | 4202 | run_ndc(dut, "ndc softap startap"); | 
|  | 4203 | num_tries++; | 
|  | 4204 | } | 
|  | 4205 |  | 
|  | 4206 | if (num_tries == 10) { | 
|  | 4207 | sigma_dut_print(dut, DUT_MSG_INFO, "Tried 10 times with ctrl " | 
|  | 4208 | "iface %s :: reboot the APDUT", buf); | 
|  | 4209 | return ret; | 
|  | 4210 | } | 
|  | 4211 |  | 
|  | 4212 | sigma_dut_print(dut, DUT_MSG_INFO, "setting ip addr %s mask %s", | 
|  | 4213 | ap_inet_addr, ap_inet_mask); | 
|  | 4214 | snprintf(buf, sizeof(buf), "ifconfig %s %s netmask %s up", | 
|  | 4215 | sigma_main_ifname, ap_inet_addr, ap_inet_mask); | 
|  | 4216 | if (system(buf) != 0) { | 
|  | 4217 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 4218 | "Failed to intialize the interface"); | 
|  | 4219 | return -1; | 
|  | 4220 | } | 
|  | 4221 |  | 
|  | 4222 | return 1; | 
|  | 4223 | } | 
|  | 4224 |  | 
|  | 4225 |  | 
|  | 4226 | static int append_hostapd_conf_hs2(struct sigma_dut *dut, FILE *f) | 
|  | 4227 | { | 
|  | 4228 | fprintf(f, "hs20=1\nhs20_deauth_req_timeout=3\n" | 
|  | 4229 | "disable_dgaf=%d\n", dut->ap_dgaf_disable); | 
|  | 4230 |  | 
|  | 4231 | if (dut->ap_oper_name) { | 
|  | 4232 | fprintf(f, "hs20_oper_friendly_name=eng:Wi-Fi Alliance\n"); | 
|  | 4233 | fprintf(f, "hs20_oper_friendly_name=chi:Wi-Fi\xe8\x81\x94\xe7\x9b\x9f\n"); | 
|  | 4234 | } | 
|  | 4235 |  | 
|  | 4236 | if (dut->ap_wan_metrics == 1) | 
|  | 4237 | fprintf(f, "hs20_wan_metrics=01:2500:384:0:0:10\n"); | 
|  | 4238 | else if (dut->ap_wan_metrics == 2) | 
|  | 4239 | fprintf(f, "hs20_wan_metrics=01:1500:384:20:20:10\n"); | 
|  | 4240 | else if (dut->ap_wan_metrics == 3) | 
|  | 4241 | fprintf(f, "hs20_wan_metrics=01:2000:1000:20:20:10\n"); | 
|  | 4242 | else if (dut->ap_wan_metrics == 4) | 
|  | 4243 | fprintf(f, "hs20_wan_metrics=01:8000:1000:20:20:10\n"); | 
|  | 4244 | else if (dut->ap_wan_metrics == 5) | 
|  | 4245 | fprintf(f, "hs20_wan_metrics=01:9000:5000:20:20:10\n"); | 
|  | 4246 |  | 
|  | 4247 | if (dut->ap_conn_capab == 1) { | 
|  | 4248 | fprintf(f, "hs20_conn_capab=1:0:0\n"); | 
|  | 4249 | fprintf(f, "hs20_conn_capab=6:20:1\n"); | 
|  | 4250 | fprintf(f, "hs20_conn_capab=6:22:0\n"); | 
|  | 4251 | fprintf(f, "hs20_conn_capab=6:80:1\n"); | 
|  | 4252 | fprintf(f, "hs20_conn_capab=6:443:1\n"); | 
|  | 4253 | fprintf(f, "hs20_conn_capab=6:1723:0\n"); | 
|  | 4254 | fprintf(f, "hs20_conn_capab=6:5060:0\n"); | 
|  | 4255 | fprintf(f, "hs20_conn_capab=17:500:1\n"); | 
|  | 4256 | fprintf(f, "hs20_conn_capab=17:5060:0\n"); | 
|  | 4257 | fprintf(f, "hs20_conn_capab=17:4500:1\n"); | 
|  | 4258 | fprintf(f, "hs20_conn_capab=50:0:1\n"); | 
|  | 4259 | } else if (dut->ap_conn_capab == 2) { | 
|  | 4260 | fprintf(f, "hs20_conn_capab=6:80:1\n"); | 
|  | 4261 | fprintf(f, "hs20_conn_capab=6:443:1\n"); | 
|  | 4262 | fprintf(f, "hs20_conn_capab=17:5060:1\n"); | 
|  | 4263 | fprintf(f, "hs20_conn_capab=6:5060:1\n"); | 
|  | 4264 | } else if (dut->ap_conn_capab == 3) { | 
|  | 4265 | fprintf(f, "hs20_conn_capab=6:80:1\n"); | 
|  | 4266 | fprintf(f, "hs20_conn_capab=6:443:1\n"); | 
|  | 4267 | } else if (dut->ap_conn_capab == 4) { | 
|  | 4268 | fprintf(f, "hs20_conn_capab=6:80:1\n"); | 
|  | 4269 | fprintf(f, "hs20_conn_capab=6:443:1\n"); | 
|  | 4270 | fprintf(f, "hs20_conn_capab=6:5060:1\n"); | 
|  | 4271 | fprintf(f, "hs20_conn_capab=17:5060:1\n"); | 
|  | 4272 | } | 
|  | 4273 |  | 
|  | 4274 | if (dut->ap_oper_class == 1) | 
|  | 4275 | fprintf(f, "hs20_operating_class=51\n"); | 
|  | 4276 | else if (dut->ap_oper_class == 2) | 
|  | 4277 | fprintf(f, "hs20_operating_class=73\n"); | 
|  | 4278 | else if (dut->ap_oper_class == 3) | 
|  | 4279 | fprintf(f, "hs20_operating_class=5173\n"); | 
|  | 4280 |  | 
|  | 4281 | if (dut->ap_osu_provider_list) { | 
|  | 4282 | char *osu_friendly_name = NULL; | 
|  | 4283 | char *osu_icon = NULL; | 
|  | 4284 | char *osu_ssid = NULL; | 
|  | 4285 | char *osu_nai = NULL; | 
| Jouni Malinen | 93a837f | 2018-11-01 17:09:22 +0200 | [diff] [blame] | 4286 | char *osu_nai2 = NULL; | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4287 | char *osu_service_desc = NULL; | 
|  | 4288 | char *hs20_icon_filename = NULL; | 
|  | 4289 | char hs20_icon[150]; | 
|  | 4290 | int osu_method; | 
|  | 4291 |  | 
|  | 4292 | hs20_icon_filename = "icon_red_zxx.png"; | 
|  | 4293 | if (dut->ap_osu_icon_tag == 2) | 
|  | 4294 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; | 
|  | 4295 | snprintf(hs20_icon, sizeof(hs20_icon), | 
|  | 4296 | "128:61:zxx:image/png:icon_red_zxx.png:/etc/ath/%s", | 
|  | 4297 | hs20_icon_filename); | 
|  | 4298 | osu_icon = "icon_red_zxx.png"; | 
|  | 4299 | osu_ssid = "OSU"; | 
|  | 4300 | osu_friendly_name = "kor:SP 빨강 테스트 전용"; | 
|  | 4301 | osu_service_desc = "kor:테스트 목적으로 무료 서비스"; | 
|  | 4302 | osu_method = (dut->ap_osu_method[0] == 0xFF) ? 1 : dut->ap_osu_method[0]; | 
|  | 4303 |  | 
|  | 4304 | if (strlen(dut->ap_osu_server_uri[0])) | 
|  | 4305 | fprintf(f, "osu_server_uri=%s\n", dut->ap_osu_server_uri[0]); | 
|  | 4306 | else | 
|  | 4307 | fprintf(f, "osu_server_uri=https://osu-server.r2-testbed.wi-fi.org/\n"); | 
|  | 4308 |  | 
|  | 4309 | switch (dut->ap_osu_provider_list) { | 
|  | 4310 | case 1: | 
|  | 4311 | case 101: | 
|  | 4312 | fprintf(f, "osu_friendly_name=eng:SP Red Test Only\n"); | 
|  | 4313 | fprintf(f, "osu_service_desc=eng:Free service for test purpose\n"); | 
|  | 4314 | hs20_icon_filename = "icon_red_eng.png"; | 
|  | 4315 | if (dut->ap_osu_icon_tag == 2) | 
|  | 4316 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; | 
|  | 4317 | fprintf(f, "hs20_icon=160:76:eng:image/png:icon_red_eng.png:/etc/ath/%s\n", | 
|  | 4318 | hs20_icon_filename); | 
|  | 4319 | fprintf(f, "osu_icon=icon_red_eng.png\n"); | 
|  | 4320 | break; | 
|  | 4321 | case 2: | 
|  | 4322 | case 102: | 
|  | 4323 | fprintf(f, "osu_friendly_name=eng:Wireless Broadband Alliance\n"); | 
|  | 4324 | fprintf(f, "osu_service_desc=eng:Free service for test purpose\n"); | 
|  | 4325 | hs20_icon_filename = "icon_orange_zxx.png"; | 
|  | 4326 | if (dut->ap_osu_icon_tag == 2) | 
|  | 4327 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; | 
|  | 4328 | snprintf(hs20_icon, sizeof(hs20_icon), | 
|  | 4329 | "128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/%s", | 
|  | 4330 | hs20_icon_filename); | 
|  | 4331 | osu_icon = "icon_orange_zxx.png"; | 
|  | 4332 | osu_friendly_name = "kor:와이어리스 브로드밴드 얼라이언스"; | 
|  | 4333 | break; | 
|  | 4334 | case 3: | 
|  | 4335 | case 103: | 
|  | 4336 | osu_friendly_name = "spa:SP Red Test Only"; | 
|  | 4337 | osu_service_desc = "spa:Free service for test purpose"; | 
|  | 4338 | break; | 
|  | 4339 | case 4: | 
|  | 4340 | case 104: | 
|  | 4341 | fprintf(f, "osu_friendly_name=eng:SP Orange Test Only\n"); | 
|  | 4342 | fprintf(f, "osu_service_desc=eng:Free service for test purpose\n"); | 
|  | 4343 | hs20_icon_filename = "icon_orange_eng.png"; | 
|  | 4344 | if (dut->ap_osu_icon_tag == 2) | 
|  | 4345 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; | 
|  | 4346 | fprintf(f, "hs20_icon=160:76:eng:image/png:icon_orange_eng.png:/etc/ath/%s\n", | 
|  | 4347 | hs20_icon_filename); | 
|  | 4348 | fprintf(f, "osu_icon=icon_orange_eng.png\n"); | 
|  | 4349 | osu_friendly_name = "kor:SP 오렌지 테스트 전용"; | 
|  | 4350 |  | 
|  | 4351 | hs20_icon_filename = "icon_orange_zxx.png"; | 
|  | 4352 | if (dut->ap_osu_icon_tag == 2) | 
|  | 4353 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; | 
|  | 4354 | snprintf(hs20_icon, sizeof(hs20_icon), | 
|  | 4355 | "128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/%s", | 
|  | 4356 | hs20_icon_filename); | 
|  | 4357 | osu_icon = "icon_orange_zxx.png"; | 
|  | 4358 | break; | 
|  | 4359 | case 5: | 
|  | 4360 | case 105: | 
|  | 4361 | fprintf(f, "osu_friendly_name=eng:SP Orange Test Only\n"); | 
|  | 4362 | fprintf(f, "osu_service_desc=eng:Free service for test purpose\n"); | 
|  | 4363 | osu_friendly_name = "kor:SP 오렌지 테스트 전용"; | 
|  | 4364 | hs20_icon_filename = "icon_orange_zxx.png"; | 
|  | 4365 | if (dut->ap_osu_icon_tag == 2) | 
|  | 4366 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; | 
|  | 4367 | snprintf(hs20_icon, sizeof(hs20_icon), | 
|  | 4368 | "128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/%s", | 
|  | 4369 | hs20_icon_filename); | 
|  | 4370 | osu_icon = "icon_orange_zxx.png"; | 
|  | 4371 | break; | 
|  | 4372 | case 6: | 
|  | 4373 | case 106: | 
|  | 4374 | fprintf(f, "osu_friendly_name=eng:SP Green Test Only\n"); | 
|  | 4375 | fprintf(f, "osu_friendly_name=kor:SP 초록 테스트 전용\n"); | 
|  | 4376 | hs20_icon_filename = "icon_green_zxx.png"; | 
|  | 4377 | if (dut->ap_osu_icon_tag == 2) | 
|  | 4378 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; | 
|  | 4379 | fprintf(f, "hs20_icon=128:61:zxx:image/png:icon_green_zxx.png:/etc/ath/%s\n", | 
|  | 4380 | hs20_icon_filename); | 
|  | 4381 | fprintf(f, "osu_icon=icon_green_zxx.png\n"); | 
|  | 4382 | osu_method = (dut->ap_osu_method[0] == 0xFF) ? 0 : dut->ap_osu_method[0]; | 
|  | 4383 | fprintf(f, "osu_method_list=%d\n", osu_method); | 
|  | 4384 |  | 
|  | 4385 | if (strlen(dut->ap_osu_server_uri[1])) | 
|  | 4386 | fprintf(f, "osu_server_uri=%s\n", dut->ap_osu_server_uri[1]); | 
|  | 4387 | else | 
|  | 4388 | fprintf(f, "osu_server_uri=https://osu-server.r2-testbed.wi-fi.org/\n"); | 
|  | 4389 | fprintf(f, "osu_friendly_name=eng:SP Orange Test Only\n"); | 
|  | 4390 | hs20_icon_filename = "icon_orange_zxx.png"; | 
|  | 4391 | if (dut->ap_osu_icon_tag == 2) | 
|  | 4392 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; | 
|  | 4393 | snprintf(hs20_icon, sizeof(hs20_icon), | 
|  | 4394 | "128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/%s", | 
|  | 4395 | hs20_icon_filename); | 
|  | 4396 | osu_icon = "icon_orange_zxx.png"; | 
|  | 4397 | osu_friendly_name = "kor:SP 오렌지 테스트 전용"; | 
|  | 4398 | osu_method = (dut->ap_osu_method[1] == 0xFF) ? 0 : dut->ap_osu_method[1]; | 
|  | 4399 | osu_service_desc = NULL; | 
|  | 4400 | break; | 
|  | 4401 | case 7: | 
|  | 4402 | case 107: | 
|  | 4403 | fprintf(f, "osu_friendly_name=eng:SP Green Test Only\n"); | 
|  | 4404 | fprintf(f, "osu_service_desc=eng:Free service for test purpose\n"); | 
|  | 4405 | hs20_icon_filename = "icon_green_eng.png"; | 
|  | 4406 | if (dut->ap_osu_icon_tag == 2) | 
|  | 4407 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; | 
|  | 4408 | fprintf(f, "hs20_icon=160:76:eng:image/png:icon_green_eng.png:/etc/ath/%s\n", | 
|  | 4409 | hs20_icon_filename); | 
|  | 4410 | fprintf(f, "osu_icon=icon_green_eng.png\n"); | 
|  | 4411 | osu_friendly_name = "kor:SP 초록 테스트 전용"; | 
|  | 4412 |  | 
|  | 4413 | hs20_icon_filename = "icon_green_zxx.png"; | 
|  | 4414 | if (dut->ap_osu_icon_tag == 2) | 
|  | 4415 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; | 
|  | 4416 | snprintf(hs20_icon, sizeof(hs20_icon), | 
|  | 4417 | "128:61:zxx:image/png:icon_green_zxx.png:/etc/ath/%s", | 
|  | 4418 | hs20_icon_filename); | 
|  | 4419 | osu_icon = "icon_green_zxx.png"; | 
|  | 4420 | break; | 
|  | 4421 | case 8: | 
|  | 4422 | case 108: | 
|  | 4423 | fprintf(f, "osu_friendly_name=eng:SP Red Test Only\n"); | 
|  | 4424 | fprintf(f, "osu_service_desc=eng:Free service for test purpose\n"); | 
|  | 4425 | osu_ssid = "OSU-Encrypted"; | 
|  | 4426 | osu_nai = "anonymous@hotspot.net"; | 
|  | 4427 | break; | 
|  | 4428 | case 9: | 
|  | 4429 | case 109: | 
|  | 4430 | osu_ssid = "OSU-OSEN"; | 
|  | 4431 | osu_nai = "test-anonymous@wi-fi.org"; | 
|  | 4432 | osu_friendly_name = "eng:SP Orange Test Only"; | 
|  | 4433 | hs20_icon_filename = "icon_orange_zxx.png"; | 
|  | 4434 | if (dut->ap_osu_icon_tag == 2) | 
|  | 4435 | hs20_icon_filename = "wifi-abgn-logo_270x73.png"; | 
|  | 4436 | snprintf(hs20_icon, sizeof(hs20_icon), | 
|  | 4437 | "128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/%s", | 
|  | 4438 | hs20_icon_filename); | 
|  | 4439 | osu_icon = "icon_orange_zxx.png"; | 
|  | 4440 | osu_method = (dut->ap_osu_method[0] == 0xFF) ? 1 : dut->ap_osu_method[0]; | 
|  | 4441 | osu_service_desc = NULL; | 
|  | 4442 | break; | 
| Jouni Malinen | 93a837f | 2018-11-01 17:09:22 +0200 | [diff] [blame] | 4443 | case 10: | 
|  | 4444 | case 110: | 
|  | 4445 | /* OSU Provider #1 */ | 
|  | 4446 | fprintf(f, "osu_friendly_name=eng:SP Orange Test Only\n"); | 
|  | 4447 | fprintf(f, "osu_friendly_name=kor:SP 오렌지 테스트 전용\n"); | 
|  | 4448 | fprintf(f, "hs20_icon=128:61:zxx:image/png:icon_orange_zxx.png:/etc/ath/icon_orange_zxx.png\n"); | 
|  | 4449 | fprintf(f, "osu_icon=icon_orange_zxx.png\n"); | 
|  | 4450 | osu_method = (dut->ap_osu_method[0] == 0xFF) ? | 
|  | 4451 | 1 : dut->ap_osu_method[0]; | 
|  | 4452 | fprintf(f, "osu_method_list=%d\n", osu_method); | 
|  | 4453 | fprintf(f, "osu_nai=test-anonymous@wi-fi.org\n"); | 
|  | 4454 | switch (dut->ap_osu_provider_nai_list) { | 
|  | 4455 | case 3: | 
|  | 4456 | fprintf(f, | 
|  | 4457 | "osu_nai2=test-anonymous@wi-fi.org\n"); | 
|  | 4458 | break; | 
|  | 4459 | case 4: | 
|  | 4460 | fprintf(f, "osu_nai2=random@hotspot.net\n"); | 
|  | 4461 | break; | 
|  | 4462 | } | 
|  | 4463 |  | 
|  | 4464 | /* OSU Provider #2 */ | 
|  | 4465 | /* SP Red from defaults */ | 
|  | 4466 | if (strlen(dut->ap_osu_server_uri[1])) | 
|  | 4467 | fprintf(f, "osu_server_uri=%s\n", dut->ap_osu_server_uri[1]); | 
|  | 4468 | else | 
|  | 4469 | fprintf(f, "osu_server_uri=https://osu-server.r2-testbed.wi-fi.org/\n"); | 
|  | 4470 | fprintf(f, "osu_friendly_name=eng:SP Red Test Only\n"); | 
|  | 4471 | snprintf(hs20_icon, sizeof(hs20_icon), | 
|  | 4472 | "128:61:zxx:image/png:icon_red_zxx.png:/etc/ath/icon_red_zxx.png"); | 
|  | 4473 | osu_method = (dut->ap_osu_method[1] == 0xFF) ? | 
|  | 4474 | 1 : dut->ap_osu_method[1]; | 
|  | 4475 | osu_service_desc = NULL; | 
|  | 4476 | osu_nai = "anonymous@hotspot.net"; | 
|  | 4477 | break; | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4478 | default: | 
|  | 4479 | break; | 
|  | 4480 | } | 
|  | 4481 |  | 
| Jouni Malinen | 93a837f | 2018-11-01 17:09:22 +0200 | [diff] [blame] | 4482 | switch (dut->ap_osu_provider_nai_list) { | 
|  | 4483 | case 1: | 
|  | 4484 | osu_nai2 = "anonymous@hotspot.net"; | 
|  | 4485 | break; | 
|  | 4486 | case 2: | 
|  | 4487 | osu_nai2 = "test-anonymous@wi-fi.org"; | 
|  | 4488 | break; | 
|  | 4489 | case 3: | 
|  | 4490 | /* OSU Provider NAI #1 written above */ | 
|  | 4491 | /* OSU Provider NAI #2 */ | 
|  | 4492 | osu_nai2 = "anonymous@hotspot.net"; | 
|  | 4493 | break; | 
|  | 4494 | case 4: | 
|  | 4495 | /* OSU Provider NAI #1 written above */ | 
|  | 4496 | /* OSU Provider NAI #2 */ | 
|  | 4497 | osu_nai2 = "anonymous@hotspot.net"; | 
|  | 4498 | break; | 
|  | 4499 | } | 
|  | 4500 |  | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4501 | if (strlen(dut->ap_osu_ssid)) { | 
| Jouni Malinen | e6ac6a0 | 2018-09-11 02:40:17 +0300 | [diff] [blame] | 4502 | if (dut->ap_tag_ssid[0][0] && | 
|  | 4503 | strcmp(dut->ap_tag_ssid[0], dut->ap_osu_ssid) && | 
| Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 4504 | strcmp(dut->ap_tag_ssid[0], osu_ssid)) { | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4505 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 4506 | "OSU_SSID and " | 
|  | 4507 | "WLAN_TAG2 SSID differ"); | 
|  | 4508 | return -2; | 
|  | 4509 | } | 
|  | 4510 | fprintf(f, "osu_ssid=\"%s\"\n", dut->ap_osu_ssid); | 
|  | 4511 | } else | 
|  | 4512 | fprintf(f, "osu_ssid=\"%s\"\n", osu_ssid); | 
|  | 4513 |  | 
|  | 4514 |  | 
|  | 4515 | if (osu_friendly_name) | 
|  | 4516 | fprintf(f, "osu_friendly_name=%s\n", osu_friendly_name); | 
|  | 4517 |  | 
|  | 4518 | if (osu_service_desc) | 
|  | 4519 | fprintf(f, "osu_service_desc=%s\n", osu_service_desc); | 
|  | 4520 |  | 
|  | 4521 | if (osu_nai) | 
|  | 4522 | fprintf(f, "osu_nai=%s\n", osu_nai); | 
| Jouni Malinen | 93a837f | 2018-11-01 17:09:22 +0200 | [diff] [blame] | 4523 | if (osu_nai2) | 
|  | 4524 | fprintf(f, "osu_nai2=%s\n", osu_nai2); | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4525 |  | 
|  | 4526 | fprintf(f, "hs20_icon=%s\n", hs20_icon); | 
|  | 4527 |  | 
|  | 4528 | if (osu_icon) | 
|  | 4529 | fprintf(f, "osu_icon=%s\n", osu_icon); | 
|  | 4530 |  | 
|  | 4531 | if (dut->ap_osu_provider_list > 100) | 
|  | 4532 | fprintf(f, "osu_method_list=0\n"); | 
|  | 4533 | else | 
|  | 4534 | fprintf(f, "osu_method_list=%d\n", osu_method); | 
|  | 4535 | } | 
|  | 4536 |  | 
| Jouni Malinen | 54a89b0 | 2018-05-01 00:16:26 +0300 | [diff] [blame] | 4537 | switch (dut->ap_venue_url) { | 
|  | 4538 | case 1: | 
|  | 4539 | fprintf(f, | 
|  | 4540 | "venue_url=1:https://venue-server.r2m-testbed.wi-fi.org/floorplans/index.html\n" | 
|  | 4541 | "venue_url=1:https://venue-server.r2m-testbed.wi-fi.org/directory/index.html\n"); | 
|  | 4542 | break; | 
|  | 4543 | case 2: | 
|  | 4544 | fprintf(f, | 
|  | 4545 | "venue_url=1:https://the-great-mall.r2m-testbed.wi-fi.org/floorplans/index.html\n" | 
|  | 4546 | "venue_url=2:https://abercrombie.r2m-testbed.wi-fi.org/floorplans/index.html\n" | 
|  | 4547 | "venue_url=3:https://adidas.r2m-testbed.wi-fi.org/floorplans/index.html\n" | 
|  | 4548 | "venue_url=4:https://aeropostale.r2m-testbed.wi-fi.org/floorplans/index.html\n" | 
|  | 4549 | "venue_url=5:https://agaci.r2m-testbed.wi-fi.org/floorplans/index.html\n" | 
|  | 4550 | "venue_url=6:https://aldo-shoes.r2m-testbed.wi-fi.org/floorplans/index.html\n" | 
|  | 4551 | "venue_url=7:https://american-eagle-outfitters.r2m-testbed.wi-fi.org/floorplans/index.html\n" | 
|  | 4552 | "venue_url=8:https://anderson-bakery.r2m-testbed.wi-fi.org/floorplans/index.html\n" | 
|  | 4553 | "venue_url=9:https://banana-republic-factory-store.r2m-testbed.wi-fi.org/floorplans/index.html\n" | 
|  | 4554 | "venue_url=10:https://bed-bath-and-beyond.r2m-testbed.wi-fi.org/floorplans/index.html\n" | 
|  | 4555 | ); | 
|  | 4556 | break; | 
|  | 4557 | } | 
|  | 4558 |  | 
| Jouni Malinen | f7ff42b | 2018-05-01 00:21:56 +0300 | [diff] [blame] | 4559 | switch (dut->ap_advice_of_charge) { | 
|  | 4560 | case 1: | 
|  | 4561 | fprintf(f, "anqp_elem=278:" ADV_OF_CHARGE_1 "\n"); | 
|  | 4562 | break; | 
|  | 4563 | } | 
|  | 4564 |  | 
| Jouni Malinen | ac10453 | 2018-05-01 00:27:37 +0300 | [diff] [blame] | 4565 | switch (dut->ap_oper_icon_metadata) { | 
|  | 4566 | case 1: | 
|  | 4567 | fprintf(f, | 
|  | 4568 | "hs20_icon=160:76:eng:image/png:icon_red_eng.png:/etc/ath/icon_red_eng.png\n" | 
|  | 4569 | "operator_icon=icon_red_eng.png\n"); | 
|  | 4570 | break; | 
|  | 4571 | } | 
|  | 4572 |  | 
| Jouni Malinen | ac36714 | 2018-05-01 00:32:24 +0300 | [diff] [blame] | 4573 | switch (dut->ap_tnc_file_name) { | 
|  | 4574 | case 1: | 
|  | 4575 | fprintf(f, "hs20_t_c_filename=tandc-id1-content.txt\n"); | 
|  | 4576 | break; | 
|  | 4577 | } | 
|  | 4578 |  | 
|  | 4579 | if (dut->ap_tnc_time_stamp) | 
|  | 4580 | fprintf(f, "hs20_t_c_timestamp=%u\n", dut->ap_tnc_time_stamp); | 
|  | 4581 |  | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4582 | return 0; | 
|  | 4583 | } | 
|  | 4584 |  | 
|  | 4585 |  | 
|  | 4586 | static void write_ap_roaming_cons(FILE *f, const char *list) | 
|  | 4587 | { | 
|  | 4588 | char *buf, *pos, *end; | 
|  | 4589 |  | 
|  | 4590 | if (list == NULL || list[0] == '\0') | 
|  | 4591 | return; | 
|  | 4592 |  | 
|  | 4593 | buf = strdup(list); | 
|  | 4594 | if (buf == NULL) | 
|  | 4595 | return; | 
|  | 4596 |  | 
|  | 4597 | pos = buf; | 
|  | 4598 | while (pos && *pos) { | 
|  | 4599 | end = strchr(pos, ';'); | 
|  | 4600 | if (end) | 
|  | 4601 | *end++ = '\0'; | 
|  | 4602 | fprintf(f, "roaming_consortium=%s\n", pos); | 
|  | 4603 | pos = end; | 
|  | 4604 | } | 
|  | 4605 |  | 
|  | 4606 | free(buf); | 
|  | 4607 | } | 
|  | 4608 |  | 
|  | 4609 |  | 
|  | 4610 | static int append_hostapd_conf_interworking(struct sigma_dut *dut, FILE *f) | 
|  | 4611 | { | 
|  | 4612 | int i; | 
|  | 4613 | char buf[100], *temp; | 
|  | 4614 |  | 
|  | 4615 | if (dut->ap_gas_cb_delay > 0) | 
|  | 4616 | fprintf(f, "gas_comeback_delay=%d\n", | 
|  | 4617 | dut->ap_gas_cb_delay); | 
|  | 4618 |  | 
|  | 4619 | fprintf(f, "interworking=1\n" | 
|  | 4620 | "access_network_type=%d\n" | 
|  | 4621 | "internet=%d\n" | 
|  | 4622 | "asra=0\n" | 
|  | 4623 | "esr=0\n" | 
|  | 4624 | "uesa=0\n" | 
|  | 4625 | "venue_group=%d\n" | 
|  | 4626 | "venue_type=%d\n", | 
|  | 4627 | dut->ap_access_net_type, | 
|  | 4628 | dut->ap_internet, | 
|  | 4629 | dut->ap_venue_group, | 
|  | 4630 | dut->ap_venue_type); | 
|  | 4631 | if (dut->ap_hessid[0]) | 
|  | 4632 | fprintf(f, "hessid=%s\n", dut->ap_hessid); | 
|  | 4633 |  | 
|  | 4634 | write_ap_roaming_cons(f, dut->ap_roaming_cons); | 
|  | 4635 |  | 
|  | 4636 | if (dut->ap_venue_name) { | 
|  | 4637 | fprintf(f, "venue_name=P\"eng:Wi-Fi Alliance\\n2989 Copper Road\\nSanta Clara, CA 95051, USA\"\n"); | 
|  | 4638 | fprintf(f, "venue_name=%s\n", ANQP_VENUE_NAME_1_CHI); | 
|  | 4639 | } | 
|  | 4640 |  | 
|  | 4641 | if (dut->ap_net_auth_type == 1) | 
|  | 4642 | fprintf(f, "network_auth_type=00https://tandc-server.wi-fi.org\n"); | 
|  | 4643 | else if (dut->ap_net_auth_type == 2) | 
|  | 4644 | fprintf(f, "network_auth_type=01\n"); | 
|  | 4645 |  | 
|  | 4646 | if (dut->ap_nai_realm_list == 1) { | 
|  | 4647 | fprintf(f, "nai_realm=0,mail.example.com;cisco.com;wi-fi.org,21[2:4][5:7]\n"); | 
|  | 4648 | fprintf(f, "nai_realm=0,wi-fi.org;example.com,13[5:6]\n"); | 
|  | 4649 | } else if (dut->ap_nai_realm_list == 2) { | 
|  | 4650 | fprintf(f, "nai_realm=0,wi-fi.org,21[2:4][5:7]\n"); | 
|  | 4651 | } else if (dut->ap_nai_realm_list == 3) { | 
|  | 4652 | fprintf(f, "nai_realm=0,cisco.com;wi-fi.org,21[2:4][5:7]\n"); | 
|  | 4653 | fprintf(f, "nai_realm=0,wi-fi.org;example.com,13[5:6]\n"); | 
|  | 4654 | } else if (dut->ap_nai_realm_list == 4) { | 
|  | 4655 | fprintf(f, "nai_realm=0,mail.example.com,21[2:4][5:7],13[5:6]\n"); | 
|  | 4656 | } else if (dut->ap_nai_realm_list == 5) { | 
|  | 4657 | fprintf(f, "nai_realm=0,wi-fi.org;ruckuswireless.com,21[2:4][5:7]\n"); | 
|  | 4658 | } else if (dut->ap_nai_realm_list == 6) { | 
|  | 4659 | fprintf(f, "nai_realm=0,wi-fi.org;mail.example.com,21[2:4][5:7]\n"); | 
|  | 4660 | } else if (dut->ap_nai_realm_list == 7) { | 
|  | 4661 | fprintf(f, "nai_realm=0,wi-fi.org,13[5:6]\n"); | 
|  | 4662 | fprintf(f, "nai_realm=0,wi-fi.org,21[2:4][5:7]\n"); | 
|  | 4663 | } | 
|  | 4664 |  | 
|  | 4665 | if (dut->ap_domain_name_list[0]) { | 
|  | 4666 | fprintf(f, "domain_name=%s\n", | 
|  | 4667 | dut->ap_domain_name_list); | 
|  | 4668 | } | 
|  | 4669 |  | 
|  | 4670 | if (dut->ap_ip_addr_type_avail == 1) { | 
|  | 4671 | fprintf(f, "ipaddr_type_availability=0c\n"); | 
|  | 4672 | } | 
|  | 4673 |  | 
|  | 4674 | temp = buf; | 
|  | 4675 | for (i = 0; dut->ap_plmn_mcc[i][0] && dut->ap_plmn_mnc[i][0]; | 
|  | 4676 | i++) { | 
|  | 4677 | if (i) | 
|  | 4678 | *temp++ = ';'; | 
|  | 4679 |  | 
|  | 4680 | snprintf(temp, | 
|  | 4681 | sizeof(dut->ap_plmn_mcc[i]) + | 
|  | 4682 | sizeof(dut->ap_plmn_mnc[i]) + 1, | 
|  | 4683 | "%s,%s", | 
|  | 4684 | dut->ap_plmn_mcc[i], | 
|  | 4685 | dut->ap_plmn_mnc[i]); | 
|  | 4686 |  | 
|  | 4687 | temp += strlen(dut->ap_plmn_mcc[i]) + | 
|  | 4688 | strlen(dut->ap_plmn_mnc[i]) + 1; | 
|  | 4689 | } | 
|  | 4690 | if (i) | 
|  | 4691 | fprintf(f, "anqp_3gpp_cell_net=%s\n", buf); | 
|  | 4692 |  | 
|  | 4693 | if (dut->ap_qos_map_set == 1) | 
|  | 4694 | fprintf(f, "qos_map_set=%s\n", QOS_MAP_SET_1); | 
|  | 4695 | else if (dut->ap_qos_map_set == 2) | 
|  | 4696 | fprintf(f, "qos_map_set=%s\n", QOS_MAP_SET_2); | 
|  | 4697 |  | 
|  | 4698 | return 0; | 
|  | 4699 | } | 
|  | 4700 |  | 
|  | 4701 |  | 
|  | 4702 | static int ath_ap_append_hostapd_conf(struct sigma_dut *dut) | 
|  | 4703 | { | 
|  | 4704 | FILE *f; | 
|  | 4705 |  | 
|  | 4706 | if (kill_process(dut, "(hostapd)", 1, SIGTERM) == 0 || | 
|  | 4707 | system("killall hostapd") == 0) { | 
|  | 4708 | int i; | 
|  | 4709 |  | 
|  | 4710 | /* Wait some time to allow hostapd to complete cleanup before | 
|  | 4711 | * starting a new process */ | 
|  | 4712 | for (i = 0; i < 10; i++) { | 
|  | 4713 | usleep(500000); | 
|  | 4714 | if (system("pidof hostapd") != 0) | 
|  | 4715 | break; | 
|  | 4716 | } | 
|  | 4717 | } | 
|  | 4718 |  | 
|  | 4719 | f = fopen("/tmp/secath0", "a"); | 
|  | 4720 | if (f == NULL) | 
|  | 4721 | return -2; | 
|  | 4722 |  | 
|  | 4723 | if (dut->ap_hs2 && append_hostapd_conf_hs2(dut, f)) { | 
|  | 4724 | fclose(f); | 
|  | 4725 | return -2; | 
|  | 4726 | } | 
|  | 4727 |  | 
|  | 4728 | if (dut->ap_interworking && append_hostapd_conf_interworking(dut, f)) { | 
|  | 4729 | fclose(f); | 
|  | 4730 | return -2; | 
|  | 4731 | } | 
|  | 4732 |  | 
|  | 4733 | fflush(f); | 
|  | 4734 | fclose(f); | 
|  | 4735 | return ath_ap_start_hostapd(dut); | 
|  | 4736 | } | 
|  | 4737 |  | 
|  | 4738 |  | 
|  | 4739 | static int ath_ap_start_hostapd(struct sigma_dut *dut) | 
|  | 4740 | { | 
| Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 4741 | if (dut->ap_tag_key_mgmt[0] == AP2_OSEN) | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4742 | run_system(dut, "hostapd -B /tmp/secath0 /tmp/secath1 -e /etc/wpa2/entropy"); | 
|  | 4743 | else | 
|  | 4744 | run_system(dut, "hostapd -B /tmp/secath0 -e /etc/wpa2/entropy"); | 
|  | 4745 |  | 
|  | 4746 | return 0; | 
|  | 4747 | } | 
|  | 4748 |  | 
|  | 4749 |  | 
|  | 4750 | #define LE16(a) ((((a) & 0xff) << 8) | (((a) >> 8) & 0xff)) | 
|  | 4751 |  | 
|  | 4752 | static int cmd_ath_ap_anqpserver_start(struct sigma_dut *dut) | 
|  | 4753 | { | 
|  | 4754 | FILE *f; | 
|  | 4755 | int nai_realm = 0, domain_name = 0, oper_name = 0, venue_name = 0, | 
|  | 4756 | wan_metrics = 0, conn_cap = 0, ipaddr_avail = 0, cell_net = 0; | 
|  | 4757 | char buf[100]; | 
|  | 4758 | int i; | 
|  | 4759 |  | 
|  | 4760 | f = fopen("/root/anqpserver.conf", "w"); | 
|  | 4761 | if (f == NULL) | 
|  | 4762 | return -1; | 
|  | 4763 |  | 
|  | 4764 | if (dut->ap_nai_realm_list == 1) { | 
|  | 4765 | nai_realm = 1; | 
|  | 4766 | 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"); | 
|  | 4767 | } else if (dut->ap_nai_realm_list == 2) { | 
|  | 4768 | nai_realm = 1; | 
|  | 4769 | fprintf(f, "dyn_nai_home_realm=encoding=00realm=wi-fi.org;eap_method=0Dauth_id=05auth_val=06\n"); | 
|  | 4770 | } else if (dut->ap_nai_realm_list == 3) { | 
|  | 4771 | nai_realm = 1; | 
|  | 4772 | 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"); | 
|  | 4773 | } else if (dut->ap_nai_realm_list == 4) { | 
|  | 4774 | nai_realm = 1; | 
|  | 4775 | 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"); | 
|  | 4776 | } else | 
|  | 4777 | sigma_dut_print(dut, DUT_MSG_INFO, "not setting nai_realm"); | 
|  | 4778 |  | 
|  | 4779 | if (dut->ap_domain_name_list[0]) { | 
|  | 4780 | char *next, *start, *dnbuf, *dn1, *anqp_dn; | 
|  | 4781 | int len, dn_len_max; | 
|  | 4782 | dnbuf = strdup(dut->ap_domain_name_list); | 
| Pradeep Reddy POTTETI | 673d85c | 2016-07-26 19:08:07 +0530 | [diff] [blame] | 4783 | if (dnbuf == NULL) { | 
|  | 4784 | fclose(f); | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4785 | return 0; | 
| Pradeep Reddy POTTETI | 673d85c | 2016-07-26 19:08:07 +0530 | [diff] [blame] | 4786 | } | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4787 |  | 
|  | 4788 | len = strlen(dnbuf); | 
|  | 4789 | dn_len_max = 50 + len*2; | 
|  | 4790 | anqp_dn = malloc(dn_len_max); | 
|  | 4791 | if (anqp_dn == NULL) { | 
|  | 4792 | free(dnbuf); | 
| Pradeep Reddy POTTETI | 673d85c | 2016-07-26 19:08:07 +0530 | [diff] [blame] | 4793 | fclose(f); | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4794 | return -1; | 
|  | 4795 | } | 
|  | 4796 | start = dnbuf; | 
|  | 4797 | dn1 = anqp_dn; | 
|  | 4798 | while (start && *start) { | 
|  | 4799 | char *hexstr; | 
|  | 4800 |  | 
|  | 4801 | next = strchr(start, ','); | 
|  | 4802 | if (next) | 
|  | 4803 | *next++ = '\0'; | 
|  | 4804 |  | 
|  | 4805 | len = strlen(start); | 
| vamsi krishna | 2e88130 | 2016-05-25 15:02:39 +0530 | [diff] [blame] | 4806 | hexstr = malloc(len * 2 + 1); | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4807 | if (hexstr == NULL) { | 
|  | 4808 | free(dnbuf); | 
|  | 4809 | free(anqp_dn); | 
| Pradeep Reddy POTTETI | 673d85c | 2016-07-26 19:08:07 +0530 | [diff] [blame] | 4810 | fclose(f); | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 4811 | return -1; | 
|  | 4812 | } | 
|  | 4813 | ascii2hexstr(start, hexstr); | 
|  | 4814 | snprintf(dn1, dn_len_max, "%02x%s", len, hexstr); | 
|  | 4815 | free(hexstr); | 
|  | 4816 | dn1 += 2 + len * 2; | 
|  | 4817 | dn_len_max -= 2 + len * 2; | 
|  | 4818 | start = next; | 
|  | 4819 | } | 
|  | 4820 | free(dnbuf); | 
|  | 4821 | if (dut->ap_gas_cb_delay) { | 
|  | 4822 | fprintf(f, "dyn_domain_name=0c01%04x%s", | 
|  | 4823 | LE16((unsigned int) strlen(anqp_dn)), anqp_dn); | 
|  | 4824 | domain_name = 1; | 
|  | 4825 | } else | 
|  | 4826 | fprintf(f, "domain_name=0c01%04x%s", | 
|  | 4827 | LE16((unsigned int) strlen(anqp_dn)), anqp_dn); | 
|  | 4828 | free(anqp_dn); | 
|  | 4829 | } else | 
|  | 4830 | sigma_dut_print(dut, DUT_MSG_INFO, "not setting domain_name"); | 
|  | 4831 |  | 
|  | 4832 | sigma_dut_print(dut, DUT_MSG_INFO, "not setting roaming_consortium"); | 
|  | 4833 |  | 
|  | 4834 | if (dut->ap_oper_name) { | 
|  | 4835 | if (dut->ap_gas_cb_delay) { | 
|  | 4836 | fprintf(f, "dyn_oper_friendly_name=" | 
|  | 4837 | ANQP_HS20_OPERATOR_FRIENDLY_NAME_1 "\n"); | 
|  | 4838 | oper_name = 1; | 
|  | 4839 | } else | 
|  | 4840 | fprintf(f, "oper_friendly_name=" | 
|  | 4841 | ANQP_HS20_OPERATOR_FRIENDLY_NAME_1 "\n"); | 
|  | 4842 | } else | 
|  | 4843 | sigma_dut_print(dut, DUT_MSG_INFO, "not setting oper_name"); | 
|  | 4844 |  | 
|  | 4845 | if (dut->ap_venue_name) { | 
|  | 4846 | if (dut->ap_gas_cb_delay) { | 
|  | 4847 | fprintf(f, "dyn_venue_name=" ANQP_VENUE_NAME_1 "\n"); | 
|  | 4848 | venue_name = 1; | 
|  | 4849 | } else | 
|  | 4850 | fprintf(f, "venue_name=" ANQP_VENUE_NAME_1 "\n"); | 
|  | 4851 | } else | 
|  | 4852 | sigma_dut_print(dut, DUT_MSG_ERROR, "not setting venue_name"); | 
|  | 4853 |  | 
|  | 4854 | if (dut->ap_wan_metrics) { | 
|  | 4855 | if (dut->ap_gas_cb_delay) { | 
|  | 4856 | fprintf(f, "dyn_wan_metrics=" ANQP_HS20_WAN_METRICS_1 "\n"); | 
|  | 4857 | wan_metrics = 1; | 
|  | 4858 | } else | 
|  | 4859 | fprintf(f, "wan_metrics=" ANQP_HS20_WAN_METRICS_1 | 
|  | 4860 | "\n"); | 
|  | 4861 | } else | 
|  | 4862 | sigma_dut_print(dut, DUT_MSG_ERROR, "not setting wan_metrics"); | 
|  | 4863 |  | 
|  | 4864 | if (dut->ap_conn_capab) { | 
|  | 4865 | if (dut->ap_gas_cb_delay) { | 
|  | 4866 | fprintf(f, "dyn_conn_capability=" | 
|  | 4867 | ANQP_HS20_CONNECTION_CAPABILITY_1 "\n"); | 
|  | 4868 | conn_cap = 1; | 
|  | 4869 | } else | 
|  | 4870 | fprintf(f, "conn_capability=" | 
|  | 4871 | ANQP_HS20_CONNECTION_CAPABILITY_1 "\n"); | 
|  | 4872 | } else | 
|  | 4873 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 4874 | "not setting conn_capability"); | 
|  | 4875 |  | 
|  | 4876 | if (dut->ap_ip_addr_type_avail) { | 
|  | 4877 | if (dut->ap_gas_cb_delay) { | 
|  | 4878 | fprintf(f, "dyn_ipaddr_type=" ANQP_IP_ADDR_TYPE_1 | 
|  | 4879 | "\n"); | 
|  | 4880 | ipaddr_avail = 1; | 
|  | 4881 | } else | 
|  | 4882 | fprintf(f, "ipaddr_type=" ANQP_IP_ADDR_TYPE_1 "\n"); | 
|  | 4883 | } else | 
|  | 4884 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 4885 | "not setting ipaddr_type_avail"); | 
|  | 4886 |  | 
|  | 4887 | for (i = 0; dut->ap_plmn_mcc[i][0] && dut->ap_plmn_mnc[i][0]; i++) { | 
|  | 4888 | snprintf(buf + i * 6, sizeof(buf) - i * 6, "%c%c%c%c%c%c", | 
|  | 4889 | dut->ap_plmn_mcc[i][1], | 
|  | 4890 | dut->ap_plmn_mcc[i][0], | 
|  | 4891 | dut->ap_plmn_mnc[i][2] == '\0' ? | 
|  | 4892 | 'f' : dut->ap_plmn_mnc[i][2], | 
|  | 4893 | dut->ap_plmn_mcc[i][2], | 
|  | 4894 | dut->ap_plmn_mnc[i][1], | 
|  | 4895 | dut->ap_plmn_mnc[i][0]); | 
|  | 4896 | } | 
|  | 4897 | if (i) { | 
|  | 4898 | uint16_t ie_len = (i * 3) + 5; | 
|  | 4899 | if (dut->ap_gas_cb_delay) { | 
|  | 4900 | fprintf(f, "dyn_cell_net=0801"); | 
|  | 4901 | cell_net = 1; | 
|  | 4902 | } else | 
|  | 4903 | fprintf(f, "cell_net=0801"); | 
|  | 4904 | fprintf(f, "%04x", LE16(ie_len)); | 
|  | 4905 | fprintf(f, "00");                /* version */ | 
|  | 4906 | fprintf(f, "%02x", (i * 3) + 3); /* user data hdr length */ | 
|  | 4907 | fprintf(f, "00");                /* plmn list */ | 
|  | 4908 | fprintf(f, "%02x", (i * 3) + 1); /* length of plmn list */ | 
|  | 4909 | fprintf(f, "%02x", i);           /* number of plmns */ | 
|  | 4910 | fprintf(f, "%s\n", buf);           /* plmns */ | 
|  | 4911 | } else | 
|  | 4912 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 4913 | "not setting 3gpp_cellular_network"); | 
|  | 4914 |  | 
|  | 4915 | if (nai_realm || domain_name || oper_name || venue_name || | 
|  | 4916 | wan_metrics || conn_cap || ipaddr_avail || cell_net) { | 
|  | 4917 | fprintf(f, "anqp_attach="); | 
|  | 4918 | if (venue_name) | 
|  | 4919 | fprintf(f, "00000104%4.4x", dut->ap_gas_cb_delay); | 
|  | 4920 | if (nai_realm) | 
|  | 4921 | fprintf(f, "00000107%4.4x", dut->ap_gas_cb_delay); | 
|  | 4922 | if (cell_net) | 
|  | 4923 | fprintf(f, "00000108%4.4x", dut->ap_gas_cb_delay); | 
|  | 4924 | if (domain_name) | 
|  | 4925 | fprintf(f, "0000010c%4.4x", dut->ap_gas_cb_delay); | 
|  | 4926 | if (oper_name) | 
|  | 4927 | fprintf(f, "00010003%4.4x", dut->ap_gas_cb_delay); | 
|  | 4928 | if (wan_metrics) | 
|  | 4929 | fprintf(f, "00010004%4.4x", dut->ap_gas_cb_delay); | 
|  | 4930 | if (conn_cap) | 
|  | 4931 | fprintf(f, "00010005%4.4x", dut->ap_gas_cb_delay); | 
|  | 4932 | fprintf(f, "00010006%4.4x", dut->ap_gas_cb_delay); | 
|  | 4933 | fprintf(f, "\n"); | 
|  | 4934 | } | 
|  | 4935 |  | 
|  | 4936 | fclose(f); | 
|  | 4937 |  | 
|  | 4938 | run_system(dut, "anqpserver -i ath0 &"); | 
|  | 4939 | if (!dut->ap_anqpserver_on) | 
|  | 4940 | run_system(dut, "killall anqpserver"); | 
|  | 4941 |  | 
|  | 4942 | return 1; | 
|  | 4943 | } | 
|  | 4944 |  | 
|  | 4945 |  | 
|  | 4946 | static void cmd_ath_ap_radio_config(struct sigma_dut *dut) | 
|  | 4947 | { | 
|  | 4948 | char buf[100]; | 
|  | 4949 |  | 
|  | 4950 | run_system(dut, "cfg -a AP_STARTMODE=standard"); | 
|  | 4951 |  | 
|  | 4952 | if (sigma_radio_ifname[0] && | 
|  | 4953 | strcmp(sigma_radio_ifname[0], "wifi1") == 0) { | 
|  | 4954 | run_system(dut, "cfg -a AP_RADIO_ID=1"); | 
|  | 4955 | switch (dut->ap_mode) { | 
|  | 4956 | case AP_11g: | 
|  | 4957 | run_system(dut, "cfg -a AP_CHMODE_2=11G"); | 
|  | 4958 | break; | 
|  | 4959 | case AP_11b: | 
|  | 4960 | run_system(dut, "cfg -a AP_CHMODE_2=11B"); | 
|  | 4961 | break; | 
|  | 4962 | case AP_11ng: | 
|  | 4963 | run_system(dut, "cfg -a AP_CHMODE_2=11NGHT20"); | 
|  | 4964 | break; | 
|  | 4965 | case AP_11a: | 
|  | 4966 | run_system(dut, "cfg -a AP_CHMODE_2=11A"); | 
|  | 4967 | break; | 
|  | 4968 | case AP_11na: | 
|  | 4969 | run_system(dut, "cfg -a AP_CHMODE_2=11NAHT20"); | 
|  | 4970 | break; | 
|  | 4971 | case AP_11ac: | 
|  | 4972 | run_system(dut, "cfg -a AP_CHMODE_2=11ACVHT80"); | 
|  | 4973 | break; | 
|  | 4974 | default: | 
|  | 4975 | run_system(dut, "cfg -a AP_CHMODE_2=11ACVHT80"); | 
|  | 4976 | break; | 
|  | 4977 | } | 
|  | 4978 |  | 
|  | 4979 | switch (dut->ap_rx_streams) { | 
|  | 4980 | case 1: | 
|  | 4981 | run_system(dut, "cfg -a RX_CHAINMASK_2=1"); | 
|  | 4982 | break; | 
|  | 4983 | case 2: | 
|  | 4984 | run_system(dut, "cfg -a RX_CHAINMASK_2=3"); | 
|  | 4985 | break; | 
|  | 4986 | case 3: | 
|  | 4987 | run_system(dut, "cfg -a RX_CHAINMASK_2=7"); | 
|  | 4988 | break; | 
|  | 4989 | } | 
|  | 4990 |  | 
|  | 4991 | switch (dut->ap_tx_streams) { | 
|  | 4992 | case 1: | 
|  | 4993 | run_system(dut, "cfg -a TX_CHAINMASK_2=1"); | 
|  | 4994 | break; | 
|  | 4995 | case 2: | 
|  | 4996 | run_system(dut, "cfg -a TX_CHAINMASK_2=3"); | 
|  | 4997 | break; | 
|  | 4998 | case 3: | 
|  | 4999 | run_system(dut, "cfg -a TX_CHAINMASK_2=7"); | 
|  | 5000 | break; | 
|  | 5001 | } | 
|  | 5002 |  | 
|  | 5003 | switch (dut->ap_chwidth) { | 
|  | 5004 | case AP_20: | 
|  | 5005 | run_system(dut, "cfg -a AP_CHMODE_2=11ACVHT20"); | 
|  | 5006 | break; | 
|  | 5007 | case AP_40: | 
|  | 5008 | run_system(dut, "cfg -a AP_CHMODE_2=11ACVHT40"); | 
|  | 5009 | break; | 
|  | 5010 | case AP_80: | 
|  | 5011 | run_system(dut, "cfg -a AP_CHMODE_2=11ACVHT80"); | 
|  | 5012 | break; | 
|  | 5013 | case AP_160: | 
|  | 5014 | case AP_AUTO: | 
|  | 5015 | default: | 
|  | 5016 | run_system(dut, "cfg -a AP_CHMODE_2=11ACVHT80"); | 
|  | 5017 | break; | 
|  | 5018 | } | 
|  | 5019 |  | 
|  | 5020 | if (dut->ap_tx_stbc) { | 
|  | 5021 | run_system(dut, "cfg -a TX_STBC_2=1"); | 
|  | 5022 | } | 
|  | 5023 |  | 
|  | 5024 | snprintf(buf, sizeof(buf), "cfg -a AP_PRIMARY_CH_2=%d", | 
|  | 5025 | dut->ap_channel); | 
|  | 5026 |  | 
|  | 5027 | if (dut->ap_is_dual) { | 
|  | 5028 | switch (dut->ap_mode_1) { | 
|  | 5029 | case AP_11g: | 
|  | 5030 | run_system(dut, "cfg -a AP_CHMODE=11G"); | 
|  | 5031 | break; | 
|  | 5032 | case AP_11b: | 
|  | 5033 | run_system(dut, "cfg -a AP_CHMODE=11B"); | 
|  | 5034 | break; | 
|  | 5035 | case AP_11ng: | 
|  | 5036 | run_system(dut, "cfg -a AP_CHMODE=11NGHT20"); | 
|  | 5037 | break; | 
|  | 5038 | case AP_11a: | 
|  | 5039 | run_system(dut, "cfg -a AP_CHMODE=11A"); | 
|  | 5040 | break; | 
|  | 5041 | case AP_11na: | 
|  | 5042 | run_system(dut, "cfg -a AP_CHMODE=11NAHT20"); | 
|  | 5043 | break; | 
|  | 5044 | case AP_11ac: | 
|  | 5045 | run_system(dut, "cfg -a AP_CHMODE=11ACVHT80"); | 
|  | 5046 | break; | 
|  | 5047 | default: | 
|  | 5048 | run_system(dut, "cfg -a AP_CHMODE=11NGHT20"); | 
|  | 5049 | break; | 
|  | 5050 | } | 
|  | 5051 | snprintf(buf, sizeof(buf), "cfg -a AP_PRIMARY_CH=%d", | 
|  | 5052 | dut->ap_channel_1); | 
|  | 5053 | } | 
|  | 5054 | run_system(dut, buf); | 
|  | 5055 | } else { | 
|  | 5056 | run_system(dut, "cfg -a AP_RADIO_ID=0"); | 
|  | 5057 | switch (dut->ap_mode) { | 
|  | 5058 | case AP_11g: | 
|  | 5059 | run_system(dut, "cfg -a AP_CHMODE=11G"); | 
|  | 5060 | break; | 
|  | 5061 | case AP_11b: | 
|  | 5062 | run_system(dut, "cfg -a AP_CHMODE=11B"); | 
|  | 5063 | break; | 
|  | 5064 | case AP_11ng: | 
|  | 5065 | run_system(dut, "cfg -a AP_CHMODE=11NGHT20"); | 
|  | 5066 | break; | 
|  | 5067 | case AP_11a: | 
|  | 5068 | run_system(dut, "cfg -a AP_CHMODE=11A"); | 
|  | 5069 | break; | 
|  | 5070 | case AP_11na: | 
|  | 5071 | run_system(dut, "cfg -a AP_CHMODE=11NAHT20"); | 
|  | 5072 | break; | 
|  | 5073 | case AP_11ac: | 
|  | 5074 | run_system(dut, "cfg -a AP_CHMODE=11ACVHT80"); | 
|  | 5075 | break; | 
|  | 5076 | default: | 
|  | 5077 | run_system(dut, "cfg -a AP_CHMODE=11NGHT20"); | 
|  | 5078 | break; | 
|  | 5079 | } | 
|  | 5080 | snprintf(buf, sizeof(buf), "cfg -a AP_PRIMARY_CH=%d", | 
|  | 5081 | dut->ap_channel); | 
|  | 5082 | run_system(dut, buf); | 
|  | 5083 | } | 
|  | 5084 |  | 
|  | 5085 | if (dut->ap_sgi80 == 1) { | 
|  | 5086 | run_system(dut, "cfg -a SHORTGI=1"); | 
|  | 5087 | run_system(dut, "cfg -a SHORTGI_2=1"); | 
|  | 5088 | } else if (dut->ap_sgi80 == 0) { | 
|  | 5089 | run_system(dut, "cfg -a SHORTGI=0"); | 
|  | 5090 | run_system(dut, "cfg -a SHORTGI_2=0"); | 
|  | 5091 | } | 
|  | 5092 |  | 
| Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 5093 | if (dut->ap_ldpc == VALUE_ENABLED) | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5094 | run_system(dut, "cfg -a LDPC=1"); | 
| Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 5095 | else if (dut->ap_ldpc == VALUE_DISABLED) | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5096 | run_system(dut, "cfg -a LDPC=0"); | 
|  | 5097 | } | 
|  | 5098 |  | 
|  | 5099 |  | 
|  | 5100 | void ath_disable_txbf(struct sigma_dut *dut, const char *intf) | 
|  | 5101 | { | 
|  | 5102 | char buf[50]; | 
|  | 5103 |  | 
|  | 5104 | snprintf(buf, sizeof(buf), "iwpriv %s vhtsubfee 0", intf); | 
|  | 5105 | if (system(buf) != 0) | 
|  | 5106 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv vhtsubfee failed"); | 
|  | 5107 |  | 
|  | 5108 | snprintf(buf, sizeof(buf), "iwpriv %s vhtsubfer 0", intf); | 
|  | 5109 | if (system(buf) != 0) | 
|  | 5110 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv vhtsubfer failed"); | 
|  | 5111 |  | 
|  | 5112 | snprintf(buf, sizeof(buf), "iwpriv %s vhtmubfee 0", intf); | 
|  | 5113 | if (system(buf) != 0) | 
|  | 5114 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv vhtmubfee failed"); | 
|  | 5115 |  | 
|  | 5116 | snprintf(buf, sizeof(buf), "iwpriv %s vhtmubfer 0", intf); | 
|  | 5117 | if (system(buf) != 0) | 
|  | 5118 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv vhtmubfer failed"); | 
|  | 5119 | } | 
|  | 5120 |  | 
|  | 5121 |  | 
| Adil Saeed Musthafa | 05ec744 | 2017-04-10 23:13:35 -0700 | [diff] [blame] | 5122 | static void ath_set_assoc_disallow(struct sigma_dut *dut, const char *ifname, | 
|  | 5123 | const char *val) | 
|  | 5124 | { | 
|  | 5125 | if (strcasecmp(val, "enable") == 0) { | 
|  | 5126 | run_system_wrapper(dut, "iwpriv %s mbo_asoc_dis 1", ifname); | 
|  | 5127 | } else if (strcasecmp(val, "disable") == 0) { | 
|  | 5128 | run_system_wrapper(dut, "iwpriv %s mbo_asoc_dis 0", ifname); | 
|  | 5129 | } else { | 
|  | 5130 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 5131 | "Unsupported assoc_disallow"); | 
|  | 5132 | } | 
|  | 5133 | } | 
|  | 5134 |  | 
|  | 5135 |  | 
| Adil Saeed Musthafa | 6906372 | 2017-04-10 23:13:40 -0700 | [diff] [blame] | 5136 | static void apply_mbo_pref_ap_list(struct sigma_dut *dut) | 
|  | 5137 | { | 
|  | 5138 | int i; | 
|  | 5139 | int least_pref = 1 << 8; | 
|  | 5140 | char ifname[20]; | 
|  | 5141 | uint8_t self_mac[ETH_ALEN]; | 
|  | 5142 | char buf[200]; | 
|  | 5143 | int ap_ne_class, ap_ne_pref, ap_ne_op_ch; | 
|  | 5144 |  | 
|  | 5145 | get_if_name(dut, ifname, sizeof(ifname), 1); | 
|  | 5146 | get_hwaddr(ifname, self_mac); | 
|  | 5147 |  | 
|  | 5148 | /* Clear off */ | 
|  | 5149 | snprintf(buf, sizeof(buf), | 
|  | 5150 | "wifitool %s setbssidpref 00:00:00:00:00:00 0 0 0", | 
|  | 5151 | ifname); | 
|  | 5152 | run_system(dut, buf); | 
|  | 5153 |  | 
|  | 5154 | /* Find the least preference number */ | 
|  | 5155 | for (i = 0; i < dut->mbo_pref_ap_cnt; i++) { | 
|  | 5156 | unsigned char *mac_addr = dut->mbo_pref_aps[i].mac_addr; | 
|  | 5157 |  | 
|  | 5158 | ap_ne_class = 1; | 
|  | 5159 | ap_ne_pref = 255; | 
|  | 5160 | ap_ne_op_ch = 1; | 
|  | 5161 | if (dut->mbo_pref_aps[i].ap_ne_pref != -1) | 
|  | 5162 | ap_ne_pref = dut->mbo_pref_aps[i].ap_ne_pref; | 
|  | 5163 | if (dut->mbo_pref_aps[i].ap_ne_class != -1) | 
|  | 5164 | ap_ne_class = dut->mbo_pref_aps[i].ap_ne_class; | 
|  | 5165 | if (dut->mbo_pref_aps[i].ap_ne_op_ch != -1) | 
|  | 5166 | ap_ne_op_ch = dut->mbo_pref_aps[i].ap_ne_op_ch; | 
|  | 5167 |  | 
|  | 5168 | if (ap_ne_pref < least_pref) | 
|  | 5169 | least_pref = ap_ne_pref; | 
|  | 5170 | snprintf(buf, sizeof(buf), | 
|  | 5171 | "wifitool %s setbssidpref %02x:%02x:%02x:%02x:%02x:%02x %d %d %d", | 
|  | 5172 | ifname, mac_addr[0], mac_addr[1], mac_addr[2], | 
|  | 5173 | mac_addr[3], mac_addr[4], mac_addr[5], | 
|  | 5174 | ap_ne_pref, ap_ne_class, ap_ne_op_ch); | 
|  | 5175 | run_system(dut, buf); | 
|  | 5176 | } | 
|  | 5177 |  | 
|  | 5178 | /* Now add the self AP Address */ | 
|  | 5179 | if (dut->mbo_self_ap_tuple.ap_ne_class == -1) { | 
|  | 5180 | if (dut->ap_channel <= 11) | 
|  | 5181 | ap_ne_class = 81; | 
|  | 5182 | else | 
|  | 5183 | ap_ne_class = 115; | 
|  | 5184 | } else { | 
|  | 5185 | ap_ne_class = dut->mbo_self_ap_tuple.ap_ne_class; | 
|  | 5186 | } | 
|  | 5187 |  | 
|  | 5188 | if (dut->mbo_self_ap_tuple.ap_ne_op_ch == -1) | 
|  | 5189 | ap_ne_op_ch = dut->ap_channel; | 
|  | 5190 | else | 
|  | 5191 | ap_ne_op_ch = dut->mbo_self_ap_tuple.ap_ne_op_ch; | 
|  | 5192 |  | 
|  | 5193 | if (dut->mbo_self_ap_tuple.ap_ne_pref == -1) | 
|  | 5194 | ap_ne_pref = least_pref - 1; | 
|  | 5195 | else | 
|  | 5196 | ap_ne_pref = dut->mbo_self_ap_tuple.ap_ne_pref; | 
|  | 5197 |  | 
|  | 5198 | snprintf(buf, sizeof(buf), | 
|  | 5199 | "wifitool %s setbssidpref %02x:%02x:%02x:%02x:%02x:%02x %d %d %d", | 
|  | 5200 | ifname, self_mac[0], self_mac[1], self_mac[2], | 
|  | 5201 | self_mac[3], self_mac[4], self_mac[5], | 
|  | 5202 | ap_ne_pref, | 
|  | 5203 | ap_ne_class, | 
|  | 5204 | ap_ne_op_ch); | 
|  | 5205 | run_system(dut, buf); | 
|  | 5206 | } | 
|  | 5207 |  | 
|  | 5208 |  | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5209 | static void ath_ap_set_params(struct sigma_dut *dut) | 
|  | 5210 | { | 
| priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 5211 | const char *basedev = "wifi0"; | 
|  | 5212 | const char *basedev_radio = "wifi1"; | 
|  | 5213 | char *ifname = get_main_ifname(); | 
|  | 5214 | char *ifname_dual; | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5215 | int i; | 
| priyadharshini gowthaman | 8e26ff4 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 5216 | char buf[300]; | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5217 |  | 
| priyadharshini gowthaman | e161746 | 2017-04-25 12:03:59 -0700 | [diff] [blame] | 5218 | if (sigma_radio_ifname[0]) | 
|  | 5219 | basedev = sigma_radio_ifname[0]; | 
|  | 5220 |  | 
| priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 5221 | if (dut->ap_is_dual == 1) { | 
|  | 5222 | basedev = sigma_radio_ifname[0]; | 
|  | 5223 | basedev_radio = sigma_radio_ifname[1]; | 
|  | 5224 | if (sigma_radio_ifname[0] && | 
|  | 5225 | strcmp(sigma_radio_ifname[0], "wifi0") == 0) { | 
|  | 5226 | ifname = "ath0"; | 
|  | 5227 | ifname_dual = "ath1"; | 
|  | 5228 | } else { | 
|  | 5229 | ifname = "ath1"; | 
|  | 5230 | ifname_dual = "ath0"; | 
|  | 5231 | } | 
|  | 5232 | } | 
|  | 5233 |  | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5234 | if (dut->ap_countrycode[0]) { | 
|  | 5235 | snprintf(buf, sizeof(buf), "iwpriv %s setCountry %s", | 
|  | 5236 | basedev, dut->ap_countrycode); | 
|  | 5237 | if (system(buf) != 0) { | 
|  | 5238 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 5239 | "iwpriv setCountry failed"); | 
|  | 5240 | } | 
|  | 5241 | sigma_dut_print(dut, DUT_MSG_INFO, "Set countrycode"); | 
|  | 5242 | } | 
|  | 5243 |  | 
|  | 5244 | for (i = 0; i < NUM_AP_AC; i++) { | 
|  | 5245 | if (dut->ap_qos[i].ac) { | 
|  | 5246 | snprintf(buf, sizeof(buf), "iwpriv %s cwmin %d 0 %d", | 
|  | 5247 | ifname, i, dut->ap_qos[i].cwmin); | 
|  | 5248 | if (system(buf) != 0) { | 
|  | 5249 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 5250 | "iwpriv cwmin failed"); | 
|  | 5251 | } | 
|  | 5252 |  | 
|  | 5253 | snprintf(buf, sizeof(buf), "iwpriv %s cwmax %d 0 %d", | 
|  | 5254 | ifname, i, dut->ap_qos[i].cwmax); | 
|  | 5255 | if (system(buf) != 0) { | 
|  | 5256 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 5257 | "iwpriv cwmax failed"); | 
|  | 5258 | } | 
|  | 5259 |  | 
|  | 5260 | snprintf(buf, sizeof(buf), "iwpriv %s aifs %d 0 %d", | 
|  | 5261 | ifname, i, dut->ap_qos[i].aifs); | 
|  | 5262 | if (system(buf) != 0) { | 
|  | 5263 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 5264 | "iwpriv aifs failed"); | 
|  | 5265 | } | 
|  | 5266 |  | 
|  | 5267 | snprintf(buf, sizeof(buf), | 
|  | 5268 | "iwpriv %s txoplimit %d 0 %d", | 
|  | 5269 | ifname, i, dut->ap_qos[i].txop); | 
|  | 5270 | if (system(buf) != 0) { | 
|  | 5271 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 5272 | "iwpriv txoplimit failed"); | 
|  | 5273 | } | 
|  | 5274 |  | 
|  | 5275 | snprintf(buf, sizeof(buf), "iwpriv %s acm %d 0 %d", | 
|  | 5276 | ifname, i, dut->ap_qos[i].acm); | 
|  | 5277 | if (system(buf) != 0) { | 
|  | 5278 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 5279 | "iwpriv acm failed"); | 
|  | 5280 | } | 
|  | 5281 | } | 
|  | 5282 | } | 
|  | 5283 |  | 
|  | 5284 | for (i = 0; i < NUM_AP_AC; i++) { | 
|  | 5285 | if (dut->ap_sta_qos[i].ac) { | 
|  | 5286 | snprintf(buf, sizeof(buf), "iwpriv %s cwmin %d 1 %d", | 
|  | 5287 | ifname, i, dut->ap_sta_qos[i].cwmin); | 
|  | 5288 | if (system(buf) != 0) { | 
|  | 5289 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 5290 | "iwpriv cwmin failed"); | 
|  | 5291 | } | 
|  | 5292 |  | 
|  | 5293 | snprintf(buf, sizeof(buf), "iwpriv %s cwmax %d 1 %d", | 
|  | 5294 | ifname, i, dut->ap_sta_qos[i].cwmax); | 
|  | 5295 | if (system(buf) != 0) { | 
|  | 5296 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 5297 | "iwpriv cwmax failed"); | 
|  | 5298 | } | 
|  | 5299 |  | 
|  | 5300 | snprintf(buf, sizeof(buf), "iwpriv %s aifs %d 1 %d", | 
|  | 5301 | ifname, i, dut->ap_sta_qos[i].aifs); | 
|  | 5302 | if (system(buf) != 0) { | 
|  | 5303 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 5304 | "iwpriv aifs failed"); | 
|  | 5305 | } | 
|  | 5306 |  | 
|  | 5307 | snprintf(buf, sizeof(buf), | 
|  | 5308 | "iwpriv %s txoplimit %d 1 %d", | 
|  | 5309 | ifname, i, dut->ap_sta_qos[i].txop); | 
|  | 5310 | if (system(buf) != 0) { | 
|  | 5311 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 5312 | "iwpriv txoplimit failed"); | 
|  | 5313 | } | 
|  | 5314 |  | 
|  | 5315 | snprintf(buf, sizeof(buf), "iwpriv %s acm %d 1 %d", | 
|  | 5316 | ifname, i, dut->ap_sta_qos[i].acm); | 
|  | 5317 | if (system(buf) != 0) { | 
|  | 5318 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 5319 | "iwpriv acm failed"); | 
|  | 5320 | } | 
|  | 5321 | } | 
|  | 5322 | } | 
|  | 5323 |  | 
|  | 5324 | if (dut->ap_disable_protection == 1) { | 
|  | 5325 | snprintf(buf, sizeof(buf), "iwpriv %s enablertscts 0", ifname); | 
|  | 5326 | if (system(buf) != 0) { | 
|  | 5327 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 5328 | "iwpriv enablertscts failed"); | 
|  | 5329 | } | 
|  | 5330 | sigma_dut_print(dut, DUT_MSG_INFO, "Disabled rtscts"); | 
|  | 5331 | } | 
|  | 5332 |  | 
| Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 5333 | if (dut->ap_ldpc == VALUE_ENABLED) { | 
| Sarvepalli, Rajesh Babu | 580572a | 2016-11-29 22:07:14 +0530 | [diff] [blame] | 5334 | snprintf(buf, sizeof(buf), "iwpriv %s ldpc 3", ifname); | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5335 | if (system(buf) != 0) { | 
|  | 5336 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
| priyadharshini gowthaman | 15b299d | 2017-04-20 12:10:45 -0700 | [diff] [blame] | 5337 | "iwpriv ldpc 3 failed"); | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5338 | } | 
| Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 5339 | } else if (dut->ap_ldpc == VALUE_DISABLED) { | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5340 | snprintf(buf, sizeof(buf), "iwpriv %s ldpc 0", ifname); | 
|  | 5341 | if (system(buf) != 0) { | 
|  | 5342 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 5343 | "iwpriv ldpc 0 failed"); | 
|  | 5344 | } | 
|  | 5345 | } | 
|  | 5346 |  | 
| Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 5347 | if (dut->ap_ampdu == VALUE_ENABLED) { | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5348 | snprintf(buf, sizeof(buf), "iwpriv %s ampdu 1", ifname); | 
|  | 5349 | if (system(buf) != 0) { | 
|  | 5350 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 5351 | "iwpriv ampdu 1 failed"); | 
|  | 5352 | } | 
| Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 5353 | } else if (dut->ap_ampdu == VALUE_DISABLED) { | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5354 | snprintf(buf, sizeof(buf), "iwpriv %s ampdu 0", ifname); | 
|  | 5355 | if (system(buf) != 0) { | 
|  | 5356 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 5357 | "iwpriv ampdu 0 failed"); | 
|  | 5358 | } | 
|  | 5359 | } | 
|  | 5360 |  | 
|  | 5361 | if (dut->ap_ampdu_exp) { | 
|  | 5362 | if (dut->program == PROGRAM_VHT) { | 
|  | 5363 | snprintf(buf, sizeof(buf), "iwpriv %s vhtmaxampdu %d", | 
|  | 5364 | ifname, dut->ap_ampdu_exp); | 
|  | 5365 | if (system(buf) != 0) { | 
|  | 5366 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 5367 | "iwpriv vhtmaxampdu failed"); | 
|  | 5368 | } | 
|  | 5369 | } else { | 
|  | 5370 | /* 11N */ | 
|  | 5371 | snprintf(buf, sizeof(buf), "iwpriv %s maxampdu %d", | 
|  | 5372 | ifname, dut->ap_ampdu_exp); | 
|  | 5373 | if (system(buf) != 0) { | 
|  | 5374 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv maxampdu failed"); | 
|  | 5375 | } | 
|  | 5376 | } | 
|  | 5377 | } | 
|  | 5378 |  | 
| Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 5379 | if (dut->ap_noack == VALUE_ENABLED) { | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5380 | snprintf(buf, sizeof(buf), "iwpriv %s noackpolicy 0 0 1", ifname); | 
|  | 5381 | if (system(buf) != 0) { | 
|  | 5382 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv noackpolicy 0 0  1 failed"); | 
|  | 5383 | } | 
|  | 5384 | snprintf(buf, sizeof(buf), "iwpriv %s noackpolicy 1 0 1", ifname); | 
|  | 5385 | if (system(buf) != 0) { | 
|  | 5386 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv noackpolicy 1 0 1 failed"); | 
|  | 5387 | } | 
|  | 5388 | snprintf(buf, sizeof(buf), "iwpriv %s noackpolicy 2 0 1", ifname); | 
|  | 5389 | if (system(buf) != 0) { | 
|  | 5390 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv noackpolicy 2 0 1 failed"); | 
|  | 5391 | } | 
|  | 5392 | snprintf(buf, sizeof(buf), "iwpriv %s noackpolicy 3 0 1", ifname); | 
|  | 5393 | if (system(buf) != 0) { | 
|  | 5394 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv noackpolicy 3 0 1 failed"); | 
|  | 5395 | } | 
| Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 5396 | } else if (dut->ap_noack == VALUE_DISABLED) { | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5397 | snprintf(buf, sizeof(buf), "iwpriv %s noackpolicy 0 0 0", ifname); | 
|  | 5398 | if (system(buf) != 0) { | 
|  | 5399 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv noackpolicy 0 0 0 failed"); | 
|  | 5400 | } | 
|  | 5401 | snprintf(buf, sizeof(buf), "iwpriv %s noackpolicy 1 0 0", ifname); | 
|  | 5402 | if (system(buf) != 0) { | 
|  | 5403 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv noackpolicy 1 0 0 failed"); | 
|  | 5404 | } | 
|  | 5405 | snprintf(buf, sizeof(buf), "iwpriv %s noackpolicy 2 0 0", ifname); | 
|  | 5406 | if (system(buf) != 0) { | 
|  | 5407 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv noackpolicy 2 0 0 failed"); | 
|  | 5408 | } | 
|  | 5409 | snprintf(buf, sizeof(buf), "iwpriv %s noackpolicy 3 0 0", ifname); | 
|  | 5410 | if (system(buf) != 0) { | 
|  | 5411 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv noackpolicy 3 0 0 failed"); | 
|  | 5412 | } | 
|  | 5413 | } | 
|  | 5414 |  | 
|  | 5415 | if (dut->device_type == AP_testbed && dut->ap_vhtmcs_map) { | 
|  | 5416 | snprintf(buf, sizeof(buf), "iwpriv %s vht_mcsmap 0x%04x", | 
|  | 5417 | ifname, dut->ap_vhtmcs_map); | 
|  | 5418 | if (system(buf) != 0) { | 
|  | 5419 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 5420 | "iwpriv vht_mcsmap failed"); | 
|  | 5421 | } | 
|  | 5422 | } | 
|  | 5423 |  | 
| Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 5424 | if (dut->ap_amsdu == VALUE_ENABLED) { | 
| Sunil Dutt | 27ec7f6 | 2017-09-14 18:22:59 +0300 | [diff] [blame] | 5425 | snprintf(buf, sizeof(buf), "iwpriv %s amsdu 2", ifname); | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5426 | if (system(buf) != 0) { | 
| Sunil Dutt | 27ec7f6 | 2017-09-14 18:22:59 +0300 | [diff] [blame] | 5427 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv amsdu 2 failed"); | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5428 | } | 
| Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 5429 | } else if (dut->ap_amsdu == VALUE_DISABLED) { | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5430 | snprintf(buf, sizeof(buf), "iwpriv %s amsdu 1", ifname); | 
|  | 5431 | if (system(buf) != 0) { | 
|  | 5432 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv amsdu 1 failed"); | 
|  | 5433 | } | 
|  | 5434 | } | 
|  | 5435 |  | 
| Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 5436 | if (dut->ap_rx_amsdu == VALUE_ENABLED) { | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5437 | snprintf(buf, sizeof(buf), "iwpriv wifi1 rx_amsdu 1"); | 
|  | 5438 | if (system(buf) != 0) { | 
|  | 5439 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv rx_amsdu 1 failed"); | 
|  | 5440 | } | 
| Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 5441 | } else if (dut->ap_rx_amsdu == VALUE_DISABLED) { | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5442 | snprintf(buf, sizeof(buf), "iwpriv wifi1 rx_amsdu 0"); | 
|  | 5443 | if (system(buf) != 0) { | 
|  | 5444 | sigma_dut_print(dut, DUT_MSG_ERROR, "iwpriv rx_amsdu 0 failed"); | 
|  | 5445 | } | 
|  | 5446 | } | 
|  | 5447 |  | 
|  | 5448 | /* Command sequence to generate single VHT AMSDU and MPDU */ | 
| Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 5449 | if (dut->ap_addba_reject != VALUE_NOT_SET && | 
|  | 5450 | dut->ap_ampdu == VALUE_DISABLED && | 
|  | 5451 | dut->ap_amsdu == VALUE_ENABLED) { | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5452 | snprintf(buf, sizeof(buf), "iwpriv %s setaddbaoper 1", ifname); | 
|  | 5453 | if (system(buf) != 0) { | 
|  | 5454 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 5455 | "iwpriv setaddbaoper 1 failed"); | 
|  | 5456 | } | 
|  | 5457 |  | 
|  | 5458 | snprintf(buf, sizeof(buf), | 
|  | 5459 | "wifitool %s senddelba 1 0 1 4", ifname); | 
|  | 5460 | if (system(buf) != 0) { | 
|  | 5461 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 5462 | "wifitool senddelba failed"); | 
|  | 5463 | } | 
|  | 5464 |  | 
|  | 5465 | snprintf(buf, sizeof(buf), "wifitool %s sendsingleamsdu 1 0", | 
|  | 5466 | ifname); | 
|  | 5467 | if (system(buf) != 0) { | 
|  | 5468 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 5469 | "wifitool sendsingleamsdu failed"); | 
|  | 5470 | } | 
|  | 5471 |  | 
|  | 5472 | snprintf(buf, sizeof(buf), "iwpriv %s amsdu 10", ifname); | 
|  | 5473 | if (system(buf) != 0) { | 
|  | 5474 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 5475 | "iwpriv amsdu failed"); | 
|  | 5476 | } | 
|  | 5477 | } | 
|  | 5478 |  | 
|  | 5479 | if (dut->ap_mode == AP_11ac) { | 
|  | 5480 | int chwidth, nss; | 
|  | 5481 |  | 
|  | 5482 | switch (dut->ap_chwidth) { | 
|  | 5483 | case AP_20: | 
|  | 5484 | chwidth = 0; | 
|  | 5485 | break; | 
|  | 5486 | case AP_40: | 
|  | 5487 | chwidth = 1; | 
|  | 5488 | break; | 
|  | 5489 | case AP_80: | 
|  | 5490 | chwidth = 2; | 
|  | 5491 | break; | 
|  | 5492 | case AP_160: | 
|  | 5493 | chwidth = 3; | 
|  | 5494 | break; | 
| priyadharshini gowthaman | 63ab848 | 2017-12-28 15:32:55 -0800 | [diff] [blame] | 5495 | case AP_80_80: | 
|  | 5496 | chwidth = 3; | 
|  | 5497 | break; | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5498 | default: | 
|  | 5499 | chwidth = 0; | 
|  | 5500 | break; | 
|  | 5501 | } | 
|  | 5502 |  | 
|  | 5503 | switch (dut->ap_tx_streams) { | 
|  | 5504 | case 1: | 
|  | 5505 | nss = 1; | 
|  | 5506 | break; | 
|  | 5507 | case 2: | 
|  | 5508 | nss = 2; | 
|  | 5509 | break; | 
|  | 5510 | case 3: | 
|  | 5511 | nss = 3; | 
|  | 5512 | break; | 
|  | 5513 | case 4: | 
|  | 5514 | nss = 4; | 
|  | 5515 | break; | 
|  | 5516 | default: | 
|  | 5517 | nss = 3; | 
|  | 5518 | break; | 
|  | 5519 | } | 
|  | 5520 |  | 
|  | 5521 | if (dut->ap_fixed_rate) { | 
|  | 5522 | if (nss == 4) | 
|  | 5523 | ath_disable_txbf(dut, ifname); | 
|  | 5524 |  | 
|  | 5525 | /* Set the nss */ | 
|  | 5526 | snprintf(buf, sizeof(buf), "iwpriv %s nss %d", | 
|  | 5527 | ifname, nss); | 
|  | 5528 | if (system(buf) != 0) { | 
|  | 5529 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 5530 | "iwpriv nss failed"); | 
|  | 5531 | } | 
|  | 5532 |  | 
|  | 5533 | /* Set the channel width */ | 
|  | 5534 | snprintf(buf, sizeof(buf), "iwpriv %s chwidth %d", | 
|  | 5535 | ifname, chwidth); | 
|  | 5536 | if (system(buf) != 0) { | 
|  | 5537 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 5538 | "iwpriv chwidth failed"); | 
|  | 5539 | } | 
|  | 5540 |  | 
|  | 5541 | /* Set the VHT MCS */ | 
|  | 5542 | snprintf(buf, sizeof(buf), "iwpriv %s vhtmcs %d", | 
|  | 5543 | ifname, dut->ap_mcs); | 
|  | 5544 | if (system(buf) != 0) { | 
|  | 5545 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 5546 | "iwpriv vhtmcs failed"); | 
|  | 5547 | } | 
|  | 5548 | } | 
|  | 5549 | } | 
|  | 5550 |  | 
| Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 5551 | if (dut->ap_dyn_bw_sig == VALUE_ENABLED) { | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5552 | snprintf(buf, sizeof(buf), "iwpriv %s cwmenable 1", ifname); | 
|  | 5553 | if (system(buf) != 0) { | 
|  | 5554 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 5555 | "iwpriv cwmenable 1 failed"); | 
|  | 5556 | } | 
| Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 5557 | } else if (dut->ap_dyn_bw_sig == VALUE_DISABLED) { | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5558 | snprintf(buf, sizeof(buf), "iwpriv %s cwmenable 0", ifname); | 
|  | 5559 | if (system(buf) != 0) { | 
|  | 5560 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 5561 | "iwpriv cwmenable 0 failed"); | 
|  | 5562 | } | 
|  | 5563 | } | 
|  | 5564 |  | 
| Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 5565 | if (dut->ap_sig_rts == VALUE_ENABLED) { | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5566 | snprintf(buf, sizeof(buf), "iwconfig %s rts 64", ifname); | 
|  | 5567 | if (system(buf) != 0) { | 
|  | 5568 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 5569 | "iwconfig rts 64 failed"); | 
|  | 5570 | } | 
| Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 5571 | } else if (dut->ap_sig_rts == VALUE_DISABLED) { | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 5572 | snprintf(buf, sizeof(buf), "iwconfig %s rts 2347", ifname); | 
|  | 5573 | if (system(buf) != 0) { | 
|  | 5574 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 5575 | "iwpriv rts 2347 failed"); | 
|  | 5576 | } | 
|  | 5577 | } | 
|  | 5578 |  | 
|  | 5579 | if (dut->ap_hs2) { | 
|  | 5580 | snprintf(buf, sizeof(buf), "iwpriv %s qbssload 1", ifname); | 
|  | 5581 | if (system(buf) != 0) { | 
|  | 5582 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 5583 | "iwpriv qbssload failed"); | 
|  | 5584 | } | 
|  | 5585 | sigma_dut_print(dut, DUT_MSG_INFO, "Enabled qbssload"); | 
|  | 5586 | } | 
|  | 5587 |  | 
|  | 5588 | if (dut->ap_bss_load && dut->ap_bss_load != -1) { | 
|  | 5589 | unsigned int bssload = 0; | 
|  | 5590 |  | 
|  | 5591 | if (dut->ap_bss_load == 1) { | 
|  | 5592 | /* STA count: 1, CU: 50, AAC: 65535 */ | 
|  | 5593 | bssload = 0x0132ffff; | 
|  | 5594 | } else if (dut->ap_bss_load == 2) { | 
|  | 5595 | /* STA count: 1, CU: 200, AAC: 65535 */ | 
|  | 5596 | bssload = 0x01c8ffff; | 
|  | 5597 | } else if (dut->ap_bss_load == 3) { | 
|  | 5598 | /* STA count: 1, CU: 75, AAC: 65535 */ | 
|  | 5599 | bssload = 0x014bffff; | 
|  | 5600 | } | 
|  | 5601 |  | 
|  | 5602 | snprintf(buf, sizeof(buf), "iwpriv %s hcbssload %u", | 
|  | 5603 | ifname, bssload); | 
|  | 5604 | if (system(buf) != 0) { | 
|  | 5605 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 5606 | "iwpriv hcbssload failed"); | 
|  | 5607 | } | 
|  | 5608 | } else if (dut->ap_bss_load == 0) { | 
|  | 5609 | snprintf(buf, sizeof(buf), "iwpriv %s qbssload 0", ifname); | 
|  | 5610 | if (system(buf) != 0) { | 
|  | 5611 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 5612 | "iwpriv qbssload failed"); | 
|  | 5613 | } | 
|  | 5614 | sigma_dut_print(dut, DUT_MSG_INFO, "Disabled qbssload"); | 
|  | 5615 | } | 
|  | 5616 |  | 
|  | 5617 | if (dut->ap_dgaf_disable) { | 
|  | 5618 | snprintf(buf, sizeof(buf), "iwpriv %s dgaf_disable 1", ifname); | 
|  | 5619 | if (system(buf) != 0) { | 
|  | 5620 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 5621 | "iwpriv dgaf_disable failed"); | 
|  | 5622 | } | 
|  | 5623 | sigma_dut_print(dut, DUT_MSG_INFO, "Enabled dgaf_disable"); | 
|  | 5624 | } | 
|  | 5625 |  | 
|  | 5626 | if (dut->ap_l2tif) { | 
|  | 5627 | snprintf(buf, sizeof(buf), "iwpriv %s l2tif 1", ifname); | 
|  | 5628 | if (system(buf) != 0) { | 
|  | 5629 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 5630 | "iwpriv l2tif failed"); | 
|  | 5631 | } | 
|  | 5632 | snprintf(buf, sizeof(buf), | 
|  | 5633 | "echo 1 > /sys/class/net/br0/brif/ath0/hotspot_l2tif"); | 
|  | 5634 | if (system(buf) != 0) | 
|  | 5635 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 5636 | "l2tif br failed"); | 
|  | 5637 |  | 
|  | 5638 | snprintf(buf, sizeof(buf), | 
|  | 5639 | "echo 1 > /sys/class/net/br0/brif/eth0/hotspot_wan"); | 
|  | 5640 | if (system(buf) != 0) | 
|  | 5641 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 5642 | "l2tif brif failed"); | 
|  | 5643 | sigma_dut_print(dut, DUT_MSG_INFO, "Enabled l2tif"); | 
|  | 5644 | } | 
| priyadharshini gowthaman | 264d544 | 2016-02-25 15:52:22 -0800 | [diff] [blame] | 5645 |  | 
|  | 5646 | if (dut->ap_ndpa_frame == 0) { | 
|  | 5647 | snprintf(buf, sizeof(buf), | 
|  | 5648 | "wifitool %s beeliner_fw_test 117 192", ifname); | 
|  | 5649 | if (system(buf) != 0) { | 
|  | 5650 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 5651 | "wifitool beeliner_fw_test 117 192 failed"); | 
|  | 5652 | } | 
|  | 5653 | snprintf(buf, sizeof(buf), | 
|  | 5654 | "wifitool %s beeliner_fw_test 118 192", ifname); | 
|  | 5655 | if (system(buf) != 0) { | 
|  | 5656 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 5657 | "wifitool beeliner_fw_test 117 192 failed"); | 
|  | 5658 | } | 
|  | 5659 | } else if (dut->ap_ndpa_frame == 1) { | 
|  | 5660 | /* Driver default - no changes needed */ | 
|  | 5661 | } else if (dut->ap_ndpa_frame == 2) { | 
|  | 5662 | snprintf(buf, sizeof(buf), | 
|  | 5663 | "wifitool %s beeliner_fw_test 115 1", ifname); | 
|  | 5664 | if (system(buf) != 0) { | 
|  | 5665 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 5666 | "wifitool beeliner_fw_test 117 192 failed"); | 
|  | 5667 | } | 
|  | 5668 | snprintf(buf, sizeof(buf), | 
|  | 5669 | "wifitool %s beeliner_fw_test 116 1", ifname); | 
|  | 5670 | if (system(buf) != 0) { | 
|  | 5671 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 5672 | "wifitool beeliner_fw_test 117 192 failed"); | 
|  | 5673 | } | 
|  | 5674 | } | 
| priyadharshini gowthaman | 8e26ff4 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 5675 |  | 
|  | 5676 | if (dut->ap_rtt == 1) { | 
|  | 5677 | snprintf(buf, sizeof(buf), "iwpriv %s enable_rtt 1", ifname); | 
|  | 5678 | run_system(dut, buf); | 
|  | 5679 | } | 
|  | 5680 |  | 
|  | 5681 | if (dut->ap_lci == 1) { | 
|  | 5682 | snprintf(buf, sizeof(buf), "iwpriv %s enable_lci 1", ifname); | 
|  | 5683 | run_system(dut, buf); | 
|  | 5684 | } | 
|  | 5685 |  | 
|  | 5686 | if (dut->ap_lcr == 1) { | 
|  | 5687 | snprintf(buf, sizeof(buf), "iwpriv %s enable_lcr 1", ifname); | 
|  | 5688 | run_system(dut, buf); | 
|  | 5689 | } | 
|  | 5690 |  | 
|  | 5691 | if (dut->ap_rrm == 1) { | 
|  | 5692 | snprintf(buf, sizeof(buf), "iwpriv %s rrm 1", ifname); | 
|  | 5693 | run_system(dut, buf); | 
|  | 5694 | } | 
|  | 5695 |  | 
|  | 5696 | if (dut->ap_lci == 1 || dut->ap_lcr == 1) { | 
|  | 5697 | run_system(dut, "wpc -l /tmp/lci_cfg.txt"); | 
|  | 5698 | } | 
|  | 5699 |  | 
|  | 5700 | if (dut->ap_neighap >= 1 && dut->ap_lci == 0) { | 
|  | 5701 | FILE *f; | 
|  | 5702 |  | 
|  | 5703 | f = fopen("/tmp/nbr_report.txt", "w"); | 
|  | 5704 | if (!f) { | 
|  | 5705 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 5706 | "Failed to open /tmp/nbr_report.txt"); | 
|  | 5707 | return; | 
|  | 5708 | } | 
|  | 5709 |  | 
|  | 5710 | fprintf(f, | 
|  | 5711 | "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", | 
|  | 5712 | dut->ap_val_neighap[0][0], dut->ap_val_neighap[0][1], | 
|  | 5713 | dut->ap_val_neighap[0][2], dut->ap_val_neighap[0][3], | 
|  | 5714 | dut->ap_val_neighap[0][4], dut->ap_val_neighap[0][5], | 
|  | 5715 | dut->ap_val_opchannel[0]); | 
|  | 5716 | fclose(f); | 
|  | 5717 |  | 
|  | 5718 | f = fopen("/tmp/ftmrr.txt", "w"); | 
|  | 5719 | if (!f) { | 
|  | 5720 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 5721 | "Failed to open /tmp/ftmrr.txt"); | 
|  | 5722 | return; | 
|  | 5723 | } | 
|  | 5724 |  | 
|  | 5725 | fprintf(f, | 
|  | 5726 | "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", | 
|  | 5727 | dut->ap_val_neighap[0][0], dut->ap_val_neighap[0][1], | 
|  | 5728 | dut->ap_val_neighap[0][2], dut->ap_val_neighap[0][3], | 
|  | 5729 | dut->ap_val_neighap[0][4], dut->ap_val_neighap[0][5], | 
|  | 5730 | dut->ap_val_opchannel[0]); | 
|  | 5731 | fclose(f); | 
|  | 5732 | } | 
|  | 5733 |  | 
|  | 5734 | if (dut->ap_neighap >= 2 && dut->ap_lci == 0) { | 
|  | 5735 | FILE *f; | 
|  | 5736 |  | 
|  | 5737 | f = fopen("/tmp/nbr_report.txt", "a"); | 
|  | 5738 | if (!f) { | 
|  | 5739 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 5740 | "Failed to open /tmp/nbr_report.txt"); | 
|  | 5741 | return; | 
|  | 5742 | } | 
|  | 5743 | fprintf(f, | 
|  | 5744 | "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", | 
|  | 5745 | dut->ap_val_neighap[1][0], dut->ap_val_neighap[1][1], | 
|  | 5746 | dut->ap_val_neighap[1][2], dut->ap_val_neighap[1][3], | 
|  | 5747 | dut->ap_val_neighap[1][4], dut->ap_val_neighap[1][5], | 
|  | 5748 | dut->ap_val_opchannel[1]); | 
|  | 5749 | fclose(f); | 
|  | 5750 |  | 
|  | 5751 | f = fopen("/tmp/ftmrr.txt", "a"); | 
|  | 5752 | if (!f) { | 
|  | 5753 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 5754 | "Failed to open /tmp/ftmrr.txt"); | 
|  | 5755 | return; | 
|  | 5756 | } | 
|  | 5757 | fprintf(f, | 
|  | 5758 | "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", | 
|  | 5759 | dut->ap_val_neighap[1][0], dut->ap_val_neighap[1][1], | 
|  | 5760 | dut->ap_val_neighap[1][2], dut->ap_val_neighap[1][3], | 
|  | 5761 | dut->ap_val_neighap[1][4], dut->ap_val_neighap[1][5], | 
|  | 5762 | dut->ap_val_opchannel[1]); | 
|  | 5763 | fclose(f); | 
|  | 5764 | } | 
|  | 5765 |  | 
|  | 5766 | if (dut->ap_neighap >= 3 && dut->ap_lci == 0) { | 
|  | 5767 | FILE *f; | 
|  | 5768 |  | 
|  | 5769 | f = fopen("/tmp/nbr_report.txt", "a"); | 
|  | 5770 | if (!f) { | 
|  | 5771 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 5772 | "Failed to open /tmp/nbr_report.txt"); | 
|  | 5773 | return; | 
|  | 5774 | } | 
|  | 5775 |  | 
|  | 5776 | fprintf(f, | 
|  | 5777 | "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", | 
|  | 5778 | dut->ap_val_neighap[2][0], dut->ap_val_neighap[2][1], | 
|  | 5779 | dut->ap_val_neighap[2][2], dut->ap_val_neighap[2][3], | 
|  | 5780 | dut->ap_val_neighap[2][4], dut->ap_val_neighap[2][5], | 
|  | 5781 | dut->ap_val_opchannel[2]); | 
|  | 5782 | fclose(f); | 
|  | 5783 |  | 
|  | 5784 | f = fopen("/tmp/ftmrr.txt", "a"); | 
|  | 5785 | if (!f) { | 
|  | 5786 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 5787 | "Failed to open /tmp/ftmrr.txt"); | 
|  | 5788 | return; | 
|  | 5789 | } | 
|  | 5790 |  | 
|  | 5791 | fprintf(f, | 
|  | 5792 | "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", | 
|  | 5793 | dut->ap_val_neighap[2][0], dut->ap_val_neighap[2][1], | 
|  | 5794 | dut->ap_val_neighap[2][2], dut->ap_val_neighap[2][3], | 
|  | 5795 | dut->ap_val_neighap[2][4], dut->ap_val_neighap[2][5], | 
|  | 5796 | dut->ap_val_opchannel[2]); | 
|  | 5797 | fclose(f); | 
|  | 5798 | } | 
|  | 5799 |  | 
|  | 5800 | if (dut->ap_neighap) { | 
|  | 5801 | snprintf(buf, sizeof(buf), "iwpriv %s enable_rtt 1", ifname); | 
|  | 5802 | run_system(dut, buf); | 
|  | 5803 | snprintf(buf, sizeof(buf), "iwpriv %s enable_lci 1", ifname); | 
|  | 5804 | run_system(dut, buf); | 
|  | 5805 | snprintf(buf, sizeof(buf), "iwpriv %s enable_lcr 1", ifname); | 
|  | 5806 | run_system(dut, buf); | 
|  | 5807 | snprintf(buf, sizeof(buf), "iwpriv %s rrm 1", ifname); | 
|  | 5808 | run_system(dut, buf); | 
|  | 5809 | } | 
|  | 5810 |  | 
|  | 5811 | if (dut->ap_scan == 1) { | 
|  | 5812 | snprintf(buf, sizeof(buf), "iwpriv %s scanentryage 600", | 
|  | 5813 | ifname); | 
|  | 5814 | run_system(dut, buf); | 
|  | 5815 | snprintf(buf, sizeof(buf), "iwlist %s scan", ifname); | 
|  | 5816 | run_system(dut, buf); | 
|  | 5817 | } | 
| priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 5818 |  | 
|  | 5819 | if (dut->ap_set_bssidpref) { | 
|  | 5820 | snprintf(buf, sizeof(buf), | 
|  | 5821 | "wifitool %s setbssidpref 00:00:00:00:00:00 0 00 00", | 
|  | 5822 | ifname); | 
|  | 5823 | if (system(buf) != 0) { | 
|  | 5824 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 5825 | "wifitool clear bssidpref failed"); | 
|  | 5826 | } | 
|  | 5827 | } | 
| Adil Saeed Musthafa | 33ea287 | 2017-04-10 23:13:24 -0700 | [diff] [blame] | 5828 |  | 
|  | 5829 | if (dut->wnm_bss_max_feature != VALUE_NOT_SET) { | 
|  | 5830 | int feature_enable; | 
|  | 5831 |  | 
|  | 5832 | feature_enable = dut->wnm_bss_max_feature == VALUE_ENABLED; | 
|  | 5833 | snprintf(buf, sizeof(buf), "iwpriv %s wnm %d", | 
|  | 5834 | ifname, feature_enable); | 
|  | 5835 | run_system(dut, buf); | 
|  | 5836 | snprintf(buf, sizeof(buf), "iwpriv %s wnm_bss %d", | 
|  | 5837 | ifname, feature_enable); | 
|  | 5838 | run_system(dut, buf); | 
|  | 5839 | if (feature_enable) { | 
|  | 5840 | const char *extra = ""; | 
|  | 5841 |  | 
|  | 5842 | if (dut->wnm_bss_max_protection != VALUE_NOT_SET) { | 
|  | 5843 | if (dut->wnm_bss_max_protection == | 
|  | 5844 | VALUE_ENABLED) | 
|  | 5845 | extra = " 1"; | 
|  | 5846 | else | 
|  | 5847 | extra = " 0"; | 
|  | 5848 | } | 
|  | 5849 | snprintf(buf, sizeof(buf), | 
|  | 5850 | "wlanconfig %s wnm setbssmax %d%s", | 
|  | 5851 | ifname, dut->wnm_bss_max_idle_time, extra); | 
|  | 5852 | run_system(dut, buf); | 
|  | 5853 | } | 
|  | 5854 | } | 
| Adil Saeed Musthafa | 05ec744 | 2017-04-10 23:13:35 -0700 | [diff] [blame] | 5855 |  | 
| Adil Saeed Musthafa | 023108a | 2017-04-10 23:13:37 -0700 | [diff] [blame] | 5856 | if (dut->program == PROGRAM_MBO) { | 
| Adil Saeed Musthafa | 6906372 | 2017-04-10 23:13:40 -0700 | [diff] [blame] | 5857 | apply_mbo_pref_ap_list(dut); | 
|  | 5858 |  | 
| Adil Saeed Musthafa | 023108a | 2017-04-10 23:13:37 -0700 | [diff] [blame] | 5859 | snprintf(buf, sizeof(buf), "iwpriv %s mbo_cel_pref %d", | 
|  | 5860 | ifname, dut->ap_cell_cap_pref); | 
|  | 5861 | run_system(dut, buf); | 
| Adil Saeed Musthafa | 16d9e63 | 2017-04-10 23:13:38 -0700 | [diff] [blame] | 5862 |  | 
|  | 5863 | snprintf(buf, sizeof(buf), "iwpriv %s mbocap 0x40", ifname); | 
|  | 5864 | run_system(dut, buf); | 
|  | 5865 |  | 
| Adil Saeed Musthafa | 05ec744 | 2017-04-10 23:13:35 -0700 | [diff] [blame] | 5866 | ath_set_assoc_disallow(dut, ifname, "disable"); | 
| Adil Saeed Musthafa | 023108a | 2017-04-10 23:13:37 -0700 | [diff] [blame] | 5867 | } | 
| priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 5868 |  | 
|  | 5869 | if (dut->ap_oce == VALUE_ENABLED) { | 
|  | 5870 | snprintf(buf, sizeof(buf), "iwpriv %s set_bpr_enable 1", | 
|  | 5871 | ifname); | 
|  | 5872 | run_system(dut, buf); | 
|  | 5873 | } | 
|  | 5874 |  | 
|  | 5875 | if (dut->ap_oce == VALUE_ENABLED && dut->ap_channel <= 11) { | 
|  | 5876 | snprintf(buf, sizeof(buf), "iwpriv %s prb_rate 5500", ifname); | 
|  | 5877 | run_system(dut, buf); | 
|  | 5878 | snprintf(buf, sizeof(buf), "iwpriv %s set_bcn_rate 5500", | 
|  | 5879 | ifname); | 
|  | 5880 | run_system(dut, buf); | 
|  | 5881 | } | 
|  | 5882 |  | 
|  | 5883 | if (dut->ap_oce == VALUE_DISABLED) { | 
|  | 5884 | snprintf(buf, sizeof(buf), "iwpriv %s set_bpr_enable 0", | 
|  | 5885 | ifname); | 
|  | 5886 | run_system(dut, buf); | 
|  | 5887 | } | 
|  | 5888 |  | 
|  | 5889 | if (dut->ap_oce == VALUE_DISABLED && dut->ap_channel <= 11) { | 
|  | 5890 | snprintf(buf, sizeof(buf), "iwpriv %s mgmt_rate 1000", ifname); | 
|  | 5891 | run_system(dut, buf); | 
|  | 5892 | snprintf(buf, sizeof(buf), "iwpriv %s set_bcn_rate 1000", | 
|  | 5893 | ifname); | 
|  | 5894 | run_system(dut, buf); | 
|  | 5895 | } | 
|  | 5896 |  | 
|  | 5897 | if (dut->ap_bcnint) { | 
|  | 5898 | snprintf(buf, sizeof(buf), "iwpriv %s bintval %d", ifname, | 
|  | 5899 | dut->ap_bcnint); | 
|  | 5900 | run_system(dut, buf); | 
|  | 5901 | } | 
|  | 5902 |  | 
|  | 5903 | if (dut->ap_filsdscv == VALUE_DISABLED) { | 
|  | 5904 | snprintf(buf, sizeof(buf), "iwpriv %s enable_fils 0 0", ifname); | 
|  | 5905 | run_system(dut, buf); | 
|  | 5906 | } | 
|  | 5907 |  | 
|  | 5908 | if (dut->ap_filshlp == VALUE_ENABLED) { | 
|  | 5909 | snprintf(buf, sizeof(buf), "iwpriv %s oce_hlp 1", ifname); | 
|  | 5910 | if (system(buf) != 0) { | 
|  | 5911 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 5912 | "iwpriv filshlp enable failed"); | 
|  | 5913 | } | 
|  | 5914 | } else if (dut->ap_filshlp == VALUE_DISABLED) { | 
|  | 5915 | snprintf(buf, sizeof(buf), "iwpriv %s oce_hlp 0", ifname); | 
|  | 5916 | if (system(buf) != 0) { | 
|  | 5917 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 5918 | "iwpriv filshlp disable failed"); | 
|  | 5919 | } | 
|  | 5920 | } | 
|  | 5921 |  | 
|  | 5922 | /*  When RNR is enabled, also enable apchannelreport, background scan */ | 
|  | 5923 | if (dut->ap_rnr == VALUE_ENABLED) { | 
|  | 5924 | snprintf(buf, sizeof(buf), "iwpriv %s rnr 1", ifname); | 
|  | 5925 | run_system(dut, buf); | 
|  | 5926 | snprintf(buf, sizeof(buf), "iwpriv %s rnr_tbtt 1", ifname); | 
|  | 5927 | run_system(dut, buf); | 
|  | 5928 | snprintf(buf, sizeof(buf), "iwpriv %s apchanrpt 1", ifname); | 
|  | 5929 | run_system(dut, buf); | 
|  | 5930 | snprintf(buf, sizeof(buf), "iwpriv %s acs_ctrlflags 0x4", | 
|  | 5931 | basedev); | 
|  | 5932 | run_system(dut, buf); | 
|  | 5933 | snprintf(buf, sizeof(buf), "iwpriv %s acs_scanintvl 60", | 
|  | 5934 | basedev); | 
|  | 5935 | run_system(dut, buf); | 
|  | 5936 | snprintf(buf, sizeof(buf), "iwpriv %s acs_bkscanen 1", basedev); | 
|  | 5937 | run_system(dut, buf); | 
|  | 5938 | if (dut->ap_is_dual == 1) { | 
|  | 5939 | snprintf(buf, sizeof(buf), "iwpriv %s rnr 1", | 
|  | 5940 | ifname_dual); | 
|  | 5941 | run_system(dut, buf); | 
|  | 5942 | snprintf(buf, sizeof(buf), "iwpriv %s rnr_tbtt 1", | 
|  | 5943 | ifname_dual); | 
|  | 5944 | run_system(dut, buf); | 
|  | 5945 | snprintf(buf, sizeof(buf), "iwpriv %s apchanrpt 1", | 
|  | 5946 | ifname_dual); | 
|  | 5947 | run_system(dut, buf); | 
|  | 5948 | snprintf(buf, sizeof(buf), | 
|  | 5949 | "iwpriv %s acs_ctrlflags 0x4", basedev_radio); | 
|  | 5950 | run_system(dut, buf); | 
|  | 5951 | snprintf(buf, sizeof(buf), "iwpriv %s acs_scanintvl 60", | 
|  | 5952 | basedev_radio); | 
|  | 5953 | run_system(dut, buf); | 
|  | 5954 | snprintf(buf, sizeof(buf), "iwpriv %s acs_bkscanen 1", | 
|  | 5955 | basedev_radio); | 
|  | 5956 | run_system(dut, buf); | 
|  | 5957 | } | 
|  | 5958 | } | 
|  | 5959 |  | 
|  | 5960 | if (dut->ap_blechanutil || dut->ap_ble_admit_cap || dut->ap_blestacnt) { | 
|  | 5961 | snprintf(buf, sizeof(buf), "iwpriv %s qbssload 0", ifname); | 
|  | 5962 | run_system(dut, buf); | 
|  | 5963 | snprintf(buf, sizeof(buf), | 
|  | 5964 | "wlanconfig %s addie ftype 0 len 7 data 0b05%02x%02x%02x%02x%02x ", | 
|  | 5965 | ifname, dut->ap_blestacnt & 0xFF, | 
|  | 5966 | dut->ap_blestacnt >> 8, dut->ap_blechanutil, | 
|  | 5967 | dut->ap_ble_admit_cap & 0xFF, | 
|  | 5968 | dut->ap_ble_admit_cap >> 8); | 
|  | 5969 | run_system(dut, buf); | 
|  | 5970 | snprintf(buf, sizeof(buf), | 
|  | 5971 | "wlanconfig %s addie ftype 2 len 7 data 0b05%02x%02x%02x%02x%02x ", | 
|  | 5972 | ifname, dut->ap_blestacnt & 0xFF, | 
|  | 5973 | dut->ap_blestacnt >> 8, dut->ap_blechanutil, | 
|  | 5974 | dut->ap_ble_admit_cap & 0xFF, | 
|  | 5975 | dut->ap_ble_admit_cap >> 8); | 
|  | 5976 | run_system(dut, buf); | 
|  | 5977 | } | 
|  | 5978 |  | 
|  | 5979 | if (dut->ap_esp == VALUE_ENABLED) { | 
|  | 5980 | snprintf(buf, sizeof(buf), "iwpriv %s esp_period 5", basedev); | 
|  | 5981 | if (system(buf) != 0) { | 
|  | 5982 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 5983 | "iwpriv esp enable failed"); | 
|  | 5984 | } | 
|  | 5985 | } else if (dut->ap_esp == VALUE_DISABLED) { | 
|  | 5986 | snprintf(buf, sizeof(buf), "iwpriv %s esp_period 0", basedev); | 
|  | 5987 | if (system(buf) != 0) { | 
|  | 5988 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 5989 | "iwpriv esp disable failed"); | 
|  | 5990 | } | 
|  | 5991 | } | 
|  | 5992 |  | 
|  | 5993 | if (dut->ap_datappdudura) { | 
|  | 5994 | snprintf(buf, sizeof(buf), "iwpriv %s esp_ppdu_dur %d", basedev, | 
|  | 5995 | dut->ap_datappdudura); | 
|  | 5996 | run_system(dut, buf); | 
|  | 5997 | } | 
|  | 5998 |  | 
|  | 5999 | if (dut->ap_airtimefract) { | 
|  | 6000 | snprintf(buf, sizeof(buf), "iwpriv %s esp_airtime %d", basedev, | 
|  | 6001 | dut->ap_airtimefract); | 
|  | 6002 | run_system(dut, buf); | 
|  | 6003 | } | 
|  | 6004 |  | 
|  | 6005 | if (dut->ap_dhcp_stop) { | 
|  | 6006 | snprintf(buf, sizeof(buf), "/etc/init.d/dnsmasq stop"); | 
|  | 6007 | run_system(dut, buf); | 
|  | 6008 | } | 
|  | 6009 |  | 
|  | 6010 | if (dut->ap_bawinsize) { | 
|  | 6011 | snprintf(buf, sizeof(buf), "iwpriv %s esp_ba_window %d", | 
|  | 6012 | basedev, dut->ap_bawinsize); | 
|  | 6013 | run_system(dut, buf); | 
|  | 6014 | } | 
| priyadharshini gowthaman | b4de196 | 2018-01-15 12:21:04 -0800 | [diff] [blame] | 6015 |  | 
|  | 6016 | if (dut->program == PROGRAM_DPP) { | 
|  | 6017 | if (dut->ap_interface_2g == 1) { | 
|  | 6018 | snprintf(buf, sizeof(buf), | 
|  | 6019 | "iwpriv %s set_bcn_rate  5500", ifname); | 
|  | 6020 | run_system(dut, buf); | 
|  | 6021 | snprintf(buf, sizeof(buf), | 
|  | 6022 | "iwpriv %s prb_rate  5500", ifname); | 
|  | 6023 | run_system(dut, buf); | 
|  | 6024 | snprintf(buf, sizeof(buf), | 
|  | 6025 | "iwpriv %s mgmt_rate 5500", ifname); | 
|  | 6026 | run_system(dut, buf); | 
|  | 6027 | } | 
|  | 6028 |  | 
|  | 6029 | snprintf(buf, sizeof(buf), "iwpriv %s set_rxfilter 0xffffffff", | 
|  | 6030 | basedev); | 
|  | 6031 | run_system(dut, buf); | 
|  | 6032 | dut->hostapd_running = 1; | 
|  | 6033 | } | 
| priyadharshini gowthaman | 350f191 | 2018-06-04 13:09:12 -0700 | [diff] [blame] | 6034 |  | 
|  | 6035 | if (dut->ap_he_ppdu == PPDU_MU) { | 
|  | 6036 | run_system_wrapper( | 
|  | 6037 | dut, "wifitool %s setUnitTestCmd 0x47 2 11 1000000", | 
|  | 6038 | ifname); | 
|  | 6039 | run_system_wrapper( | 
|  | 6040 | dut, "wifitool %s setUnitTestCmd 0x47 2 17 1000000", | 
|  | 6041 | ifname); | 
|  | 6042 | run_system_wrapper(dut, | 
|  | 6043 | "wifitool %s setUnitTestCmd 0x47 2 8 0", | 
|  | 6044 | ifname); | 
|  | 6045 | run_system_wrapper(dut, | 
|  | 6046 | "wifitool %s setUnitTestCmd 0x47 2 29 0", | 
|  | 6047 | ifname); | 
|  | 6048 | } | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6049 | } | 
|  | 6050 |  | 
|  | 6051 |  | 
|  | 6052 | static int cmd_ath_ap_config_commit(struct sigma_dut *dut, | 
|  | 6053 | struct sigma_conn *conn, | 
|  | 6054 | struct sigma_cmd *cmd) | 
|  | 6055 | { | 
|  | 6056 | /* const char *name = get_param(cmd, "NAME"); */ | 
|  | 6057 | char buf[100]; | 
|  | 6058 | struct stat s; | 
|  | 6059 | const char *ifname = dut->ap_is_dual ? "ath1" : "ath0"; | 
|  | 6060 |  | 
|  | 6061 | if (stat("/proc/athversion", &s) == 0) { | 
|  | 6062 | sigma_dut_print(dut, DUT_MSG_INFO, "Run apdown"); | 
|  | 6063 | run_system(dut, "apdown"); | 
|  | 6064 | } | 
|  | 6065 |  | 
|  | 6066 | cmd_ath_ap_radio_config(dut); | 
|  | 6067 |  | 
|  | 6068 | snprintf(buf, sizeof(buf), "cfg -a 'AP_SSID=%s'", dut->ap_ssid); | 
|  | 6069 | run_system(dut, buf); | 
|  | 6070 |  | 
|  | 6071 | switch (dut->ap_key_mgmt) { | 
|  | 6072 | case AP_OPEN: | 
|  | 6073 | if (dut->ap_cipher == AP_WEP) { | 
|  | 6074 | run_system(dut, "cfg -a AP_SECMODE=WEP"); | 
|  | 6075 | run_system(dut, "cfg -a AP_SECFILE=NONE"); | 
|  | 6076 | /* shared auth mode not supported */ | 
|  | 6077 | run_system(dut, "cfg -a AP_WEP_MODE_0=1"); | 
|  | 6078 | run_system(dut, "cfg -a AP_WEP_MODE_1=1"); | 
|  | 6079 | snprintf(buf, sizeof(buf), | 
|  | 6080 | "cfg -a WEP_RADIO_NUM0_KEY_1=%s", | 
|  | 6081 | dut->ap_wepkey); | 
|  | 6082 | run_system(dut, buf); | 
|  | 6083 | snprintf(buf, sizeof(buf), | 
|  | 6084 | "cfg -a WEP_RADIO_NUM1_KEY_1=%s", | 
|  | 6085 | dut->ap_wepkey); | 
|  | 6086 | run_system(dut, buf); | 
|  | 6087 | } else { | 
|  | 6088 | run_system(dut, "cfg -a AP_SECMODE=None"); | 
|  | 6089 | } | 
|  | 6090 | break; | 
|  | 6091 | case AP_WPA2_PSK: | 
|  | 6092 | case AP_WPA2_PSK_MIXED: | 
|  | 6093 | case AP_WPA_PSK: | 
| Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 6094 | case AP_WPA2_SAE: | 
|  | 6095 | case AP_WPA2_PSK_SAE: | 
|  | 6096 | if (dut->ap_key_mgmt == AP_WPA2_PSK || | 
|  | 6097 | dut->ap_key_mgmt == AP_WPA2_SAE || | 
|  | 6098 | dut->ap_key_mgmt == AP_WPA2_PSK_SAE) | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6099 | run_system(dut, "cfg -a AP_WPA=2"); | 
|  | 6100 | else if (dut->ap_key_mgmt == AP_WPA2_PSK_MIXED) | 
|  | 6101 | run_system(dut, "cfg -a AP_WPA=3"); | 
|  | 6102 | else | 
|  | 6103 | run_system(dut, "cfg -a AP_WPA=1"); | 
| Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 6104 | /* TODO: SAE configuration */ | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6105 | run_system(dut, "cfg -a AP_SECMODE=WPA"); | 
|  | 6106 | run_system(dut, "cfg -a AP_SECFILE=PSK"); | 
|  | 6107 | snprintf(buf, sizeof(buf), "cfg -a 'PSK_KEY=%s'", | 
|  | 6108 | dut->ap_passphrase); | 
|  | 6109 | run_system(dut, buf); | 
|  | 6110 | if (dut->ap_cipher == AP_CCMP_TKIP) | 
|  | 6111 | run_system(dut, "cfg -a AP_CYPHER=\"CCMP TKIP\""); | 
|  | 6112 | else if (dut->ap_cipher == AP_TKIP) | 
|  | 6113 | run_system(dut, "cfg -a AP_CYPHER=TKIP"); | 
|  | 6114 | else | 
|  | 6115 | run_system(dut, "cfg -a AP_CYPHER=CCMP"); | 
|  | 6116 | break; | 
|  | 6117 | case AP_WPA2_EAP: | 
|  | 6118 | case AP_WPA2_EAP_MIXED: | 
|  | 6119 | case AP_WPA_EAP: | 
|  | 6120 | if (dut->ap_key_mgmt == AP_WPA2_EAP) | 
|  | 6121 | run_system(dut, "cfg -a AP_WPA=2"); | 
|  | 6122 | else if (dut->ap_key_mgmt == AP_WPA2_EAP_MIXED) | 
|  | 6123 | run_system(dut, "cfg -a AP_WPA=3"); | 
|  | 6124 | else | 
|  | 6125 | run_system(dut, "cfg -a AP_WPA=1"); | 
|  | 6126 | run_system(dut, "cfg -a AP_SECMODE=WPA"); | 
|  | 6127 | run_system(dut, "cfg -a AP_SECFILE=EAP"); | 
|  | 6128 | if (dut->ap_cipher == AP_CCMP_TKIP) | 
|  | 6129 | run_system(dut, "cfg -a AP_CYPHER=\"CCMP TKIP\""); | 
|  | 6130 | else if (dut->ap_cipher == AP_TKIP) | 
|  | 6131 | run_system(dut, "cfg -a AP_CYPHER=TKIP"); | 
|  | 6132 | else | 
|  | 6133 | run_system(dut, "cfg -a AP_CYPHER=CCMP"); | 
|  | 6134 | snprintf(buf, sizeof(buf), "cfg -a AP_AUTH_SERVER=%s", | 
|  | 6135 | dut->ap_radius_ipaddr); | 
|  | 6136 | run_system(dut, buf); | 
|  | 6137 | snprintf(buf, sizeof(buf), "cfg -a AP_AUTH_PORT=%d", | 
|  | 6138 | dut->ap_radius_port); | 
|  | 6139 | run_system(dut, buf); | 
|  | 6140 | snprintf(buf, sizeof(buf), "cfg -a AP_AUTH_SECRET=%s", | 
|  | 6141 | dut->ap_radius_password); | 
|  | 6142 | run_system(dut, buf); | 
|  | 6143 | break; | 
| Jouni Malinen | 4cf699f | 2018-06-19 00:46:27 +0300 | [diff] [blame] | 6144 | case AP_WPA2_EAP_OSEN: | 
|  | 6145 | /* TODO */ | 
|  | 6146 | sigma_dut_print(dut, DUT_MSG_ERROR, "EAP+OSEN not supported"); | 
|  | 6147 | break; | 
| Jouni Malinen | ad395a2 | 2017-09-01 21:13:46 +0300 | [diff] [blame] | 6148 | case AP_SUITEB: | 
|  | 6149 | /* TODO */ | 
|  | 6150 | sigma_dut_print(dut, DUT_MSG_ERROR, "SuiteB not supported"); | 
|  | 6151 | break; | 
| Jouni Malinen | 147b3c3 | 2017-10-09 16:51:54 +0300 | [diff] [blame] | 6152 | case AP_WPA2_OWE: | 
|  | 6153 | /* TODO */ | 
|  | 6154 | sigma_dut_print(dut, DUT_MSG_ERROR, "OWE not supported"); | 
|  | 6155 | break; | 
| Jouni Malinen | 6be21c8 | 2018-08-01 18:47:24 +0300 | [diff] [blame] | 6156 | case AP_WPA2_FT_EAP: | 
|  | 6157 | case AP_WPA2_FT_PSK: | 
|  | 6158 | case AP_WPA2_EAP_SHA256: | 
|  | 6159 | case AP_WPA2_PSK_SHA256: | 
|  | 6160 | case AP_WPA2_ENT_FT_EAP: | 
| Jouni Malinen | c2b9121 | 2018-09-12 02:26:39 +0300 | [diff] [blame] | 6161 | case AP_OSEN: | 
| Jouni Malinen | 6be21c8 | 2018-08-01 18:47:24 +0300 | [diff] [blame] | 6162 | /* TODO */ | 
|  | 6163 | send_resp(dut, conn, SIGMA_ERROR, | 
|  | 6164 | "errorCode,Unsupported KeyMgnt value"); | 
|  | 6165 | return 0; | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6166 | } | 
|  | 6167 |  | 
|  | 6168 | if (dut->ap_is_dual) { | 
|  | 6169 | /* ath1 settings in case of dual */ | 
|  | 6170 | snprintf(buf, sizeof(buf), "cfg -a 'AP_SSID_2=%s'", | 
|  | 6171 | dut->ap_ssid); | 
|  | 6172 | run_system(dut, buf); | 
|  | 6173 |  | 
|  | 6174 | switch (dut->ap_key_mgmt) { | 
|  | 6175 | case AP_OPEN: | 
|  | 6176 | if (dut->ap_cipher == AP_WEP) { | 
|  | 6177 | run_system(dut, "cfg -a AP_SECMODE_2=WEP"); | 
|  | 6178 | run_system(dut, "cfg -a AP_SECFILE_2=NONE"); | 
|  | 6179 | /* shared auth mode not supported */ | 
|  | 6180 | run_system(dut, "cfg -a AP_WEP_MODE_0=1"); | 
|  | 6181 | run_system(dut, "cfg -a AP_WEP_MODE_1=1"); | 
|  | 6182 | snprintf(buf, sizeof(buf), | 
|  | 6183 | "cfg -a WEP_RADIO_NUM0_KEY_1=%s", | 
|  | 6184 | dut->ap_wepkey); | 
|  | 6185 | run_system(dut, buf); | 
|  | 6186 | snprintf(buf, sizeof(buf), | 
|  | 6187 | "cfg -a WEP_RADIO_NUM1_KEY_1=%s", | 
|  | 6188 | dut->ap_wepkey); | 
|  | 6189 | run_system(dut, buf); | 
|  | 6190 | } else { | 
|  | 6191 | run_system(dut, "cfg -a AP_SECMODE_2=None"); | 
|  | 6192 | } | 
|  | 6193 | break; | 
|  | 6194 | case AP_WPA2_PSK: | 
|  | 6195 | case AP_WPA2_PSK_MIXED: | 
|  | 6196 | case AP_WPA_PSK: | 
| Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 6197 | case AP_WPA2_SAE: | 
|  | 6198 | case AP_WPA2_PSK_SAE: | 
|  | 6199 | if (dut->ap_key_mgmt == AP_WPA2_PSK || | 
|  | 6200 | dut->ap_key_mgmt == AP_WPA2_SAE || | 
|  | 6201 | dut->ap_key_mgmt == AP_WPA2_PSK_SAE) | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6202 | run_system(dut, "cfg -a AP_WPA_2=2"); | 
|  | 6203 | else if (dut->ap_key_mgmt == AP_WPA2_PSK_MIXED) | 
|  | 6204 | run_system(dut, "cfg -a AP_WPA_2=3"); | 
|  | 6205 | else | 
|  | 6206 | run_system(dut, "cfg -a AP_WPA_2=1"); | 
|  | 6207 | // run_system(dut, "cfg -a AP_WPA_2=2"); | 
| Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 6208 | /* TODO: SAE configuration */ | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6209 | run_system(dut, "cfg -a AP_SECMODE_2=WPA"); | 
|  | 6210 | run_system(dut, "cfg -a AP_SECFILE_2=PSK"); | 
|  | 6211 | snprintf(buf, sizeof(buf), "cfg -a 'PSK_KEY_2=%s'", | 
|  | 6212 | dut->ap_passphrase); | 
|  | 6213 | run_system(dut, buf); | 
|  | 6214 | if (dut->ap_cipher == AP_CCMP_TKIP) | 
|  | 6215 | run_system(dut, "cfg -a AP_CYPHER_2=\"CCMP TKIP\""); | 
|  | 6216 | else if (dut->ap_cipher == AP_TKIP) | 
|  | 6217 | run_system(dut, "cfg -a AP_CYPHER_2=TKIP"); | 
|  | 6218 | else | 
|  | 6219 | run_system(dut, "cfg -a AP_CYPHER_2=CCMP"); | 
|  | 6220 | break; | 
|  | 6221 | case AP_WPA2_EAP: | 
|  | 6222 | case AP_WPA2_EAP_MIXED: | 
|  | 6223 | case AP_WPA_EAP: | 
|  | 6224 | if (dut->ap_key_mgmt == AP_WPA2_EAP) | 
|  | 6225 | run_system(dut, "cfg -a AP_WPA_2=2"); | 
|  | 6226 | else if (dut->ap_key_mgmt == AP_WPA2_EAP_MIXED) | 
|  | 6227 | run_system(dut, "cfg -a AP_WPA_2=3"); | 
|  | 6228 | else | 
|  | 6229 | run_system(dut, "cfg -a AP_WPA_2=1"); | 
|  | 6230 | run_system(dut, "cfg -a AP_SECMODE_2=WPA"); | 
|  | 6231 | run_system(dut, "cfg -a AP_SECFILE_2=EAP"); | 
|  | 6232 | if (dut->ap_cipher == AP_CCMP_TKIP) | 
|  | 6233 | run_system(dut, "cfg -a AP_CYPHER_2=\"CCMP TKIP\""); | 
|  | 6234 | else if (dut->ap_cipher == AP_TKIP) | 
|  | 6235 | run_system(dut, "cfg -a AP_CYPHER_2=TKIP"); | 
|  | 6236 | else | 
|  | 6237 | run_system(dut, "cfg -a AP_CYPHER_2=CCMP"); | 
|  | 6238 |  | 
|  | 6239 | snprintf(buf, sizeof(buf), "cfg -a AP_AUTH_SERVER_2=%s", | 
|  | 6240 | dut->ap_radius_ipaddr); | 
|  | 6241 | run_system(dut, buf); | 
|  | 6242 | snprintf(buf, sizeof(buf), "cfg -a AP_AUTH_PORT_2=%d", | 
|  | 6243 | dut->ap_radius_port); | 
|  | 6244 | run_system(dut, buf); | 
|  | 6245 | snprintf(buf, sizeof(buf), "cfg -a AP_AUTH_SECRET_2=%s", | 
|  | 6246 | dut->ap_radius_password); | 
|  | 6247 | run_system(dut, buf); | 
|  | 6248 | break; | 
| Jouni Malinen | 4cf699f | 2018-06-19 00:46:27 +0300 | [diff] [blame] | 6249 | case AP_WPA2_EAP_OSEN: | 
|  | 6250 | /* TODO */ | 
|  | 6251 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 6252 | "EAP+OSEN not supported"); | 
|  | 6253 | break; | 
| Jouni Malinen | ad395a2 | 2017-09-01 21:13:46 +0300 | [diff] [blame] | 6254 | case AP_SUITEB: | 
|  | 6255 | /* TODO */ | 
|  | 6256 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 6257 | "SuiteB not supported"); | 
|  | 6258 | break; | 
| Jouni Malinen | 147b3c3 | 2017-10-09 16:51:54 +0300 | [diff] [blame] | 6259 | case AP_WPA2_OWE: | 
|  | 6260 | /* TODO */ | 
|  | 6261 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 6262 | "OWE not supported"); | 
|  | 6263 | break; | 
| Jouni Malinen | 6be21c8 | 2018-08-01 18:47:24 +0300 | [diff] [blame] | 6264 | case AP_WPA2_FT_EAP: | 
|  | 6265 | case AP_WPA2_FT_PSK: | 
|  | 6266 | case AP_WPA2_EAP_SHA256: | 
|  | 6267 | case AP_WPA2_PSK_SHA256: | 
|  | 6268 | case AP_WPA2_ENT_FT_EAP: | 
| Jouni Malinen | c2b9121 | 2018-09-12 02:26:39 +0300 | [diff] [blame] | 6269 | case AP_OSEN: | 
| Jouni Malinen | 6be21c8 | 2018-08-01 18:47:24 +0300 | [diff] [blame] | 6270 | /* TODO */ | 
|  | 6271 | send_resp(dut, conn, SIGMA_ERROR, | 
|  | 6272 | "errorCode,Unsupported KeyMgnt value"); | 
|  | 6273 | return 0; | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6274 | } | 
|  | 6275 |  | 
|  | 6276 | /* wifi0 settings in case of dual */ | 
|  | 6277 | run_system(dut, "cfg -a AP_RADIO_ID=0"); | 
|  | 6278 | run_system(dut, "cfg -a AP_PRIMARY_CH=6"); | 
|  | 6279 | run_system(dut, "cfg -a AP_STARTMODE=dual"); | 
|  | 6280 | run_system(dut, "cfg -a AP_CHMODE=11NGHT40PLUS"); | 
|  | 6281 | run_system(dut, "cfg -a TX_CHAINMASK=7"); | 
|  | 6282 | run_system(dut, "cfg -a RX_CHAINMASK=7"); | 
|  | 6283 | } | 
|  | 6284 |  | 
|  | 6285 | switch (dut->ap_pmf) { | 
|  | 6286 | case AP_PMF_DISABLED: | 
|  | 6287 | snprintf(buf, sizeof(buf), "cfg -a AP_PMF=0"); | 
|  | 6288 | run_system(dut, buf); | 
|  | 6289 | break; | 
|  | 6290 | case AP_PMF_OPTIONAL: | 
|  | 6291 | snprintf(buf, sizeof(buf), "cfg -a AP_PMF=1"); | 
|  | 6292 | run_system(dut, buf); | 
|  | 6293 | break; | 
|  | 6294 | case AP_PMF_REQUIRED: | 
|  | 6295 | snprintf(buf, sizeof(buf), "cfg -a AP_PMF=2"); | 
|  | 6296 | run_system(dut, buf); | 
|  | 6297 | break; | 
|  | 6298 | } | 
|  | 6299 | if (dut->ap_add_sha256) { | 
|  | 6300 | snprintf(buf, sizeof(buf), "cfg -a AP_WPA_SHA256=1"); | 
|  | 6301 | run_system(dut, buf); | 
|  | 6302 | } else { | 
|  | 6303 | snprintf(buf, sizeof(buf), "cfg -r AP_WPA_SHA256"); | 
|  | 6304 | run_system(dut, buf); | 
|  | 6305 | } | 
|  | 6306 |  | 
|  | 6307 | if (dut->ap_hs2) | 
|  | 6308 | run_system(dut, "cfg -a AP_HOTSPOT=1"); | 
|  | 6309 | else | 
|  | 6310 | run_system(dut, "cfg -r AP_HOTSPOT"); | 
|  | 6311 |  | 
|  | 6312 | if (dut->ap_interworking) { | 
|  | 6313 | snprintf(buf, sizeof(buf), "cfg -a AP_HOTSPOT_ANT=%d", | 
|  | 6314 | dut->ap_access_net_type); | 
|  | 6315 | run_system(dut, buf); | 
|  | 6316 | snprintf(buf, sizeof(buf), "cfg -a AP_HOTSPOT_INTERNET=%d", | 
|  | 6317 | dut->ap_internet); | 
|  | 6318 | run_system(dut, buf); | 
|  | 6319 | snprintf(buf, sizeof(buf), "cfg -a AP_HOTSPOT_VENUEGROUP=%d", | 
|  | 6320 | dut->ap_venue_group); | 
|  | 6321 | run_system(dut, buf); | 
|  | 6322 | snprintf(buf, sizeof(buf), "cfg -a AP_HOTSPOT_VENUETYPE=%d", | 
|  | 6323 | dut->ap_venue_type); | 
|  | 6324 | run_system(dut, buf); | 
|  | 6325 | snprintf(buf, sizeof(buf), "cfg -a AP_HOTSPOT_HESSID=%s", | 
|  | 6326 | dut->ap_hessid); | 
|  | 6327 | run_system(dut, buf); | 
|  | 6328 |  | 
|  | 6329 | if (dut->ap_roaming_cons[0]) { | 
|  | 6330 | char *second, *rc; | 
|  | 6331 | rc = strdup(dut->ap_roaming_cons); | 
|  | 6332 | if (rc == NULL) | 
|  | 6333 | return 0; | 
|  | 6334 |  | 
|  | 6335 | second = strchr(rc, ';'); | 
|  | 6336 | if (second) | 
|  | 6337 | *second++ = '\0'; | 
|  | 6338 |  | 
|  | 6339 | snprintf(buf, sizeof(buf), | 
|  | 6340 | "cfg -a AP_HOTSPOT_ROAMINGCONSORTIUM=%s", rc); | 
|  | 6341 | run_system(dut, buf); | 
|  | 6342 |  | 
|  | 6343 | if (second) { | 
|  | 6344 | snprintf(buf, sizeof(buf), | 
|  | 6345 | "cfg -a AP_HOTSPOT_ROAMINGCONSORTIUM2" | 
|  | 6346 | "=%s", second); | 
|  | 6347 | run_system(dut, buf); | 
|  | 6348 | } | 
|  | 6349 | free(rc); | 
|  | 6350 | } else { | 
|  | 6351 | run_system(dut, "cfg -r AP_HOTSPOT_ROAMINGCONSORTIUM"); | 
|  | 6352 | run_system(dut, | 
|  | 6353 | "cfg -r AP_HOTSPOT_ROAMINGCONSORTIUM2"); | 
|  | 6354 | } | 
|  | 6355 | } else { | 
|  | 6356 | run_system(dut, "cfg -r AP_HOTSPOT_ANT"); | 
|  | 6357 | run_system(dut, "cfg -r AP_HOTSPOT_INTERNET"); | 
|  | 6358 | run_system(dut, "cfg -r AP_HOTSPOT_VENUEGROUP"); | 
|  | 6359 | run_system(dut, "cfg -r AP_HOTSPOT_VENUETYPE"); | 
|  | 6360 | run_system(dut, "cfg -r AP_HOTSPOT_HESSID"); | 
|  | 6361 | run_system(dut, "cfg -r AP_HOTSPOT_ROAMINGCONSORTIUM"); | 
|  | 6362 | run_system(dut, "cfg -r AP_HOTSPOT_ROAMINGCONSORTIUM2"); | 
|  | 6363 | } | 
|  | 6364 |  | 
|  | 6365 | if (dut->ap_proxy_arp) | 
|  | 6366 | run_system(dut, "cfg -a IEEE80211V_PROXYARP=1"); | 
|  | 6367 | else | 
|  | 6368 | run_system(dut, "cfg -a IEEE80211V_PROXYARP=0"); | 
|  | 6369 | if (dut->ap_dgaf_disable) | 
|  | 6370 | run_system(dut, "cfg -a AP_HOTSPOT_DISABLE_DGAF=1"); | 
|  | 6371 | else | 
|  | 6372 | run_system(dut, "cfg -r AP_HOTSPOT_DISABLE_DGAF"); | 
|  | 6373 |  | 
| Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 6374 | if (strlen(dut->ap_tag_ssid[0])) { | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6375 | snprintf(buf, sizeof(buf), | 
| Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 6376 | "cfg -a AP_SSID_2=%s", dut->ap_tag_ssid[0]); | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6377 | run_system(dut, buf); | 
|  | 6378 |  | 
| Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 6379 | if (dut->ap_tag_key_mgmt[0] == AP2_OSEN) { | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6380 | run_system(dut, "cfg -a AP_SECMODE_2=WPA"); | 
|  | 6381 | run_system(dut, "cfg -a AP_SECFILE_2=OSEN"); | 
|  | 6382 |  | 
|  | 6383 | snprintf(buf, sizeof(buf), "cfg -a AP_AUTH_SERVER_2=%s", | 
|  | 6384 | dut->ap2_radius_ipaddr); | 
|  | 6385 | run_system(dut, buf); | 
|  | 6386 |  | 
|  | 6387 | snprintf(buf, sizeof(buf), "cfg -a AP_AUTH_PORT_2=%d", | 
|  | 6388 | dut->ap2_radius_port); | 
|  | 6389 | run_system(dut, buf); | 
|  | 6390 |  | 
|  | 6391 | snprintf(buf, sizeof(buf), "cfg -a AP_AUTH_SECRET_2=%s", | 
|  | 6392 | dut->ap2_radius_password); | 
|  | 6393 | run_system(dut, buf); | 
|  | 6394 | } else { | 
|  | 6395 | run_system(dut, "cfg -a AP_SECMODE_2=None"); | 
|  | 6396 | run_system(dut, "cfg -r AP_AUTH_SERVER_2"); | 
|  | 6397 | run_system(dut, "cfg -r AP_AUTH_PORT_2"); | 
|  | 6398 | run_system(dut, "cfg -r AP_AUTH_SECRET_2"); | 
|  | 6399 | } | 
|  | 6400 |  | 
|  | 6401 | run_system(dut, "cfg -a AP_STARTMODE=multi"); | 
|  | 6402 | } | 
|  | 6403 |  | 
|  | 6404 | run_system(dut, "cfg -c"); | 
|  | 6405 |  | 
|  | 6406 | sigma_dut_print(dut, DUT_MSG_INFO, "Starting AP"); | 
|  | 6407 | if (system("apup") != 0) { | 
|  | 6408 | /* to be debugged why apup returns error | 
|  | 6409 | send_resp(dut, conn, SIGMA_ERROR, | 
|  | 6410 | "errorCode,apup failed"); | 
|  | 6411 | return 0; | 
|  | 6412 | */ | 
|  | 6413 | } | 
|  | 6414 | sigma_dut_print(dut, DUT_MSG_INFO, "AP started"); | 
|  | 6415 |  | 
|  | 6416 | if (dut->ap_key_mgmt != AP_OPEN) { | 
|  | 6417 | int res; | 
|  | 6418 | /* allow some time for hostapd to start before returning | 
|  | 6419 | * success */ | 
|  | 6420 | usleep(500000); | 
|  | 6421 | if (run_hostapd_cli(dut, "ping") != 0) { | 
|  | 6422 | send_resp(dut, conn, SIGMA_ERROR, | 
|  | 6423 | "errorCode,Failed to talk to hostapd"); | 
|  | 6424 | return 0; | 
|  | 6425 | } | 
|  | 6426 |  | 
|  | 6427 | if (dut->ap_hs2 && !dut->ap_anqpserver) { | 
|  | 6428 | /* the cfg app doesn't like ";" in the variables */ | 
|  | 6429 | res = ath_ap_append_hostapd_conf(dut); | 
|  | 6430 | if (res < 0) | 
|  | 6431 | return res; | 
|  | 6432 |  | 
|  | 6433 | /* wait for hostapd to be ready */ | 
|  | 6434 | usleep(500000); | 
|  | 6435 | if (run_hostapd_cli(dut, "ping") != 0) { | 
|  | 6436 | send_resp(dut, conn, SIGMA_ERROR, | 
|  | 6437 | "errorCode,Failed to talk to " | 
|  | 6438 | "hostapd"); | 
|  | 6439 | return 0; | 
|  | 6440 | } | 
|  | 6441 | } | 
|  | 6442 | } | 
|  | 6443 |  | 
|  | 6444 | ath_ap_set_params(dut); | 
|  | 6445 |  | 
|  | 6446 | if (dut->ap_anqpserver) | 
|  | 6447 | return cmd_ath_ap_anqpserver_start(dut); | 
|  | 6448 |  | 
|  | 6449 | if (dut->ap2_proxy_arp) | 
|  | 6450 | run_system(dut, "iwpriv ath1 proxy_arp 1"); | 
|  | 6451 |  | 
|  | 6452 | if (dut->ap_allow_vht_wep || dut->ap_allow_vht_tkip) { | 
|  | 6453 | snprintf(buf, sizeof(buf), "iwpriv %s htweptkip 1", ifname); | 
|  | 6454 | if (system(buf) != 0) { | 
|  | 6455 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 6456 | "iwpriv htweptkip failed"); | 
|  | 6457 | } | 
|  | 6458 | } | 
|  | 6459 |  | 
|  | 6460 | return 1; | 
|  | 6461 | } | 
|  | 6462 |  | 
|  | 6463 |  | 
|  | 6464 | static int set_ebtables_proxy_arp(struct sigma_dut *dut, const char *chain, | 
|  | 6465 | const char *ifname) | 
|  | 6466 | { | 
|  | 6467 | char buf[200]; | 
|  | 6468 |  | 
|  | 6469 | if (!chain || !ifname) | 
|  | 6470 | return -2; | 
|  | 6471 |  | 
|  | 6472 | snprintf(buf, sizeof(buf), "ebtables -P %s ACCEPT", chain); | 
|  | 6473 | if (system(buf) != 0) { | 
|  | 6474 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 6475 | "Failed to set ebtables rules, RULE-1, %s", | 
|  | 6476 | chain); | 
|  | 6477 | return -2; | 
|  | 6478 | } | 
|  | 6479 |  | 
|  | 6480 | snprintf(buf, sizeof(buf), | 
|  | 6481 | "ebtables -A %s -p ARP -d Broadcast -o %s -j DROP", | 
|  | 6482 | chain, ifname); | 
|  | 6483 | if (system(buf) != 0) { | 
|  | 6484 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 6485 | "Failed to set ebtables rules, RULE-2, %s", | 
|  | 6486 | chain); | 
|  | 6487 | return -2; | 
|  | 6488 | } | 
|  | 6489 |  | 
|  | 6490 | snprintf(buf, sizeof(buf), | 
|  | 6491 | "ebtables -A %s -d Multicast -p IPv6 --ip6-protocol ipv6-icmp --ip6-icmp-type neighbor-solicitation -o %s -j DROP", | 
|  | 6492 | chain, ifname); | 
|  | 6493 | if (system(buf) != 0) { | 
|  | 6494 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 6495 | "Failed to set ebtables rules, RULE-3, %s", | 
|  | 6496 | chain); | 
|  | 6497 | return -2; | 
|  | 6498 | } | 
|  | 6499 |  | 
|  | 6500 | snprintf(buf, sizeof(buf), | 
|  | 6501 | "ebtables -A %s -d Multicast -p IPv6 --ip6-protocol ipv6-icmp --ip6-icmp-type neighbor-advertisement -o %s -j DROP", | 
|  | 6502 | chain, ifname); | 
|  | 6503 | if (system(buf) != 0) { | 
|  | 6504 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 6505 | "Failed to set ebtables rules, RULE-4, %s", | 
|  | 6506 | chain); | 
|  | 6507 | return -2; | 
|  | 6508 | } | 
|  | 6509 |  | 
|  | 6510 | return 0; | 
|  | 6511 | } | 
|  | 6512 |  | 
|  | 6513 |  | 
|  | 6514 | static int set_ebtables_disable_dgaf(struct sigma_dut *dut, | 
|  | 6515 | const char *chain, | 
|  | 6516 | const char *ifname) | 
|  | 6517 | { | 
|  | 6518 | char buf[200]; | 
|  | 6519 |  | 
|  | 6520 | if (!chain || !ifname) | 
|  | 6521 | return -2; | 
|  | 6522 |  | 
|  | 6523 | snprintf(buf, sizeof(buf), "ebtables -P %s ACCEPT", chain); | 
|  | 6524 | if (system(buf) != 0) { | 
|  | 6525 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 6526 | "Failed to set ebtables rules, RULE-5, %s", | 
|  | 6527 | chain); | 
|  | 6528 | return -2; | 
|  | 6529 | } | 
|  | 6530 |  | 
|  | 6531 | snprintf(buf, sizeof(buf), | 
|  | 6532 | "ebtables -A %s -p ARP -d Broadcast -o %s -j DROP", | 
|  | 6533 | chain, ifname); | 
|  | 6534 | if (system(buf) != 0) { | 
|  | 6535 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 6536 | "Failed to set ebtables rules, RULE-6, %s", | 
|  | 6537 | chain); | 
|  | 6538 | return -2; | 
|  | 6539 | } | 
|  | 6540 |  | 
|  | 6541 | snprintf(buf, sizeof(buf), | 
|  | 6542 | "ebtables -A %s -p IPv4 -d Multicast -o %s -j DROP", | 
|  | 6543 | chain, ifname); | 
|  | 6544 | if (system(buf) != 0) { | 
|  | 6545 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 6546 | "Failed to set ebtables rules, RULE-7, %s", | 
|  | 6547 | chain); | 
|  | 6548 | return -2; | 
|  | 6549 | } | 
|  | 6550 |  | 
|  | 6551 | snprintf(buf, sizeof(buf), | 
|  | 6552 | "ebtables -A %s -p IPv6 -d Multicast -o %s -j DROP", | 
|  | 6553 | chain, ifname); | 
|  | 6554 | if (system(buf) != 0) { | 
|  | 6555 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 6556 | "Failed to set ebtables rules, RULE-8, %s", | 
|  | 6557 | chain); | 
|  | 6558 | return -2; | 
|  | 6559 | } | 
|  | 6560 |  | 
|  | 6561 | return 0; | 
|  | 6562 | } | 
|  | 6563 |  | 
|  | 6564 |  | 
| Jouni Malinen | dbbc2c4 | 2018-11-14 23:55:41 +0200 | [diff] [blame] | 6565 | static void set_ebtables_forward_drop(struct sigma_dut *dut, | 
|  | 6566 | const char *ifname, const char *ifname2) | 
|  | 6567 | { | 
|  | 6568 | char buf[128]; | 
|  | 6569 |  | 
|  | 6570 | snprintf(buf, sizeof(buf), "ebtables -A FORWARD -i %s -o %s -j DROP", | 
|  | 6571 | ifname, ifname2); | 
|  | 6572 | if (system(buf) != 0) | 
|  | 6573 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 6574 | "Failed to set ebtables rule"); | 
|  | 6575 |  | 
|  | 6576 | snprintf(buf, sizeof(buf), "ebtables -A FORWARD -i %s -o %s -j DROP", | 
|  | 6577 | ifname2, ifname); | 
|  | 6578 | if (system(buf) != 0) | 
|  | 6579 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 6580 | "Failed to set ebtables rule"); | 
|  | 6581 | } | 
|  | 6582 |  | 
|  | 6583 |  | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6584 | static int check_channel(int channel) | 
|  | 6585 | { | 
|  | 6586 | int channel_list[] = { 36, 40, 44, 48, 52, 60, 64, 100, 104, 108, 112, | 
|  | 6587 | 116, 120, 124, 128, 132, 140, 144, 149, 153, 157, | 
|  | 6588 | 161, 165 }; | 
|  | 6589 | int num_chan = sizeof(channel_list) / sizeof(int); | 
|  | 6590 | int i; | 
|  | 6591 |  | 
|  | 6592 | for (i = 0; i < num_chan; i++) { | 
|  | 6593 | if (channel == channel_list[i]) | 
|  | 6594 | return i; | 
|  | 6595 | } | 
|  | 6596 |  | 
|  | 6597 | return -1; | 
|  | 6598 | } | 
|  | 6599 |  | 
|  | 6600 |  | 
|  | 6601 | static int get_oper_centr_freq_seq_idx(int chwidth, int channel) | 
|  | 6602 | { | 
|  | 6603 | int ch_base; | 
|  | 6604 | int period; | 
|  | 6605 |  | 
|  | 6606 | if (check_channel(channel) < 0) | 
|  | 6607 | return -1; | 
|  | 6608 |  | 
|  | 6609 | if (channel >= 36 && channel <= 64) | 
|  | 6610 | ch_base = 36; | 
|  | 6611 | else if (channel >= 100 && channel <= 144) | 
|  | 6612 | ch_base = 100; | 
|  | 6613 | else | 
|  | 6614 | ch_base = 149; | 
|  | 6615 |  | 
|  | 6616 | period = channel % ch_base * 5 / chwidth; | 
|  | 6617 | return ch_base + period * chwidth / 5 + (chwidth - 20) / 10; | 
|  | 6618 | } | 
|  | 6619 |  | 
|  | 6620 |  | 
|  | 6621 | static int is_ht40plus_chan(int chan) | 
|  | 6622 | { | 
|  | 6623 | return chan == 36 || chan == 44 || chan == 52 || chan == 60 || | 
|  | 6624 | chan == 100 || chan == 108 || chan == 116 || chan == 124 || | 
|  | 6625 | chan == 132 || chan == 149 || chan == 157; | 
|  | 6626 | } | 
|  | 6627 |  | 
|  | 6628 |  | 
|  | 6629 | static int is_ht40minus_chan(int chan) | 
|  | 6630 | { | 
|  | 6631 | return chan == 40 || chan == 48 || chan == 56 || chan == 64 || | 
|  | 6632 | chan == 104 || chan == 112 || chan == 120 || chan == 128 || | 
|  | 6633 | chan == 136 || chan == 153 || chan == 161; | 
|  | 6634 | } | 
|  | 6635 |  | 
|  | 6636 |  | 
| Mohammed Shafi Shajakhan | b53d8f9 | 2017-02-28 09:05:15 +0530 | [diff] [blame] | 6637 | static int get_5g_channel_freq(int chan) | 
|  | 6638 | { | 
|  | 6639 | return 5000 + chan * 5; | 
|  | 6640 | } | 
|  | 6641 |  | 
|  | 6642 |  | 
| Jouni Malinen | 3d633da | 2017-09-14 22:19:21 +0300 | [diff] [blame] | 6643 | static const char * hostapd_cipher_name(enum ap_cipher cipher) | 
|  | 6644 | { | 
|  | 6645 | switch (cipher) { | 
|  | 6646 | case AP_CCMP: | 
|  | 6647 | return "CCMP"; | 
|  | 6648 | case AP_TKIP: | 
|  | 6649 | return "TKIP"; | 
|  | 6650 | case AP_CCMP_TKIP: | 
|  | 6651 | return "CCMP TKIP"; | 
|  | 6652 | case AP_GCMP_256: | 
|  | 6653 | return "GCMP-256"; | 
|  | 6654 | case AP_GCMP_128: | 
|  | 6655 | return "GCMP"; | 
|  | 6656 | case AP_CCMP_256: | 
|  | 6657 | return "CCMP-256"; | 
| Jouni Malinen | d538c78 | 2017-11-17 12:13:04 +0200 | [diff] [blame] | 6658 | case AP_CCMP_128_GCMP_256: | 
|  | 6659 | return "CCMP GCMP-256"; | 
| Jouni Malinen | 3d633da | 2017-09-14 22:19:21 +0300 | [diff] [blame] | 6660 | default: | 
|  | 6661 | return "UNKNOWN"; | 
|  | 6662 | } | 
|  | 6663 | } | 
|  | 6664 |  | 
|  | 6665 |  | 
|  | 6666 | static const char * | 
|  | 6667 | hostapd_group_mgmt_cipher_name(enum ap_group_mgmt_cipher cipher) | 
|  | 6668 | { | 
|  | 6669 | switch (cipher) { | 
|  | 6670 | case AP_BIP_GMAC_256: | 
| Jouni Malinen | 57887a2 | 2017-10-10 20:43:25 +0300 | [diff] [blame] | 6671 | return "BIP-GMAC-256"; | 
| Jouni Malinen | 3d633da | 2017-09-14 22:19:21 +0300 | [diff] [blame] | 6672 | case AP_BIP_CMAC_256: | 
|  | 6673 | return "BIP-CMAC-256"; | 
|  | 6674 | case AP_BIP_GMAC_128: | 
|  | 6675 | return "BIP-GMAC-128"; | 
|  | 6676 | case AP_BIP_CMAC_128: | 
|  | 6677 | return "AES-128-CMAC"; | 
|  | 6678 | default: | 
|  | 6679 | return "UNKNOWN"; | 
|  | 6680 | } | 
|  | 6681 | } | 
|  | 6682 |  | 
|  | 6683 |  | 
| Alexei Avshalom Lazar | bc180dc | 2018-12-18 16:01:14 +0200 | [diff] [blame] | 6684 | static int ap_set_60g_ese(struct sigma_dut *dut, int count, | 
|  | 6685 | struct sigma_ese_alloc *allocs) | 
|  | 6686 | { | 
|  | 6687 | switch (get_driver_type()) { | 
|  | 6688 | #ifdef __linux__ | 
|  | 6689 | case DRIVER_WIL6210: | 
|  | 6690 | return wil6210_set_ese(dut, count, allocs); | 
|  | 6691 | #endif /* __linux__ */ | 
|  | 6692 | default: | 
|  | 6693 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 6694 | "Unsupported ap_set_60g_ese with the current driver"); | 
|  | 6695 | return -1; | 
|  | 6696 | } | 
|  | 6697 | } | 
|  | 6698 |  | 
|  | 6699 |  | 
| Alexei Avshalom Lazar | aad97b0 | 2018-12-18 16:01:23 +0200 | [diff] [blame] | 6700 | static int ap_set_force_mcs(struct sigma_dut *dut, int force, int mcs) | 
|  | 6701 | { | 
|  | 6702 | switch (get_driver_type()) { | 
|  | 6703 | #ifdef __linux__ | 
|  | 6704 | case DRIVER_WIL6210: | 
|  | 6705 | return wil6210_set_force_mcs(dut, force, mcs); | 
|  | 6706 | #endif /* __linux__ */ | 
|  | 6707 | default: | 
|  | 6708 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 6709 | "Unsupported ap_set_force_mcs with the current driver"); | 
|  | 6710 | return -1; | 
|  | 6711 | } | 
|  | 6712 | } | 
|  | 6713 |  | 
|  | 6714 |  | 
| Jouni Malinen | a326d7b | 2017-09-04 13:46:02 +0300 | [diff] [blame] | 6715 | int cmd_ap_config_commit(struct sigma_dut *dut, struct sigma_conn *conn, | 
|  | 6716 | struct sigma_cmd *cmd) | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6717 | { | 
|  | 6718 | /* const char *name = get_param(cmd, "NAME"); */ | 
|  | 6719 | FILE *f; | 
|  | 6720 | const char *ifname; | 
|  | 6721 | char buf[500]; | 
|  | 6722 | char path[100]; | 
|  | 6723 | enum driver_type drv; | 
| Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 6724 | const char *key_mgmt; | 
| Srinivas Dasari | a1deeaa | 2018-06-18 22:54:04 +0530 | [diff] [blame] | 6725 | #ifdef ANDROID | 
|  | 6726 | struct group *gr; | 
|  | 6727 | #endif /* ANDROID */ | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6728 |  | 
|  | 6729 | drv = get_driver_type(); | 
|  | 6730 |  | 
|  | 6731 | if (dut->mode == SIGMA_MODE_STATION) { | 
|  | 6732 | stop_sta_mode(dut); | 
|  | 6733 | sleep(1); | 
|  | 6734 | } | 
|  | 6735 |  | 
|  | 6736 | if (dut->mode == SIGMA_MODE_SNIFFER && dut->sniffer_ifname) { | 
|  | 6737 | snprintf(buf, sizeof(buf), "ifconfig %s down", | 
|  | 6738 | dut->sniffer_ifname); | 
|  | 6739 | if (system(buf) != 0) { | 
|  | 6740 | sigma_dut_print(dut, DUT_MSG_INFO, | 
|  | 6741 | "Failed to run '%s'", buf); | 
|  | 6742 | } | 
|  | 6743 | snprintf(buf, sizeof(buf), "iw dev %s set type station", | 
|  | 6744 | dut->sniffer_ifname); | 
|  | 6745 | if (system(buf) != 0) { | 
|  | 6746 | sigma_dut_print(dut, DUT_MSG_INFO, | 
|  | 6747 | "Failed to run '%s'", buf); | 
|  | 6748 | } | 
|  | 6749 | } | 
|  | 6750 |  | 
|  | 6751 | dut->mode = SIGMA_MODE_AP; | 
|  | 6752 |  | 
|  | 6753 | if (drv == DRIVER_ATHEROS) | 
|  | 6754 | return cmd_ath_ap_config_commit(dut, conn, cmd); | 
|  | 6755 | if (drv == DRIVER_WCN) | 
|  | 6756 | return cmd_wcn_ap_config_commit(dut, conn, cmd); | 
|  | 6757 | if (drv == DRIVER_OPENWRT) | 
|  | 6758 | return cmd_owrt_ap_config_commit(dut, conn, cmd); | 
|  | 6759 |  | 
|  | 6760 | f = fopen(SIGMA_TMPDIR "/sigma_dut-ap.conf", "w"); | 
|  | 6761 | if (f == NULL) { | 
|  | 6762 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 6763 | "%s: Failed to open sigma_dut-ap.conf", | 
|  | 6764 | __func__); | 
|  | 6765 | return -2; | 
|  | 6766 | } | 
|  | 6767 | switch (dut->ap_mode) { | 
|  | 6768 | case AP_11g: | 
|  | 6769 | case AP_11b: | 
|  | 6770 | case AP_11ng: | 
| Pradeep Reddy Potteti | 08eaeba | 2017-06-14 12:43:19 +0530 | [diff] [blame] | 6771 | ifname = (drv == DRIVER_MAC80211) ? "wlan0" : "ath0"; | 
|  | 6772 | if ((drv == DRIVER_QNXNTO || drv == DRIVER_LINUX_WCN) && | 
|  | 6773 | sigma_main_ifname) | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6774 | ifname = sigma_main_ifname; | 
|  | 6775 | fprintf(f, "hw_mode=g\n"); | 
|  | 6776 | break; | 
|  | 6777 | case AP_11a: | 
|  | 6778 | case AP_11na: | 
|  | 6779 | case AP_11ac: | 
| Pradeep Reddy Potteti | 08eaeba | 2017-06-14 12:43:19 +0530 | [diff] [blame] | 6780 | if (drv == DRIVER_QNXNTO || drv == DRIVER_LINUX_WCN) { | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6781 | if (sigma_main_ifname) | 
|  | 6782 | ifname = sigma_main_ifname; | 
|  | 6783 | else | 
|  | 6784 | ifname = "wlan0"; | 
| Pradeep Reddy Potteti | 08eaeba | 2017-06-14 12:43:19 +0530 | [diff] [blame] | 6785 | } else if (drv == DRIVER_MAC80211) { | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6786 | if (if_nametoindex("wlan1") > 0) | 
|  | 6787 | ifname = "wlan1"; | 
|  | 6788 | else | 
|  | 6789 | ifname = "wlan0"; | 
|  | 6790 | } else { | 
|  | 6791 | ifname = get_main_ifname(); | 
|  | 6792 | } | 
|  | 6793 | fprintf(f, "hw_mode=a\n"); | 
|  | 6794 | break; | 
| Alexei Avshalom Lazar | 2712cc8 | 2018-12-23 16:29:14 +0200 | [diff] [blame] | 6795 | case AP_11ad: | 
|  | 6796 | ifname = get_main_ifname(); | 
|  | 6797 | fprintf(f, "hw_mode=ad\n"); | 
|  | 6798 | break; | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6799 | default: | 
|  | 6800 | fclose(f); | 
|  | 6801 | return -1; | 
|  | 6802 | } | 
| Jouni Malinen | d6bf1b4 | 2017-06-23 17:51:01 +0300 | [diff] [blame] | 6803 | if (dut->hostapd_ifname) | 
|  | 6804 | ifname = dut->hostapd_ifname; | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6805 |  | 
| Sreelakshmi Konamki | b692f10 | 2016-04-26 19:47:00 +0530 | [diff] [blame] | 6806 | if (drv == DRIVER_MAC80211 || drv == DRIVER_LINUX_WCN) | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6807 | fprintf(f, "driver=nl80211\n"); | 
|  | 6808 |  | 
| Sreelakshmi Konamki | b692f10 | 2016-04-26 19:47:00 +0530 | [diff] [blame] | 6809 | if ((drv == DRIVER_MAC80211 || drv == DRIVER_QNXNTO || | 
|  | 6810 | drv == DRIVER_LINUX_WCN) && | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6811 | (dut->ap_mode == AP_11ng || dut->ap_mode == AP_11na)) { | 
| Tamizh chelvam | 431c600 | 2017-03-07 17:07:16 +0530 | [diff] [blame] | 6812 | int ht40plus = 0, ht40minus = 0, tx_stbc = 0; | 
|  | 6813 |  | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6814 | fprintf(f, "ieee80211n=1\n"); | 
| Pradeep Reddy Potteti | bf8af29 | 2017-02-15 15:28:39 +0530 | [diff] [blame] | 6815 | if (dut->ap_mode == AP_11ng && | 
|  | 6816 | (dut->ap_chwidth == AP_40 || | 
|  | 6817 | (dut->ap_chwidth == AP_AUTO && | 
|  | 6818 | dut->default_11ng_ap_chwidth == AP_40))) { | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6819 | if (dut->ap_channel >= 1 && dut->ap_channel <= 7) | 
| Tamizh chelvam | 431c600 | 2017-03-07 17:07:16 +0530 | [diff] [blame] | 6820 | ht40plus = 1; | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6821 | else if (dut->ap_channel >= 8 && dut->ap_channel <= 11) | 
| Tamizh chelvam | 431c600 | 2017-03-07 17:07:16 +0530 | [diff] [blame] | 6822 | ht40minus = 1; | 
|  | 6823 | fprintf(f, "obss_interval=300\n"); | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6824 | } | 
|  | 6825 |  | 
|  | 6826 | /* configure ht_capab based on channel width */ | 
|  | 6827 | if (dut->ap_mode == AP_11na && | 
|  | 6828 | (dut->ap_chwidth == AP_40 || | 
|  | 6829 | (dut->ap_chwidth == AP_AUTO && | 
| Pradeep Reddy Potteti | bf8af29 | 2017-02-15 15:28:39 +0530 | [diff] [blame] | 6830 | dut->default_11na_ap_chwidth == AP_40))) { | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6831 | if (is_ht40plus_chan(dut->ap_channel)) | 
| Tamizh chelvam | 431c600 | 2017-03-07 17:07:16 +0530 | [diff] [blame] | 6832 | ht40plus = 1; | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6833 | else if (is_ht40minus_chan(dut->ap_channel)) | 
| Tamizh chelvam | 431c600 | 2017-03-07 17:07:16 +0530 | [diff] [blame] | 6834 | ht40minus = 1; | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6835 | } | 
| Mohammed Shafi Shajakhan | 31d8a15 | 2016-06-02 20:10:55 +0530 | [diff] [blame] | 6836 |  | 
|  | 6837 | if (dut->ap_tx_stbc) | 
| Tamizh chelvam | 431c600 | 2017-03-07 17:07:16 +0530 | [diff] [blame] | 6838 | tx_stbc = 1; | 
| Mohammed Shafi Shajakhan | 31d8a15 | 2016-06-02 20:10:55 +0530 | [diff] [blame] | 6839 |  | 
| Pradeep Reddy Potteti | 4b0cdee | 2017-03-15 12:37:33 +0530 | [diff] [blame] | 6840 | /* Overwrite the ht_capab with offset value if configured */ | 
|  | 6841 | if (dut->ap_chwidth == AP_40 && | 
|  | 6842 | dut->ap_chwidth_offset == SEC_CH_40ABOVE) { | 
|  | 6843 | ht40plus = 1; | 
|  | 6844 | ht40minus = 0; | 
|  | 6845 | } else if (dut->ap_chwidth == AP_40 && | 
|  | 6846 | dut->ap_chwidth_offset == SEC_CH_40BELOW) { | 
|  | 6847 | ht40minus = 1; | 
|  | 6848 | ht40plus = 0; | 
|  | 6849 | } | 
|  | 6850 |  | 
| Tamizh chelvam | 431c600 | 2017-03-07 17:07:16 +0530 | [diff] [blame] | 6851 | fprintf(f, "ht_capab=%s%s%s\n", | 
|  | 6852 | ht40plus ? "[HT40+]" : "", | 
|  | 6853 | ht40minus ? "[HT40-]" : "", | 
|  | 6854 | tx_stbc ? "[TX-STBC]" : ""); | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6855 | } | 
|  | 6856 |  | 
| Sreelakshmi Konamki | b692f10 | 2016-04-26 19:47:00 +0530 | [diff] [blame] | 6857 | if ((drv == DRIVER_MAC80211 || drv == DRIVER_QNXNTO || | 
|  | 6858 | drv == DRIVER_LINUX_WCN) && | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6859 | dut->ap_mode == AP_11ac) { | 
|  | 6860 | fprintf(f, "ieee80211ac=1\n" | 
|  | 6861 | "ieee80211n=1\n" | 
|  | 6862 | "ht_capab=[HT40+]\n"); | 
|  | 6863 | } | 
|  | 6864 |  | 
| Sreelakshmi Konamki | b692f10 | 2016-04-26 19:47:00 +0530 | [diff] [blame] | 6865 | if ((drv == DRIVER_MAC80211 || drv == DRIVER_QNXNTO || | 
|  | 6866 | drv == DRIVER_LINUX_WCN) && | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6867 | (dut->ap_mode == AP_11ac || dut->ap_mode == AP_11na)) { | 
|  | 6868 | if (dut->ap_countrycode[0]) { | 
|  | 6869 | fprintf(f, "country_code=%s\n", dut->ap_countrycode); | 
|  | 6870 | fprintf(f, "ieee80211d=1\n"); | 
|  | 6871 | fprintf(f, "ieee80211h=1\n"); | 
|  | 6872 | } | 
|  | 6873 | } | 
|  | 6874 |  | 
|  | 6875 | fprintf(f, "interface=%s\n", ifname); | 
|  | 6876 | if (dut->bridge) | 
|  | 6877 | fprintf(f, "bridge=%s\n", dut->bridge); | 
|  | 6878 | fprintf(f, "channel=%d\n", dut->ap_channel); | 
|  | 6879 |  | 
|  | 6880 | if (sigma_hapd_ctrl) | 
|  | 6881 | fprintf(f, "ctrl_interface=%s\n", sigma_hapd_ctrl); | 
|  | 6882 | else | 
|  | 6883 | fprintf(f, "ctrl_interface=/var/run/hostapd\n"); | 
|  | 6884 |  | 
|  | 6885 | if (dut->ap_ssid[0]) | 
|  | 6886 | fprintf(f, "ssid=%s\n", dut->ap_ssid); | 
|  | 6887 | else | 
|  | 6888 | fprintf(f, "ssid=QCA AP OOB\n"); | 
|  | 6889 | if (dut->ap_bcnint) | 
|  | 6890 | fprintf(f, "beacon_int=%d\n", dut->ap_bcnint); | 
|  | 6891 |  | 
|  | 6892 | switch (dut->ap_key_mgmt) { | 
|  | 6893 | case AP_OPEN: | 
|  | 6894 | if (dut->ap_cipher == AP_WEP) | 
|  | 6895 | fprintf(f, "wep_key0=%s\n", dut->ap_wepkey); | 
|  | 6896 | break; | 
|  | 6897 | case AP_WPA2_PSK: | 
|  | 6898 | case AP_WPA2_PSK_MIXED: | 
|  | 6899 | case AP_WPA_PSK: | 
| Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 6900 | case AP_WPA2_SAE: | 
|  | 6901 | case AP_WPA2_PSK_SAE: | 
| Jouni Malinen | 6be21c8 | 2018-08-01 18:47:24 +0300 | [diff] [blame] | 6902 | case AP_WPA2_PSK_SHA256: | 
|  | 6903 | case AP_WPA2_FT_PSK: | 
| Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 6904 | if (dut->ap_key_mgmt == AP_WPA2_PSK || | 
|  | 6905 | dut->ap_key_mgmt == AP_WPA2_SAE || | 
| Jouni Malinen | 6be21c8 | 2018-08-01 18:47:24 +0300 | [diff] [blame] | 6906 | dut->ap_key_mgmt == AP_WPA2_PSK_SAE || | 
|  | 6907 | dut->ap_key_mgmt == AP_WPA2_PSK_SHA256 || | 
|  | 6908 | dut->ap_key_mgmt == AP_WPA2_FT_PSK) | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6909 | fprintf(f, "wpa=2\n"); | 
|  | 6910 | else if (dut->ap_key_mgmt == AP_WPA2_PSK_MIXED) | 
|  | 6911 | fprintf(f, "wpa=3\n"); | 
|  | 6912 | else | 
|  | 6913 | fprintf(f, "wpa=1\n"); | 
| Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 6914 | if (dut->ap_key_mgmt == AP_WPA2_SAE) | 
|  | 6915 | key_mgmt = "SAE"; | 
|  | 6916 | else if (dut->ap_key_mgmt == AP_WPA2_PSK_SAE) | 
|  | 6917 | key_mgmt = "WPA-PSK SAE"; | 
|  | 6918 | else | 
|  | 6919 | key_mgmt = "WPA-PSK"; | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6920 | switch (dut->ap_pmf) { | 
|  | 6921 | case AP_PMF_DISABLED: | 
| Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 6922 | fprintf(f, "wpa_key_mgmt=%s%s\n", key_mgmt, | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6923 | dut->ap_add_sha256 ? " WPA-PSK-SHA256" : ""); | 
|  | 6924 | break; | 
|  | 6925 | case AP_PMF_OPTIONAL: | 
| Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 6926 | fprintf(f, "wpa_key_mgmt=%s%s\n", key_mgmt, | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6927 | dut->ap_add_sha256 ? " WPA-PSK-SHA256" : ""); | 
|  | 6928 | break; | 
|  | 6929 | case AP_PMF_REQUIRED: | 
| Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 6930 | if (dut->ap_key_mgmt == AP_WPA2_SAE) | 
|  | 6931 | key_mgmt = "SAE"; | 
|  | 6932 | else if (dut->ap_key_mgmt == AP_WPA2_PSK_SAE) | 
|  | 6933 | key_mgmt = "WPA-PSK-SHA256 SAE"; | 
|  | 6934 | else | 
|  | 6935 | key_mgmt = "WPA-PSK-SHA256"; | 
|  | 6936 | fprintf(f, "wpa_key_mgmt=%s\n", key_mgmt); | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6937 | break; | 
|  | 6938 | } | 
| Jouni Malinen | 6be21c8 | 2018-08-01 18:47:24 +0300 | [diff] [blame] | 6939 | if (dut->ap_key_mgmt == AP_WPA2_PSK_SHA256) | 
|  | 6940 | fprintf(f, "wpa_key_mgmt=WPA-PSK-SHA256\n"); | 
|  | 6941 | else if (dut->ap_key_mgmt == AP_WPA2_FT_PSK) | 
|  | 6942 | fprintf(f, "wpa_key_mgmt=FT-PSK\n"); | 
| Jouni Malinen | 2ba2449 | 2017-11-17 12:43:59 +0200 | [diff] [blame] | 6943 | fprintf(f, "wpa_pairwise=%s\n", | 
|  | 6944 | hostapd_cipher_name(dut->ap_cipher)); | 
|  | 6945 | if (dut->ap_group_cipher != AP_NO_GROUP_CIPHER_SET) | 
|  | 6946 | fprintf(f, "group_cipher=%s\n", | 
|  | 6947 | hostapd_cipher_name(dut->ap_group_cipher)); | 
| Jouni Malinen | 2126f42 | 2017-10-11 23:24:33 +0300 | [diff] [blame] | 6948 | if (dut->ap_key_mgmt == AP_WPA2_SAE) | 
|  | 6949 | fprintf(f, "sae_password=%s\n", dut->ap_passphrase); | 
| Jouni Malinen | 6337062 | 2017-11-18 17:47:13 +0200 | [diff] [blame] | 6950 | else if (!dut->ap_passphrase[0] && dut->ap_psk[0]) | 
|  | 6951 | fprintf(f, "wpa_psk=%s", dut->ap_psk); | 
| Jouni Malinen | 2126f42 | 2017-10-11 23:24:33 +0300 | [diff] [blame] | 6952 | else | 
|  | 6953 | fprintf(f, "wpa_passphrase=%s\n", dut->ap_passphrase); | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6954 | break; | 
|  | 6955 | case AP_WPA2_EAP: | 
|  | 6956 | case AP_WPA2_EAP_MIXED: | 
|  | 6957 | case AP_WPA_EAP: | 
| Jouni Malinen | 4cf699f | 2018-06-19 00:46:27 +0300 | [diff] [blame] | 6958 | case AP_WPA2_EAP_OSEN: | 
| Jouni Malinen | 6be21c8 | 2018-08-01 18:47:24 +0300 | [diff] [blame] | 6959 | case AP_WPA2_EAP_SHA256: | 
|  | 6960 | case AP_WPA2_FT_EAP: | 
|  | 6961 | case AP_WPA2_ENT_FT_EAP: | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6962 | fprintf(f, "ieee8021x=1\n"); | 
| Jouni Malinen | 4cf699f | 2018-06-19 00:46:27 +0300 | [diff] [blame] | 6963 | if (dut->ap_key_mgmt == AP_WPA2_EAP || | 
| Jouni Malinen | 6be21c8 | 2018-08-01 18:47:24 +0300 | [diff] [blame] | 6964 | dut->ap_key_mgmt == AP_WPA2_EAP_OSEN || | 
|  | 6965 | dut->ap_key_mgmt == AP_WPA2_EAP_SHA256 || | 
|  | 6966 | dut->ap_key_mgmt == AP_WPA2_FT_EAP || | 
|  | 6967 | dut->ap_key_mgmt == AP_WPA2_ENT_FT_EAP) | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6968 | fprintf(f, "wpa=2\n"); | 
|  | 6969 | else if (dut->ap_key_mgmt == AP_WPA2_EAP_MIXED) | 
|  | 6970 | fprintf(f, "wpa=3\n"); | 
|  | 6971 | else | 
|  | 6972 | fprintf(f, "wpa=1\n"); | 
|  | 6973 | switch (dut->ap_pmf) { | 
|  | 6974 | case AP_PMF_DISABLED: | 
|  | 6975 | fprintf(f, "wpa_key_mgmt=WPA-EAP%s\n", | 
|  | 6976 | dut->ap_add_sha256 ? " WPA-EAP-SHA256" : ""); | 
|  | 6977 | break; | 
|  | 6978 | case AP_PMF_OPTIONAL: | 
| Jouni Malinen | 4cf699f | 2018-06-19 00:46:27 +0300 | [diff] [blame] | 6979 | fprintf(f, "wpa_key_mgmt=WPA-EAP%s%s\n", | 
|  | 6980 | dut->ap_add_sha256 ? " WPA-EAP-SHA256" : "", | 
|  | 6981 | dut->ap_key_mgmt == AP_WPA2_EAP_OSEN ? " OSEN" : | 
|  | 6982 | ""); | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6983 | break; | 
|  | 6984 | case AP_PMF_REQUIRED: | 
| Jouni Malinen | 4cf699f | 2018-06-19 00:46:27 +0300 | [diff] [blame] | 6985 | fprintf(f, "wpa_key_mgmt=WPA-EAP-SHA256%s\n", | 
|  | 6986 | dut->ap_key_mgmt == AP_WPA2_EAP_OSEN ? " OSEN" : | 
|  | 6987 | ""); | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 6988 | break; | 
|  | 6989 | } | 
| Jouni Malinen | 6be21c8 | 2018-08-01 18:47:24 +0300 | [diff] [blame] | 6990 | if (dut->ap_key_mgmt == AP_WPA2_EAP_SHA256) | 
|  | 6991 | fprintf(f, "wpa_key_mgmt=WPA-EAP-SHA256\n"); | 
|  | 6992 | else if (dut->ap_key_mgmt == AP_WPA2_FT_EAP) | 
|  | 6993 | fprintf(f, "wpa_key_mgmt=FT-EAP\n"); | 
|  | 6994 | else if (dut->ap_key_mgmt == AP_WPA2_ENT_FT_EAP) | 
|  | 6995 | fprintf(f, "wpa_key_mgmt=FT-EAP WPA-EAP\n"); | 
| Jouni Malinen | 2ba2449 | 2017-11-17 12:43:59 +0200 | [diff] [blame] | 6996 | fprintf(f, "wpa_pairwise=%s\n", | 
|  | 6997 | hostapd_cipher_name(dut->ap_cipher)); | 
|  | 6998 | if (dut->ap_group_cipher != AP_NO_GROUP_CIPHER_SET) | 
|  | 6999 | fprintf(f, "group_cipher=%s\n", | 
|  | 7000 | hostapd_cipher_name(dut->ap_group_cipher)); | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7001 | fprintf(f, "auth_server_addr=%s\n", dut->ap_radius_ipaddr); | 
|  | 7002 | if (dut->ap_radius_port) | 
|  | 7003 | fprintf(f, "auth_server_port=%d\n", | 
|  | 7004 | dut->ap_radius_port); | 
|  | 7005 | fprintf(f, "auth_server_shared_secret=%s\n", | 
|  | 7006 | dut->ap_radius_password); | 
| Jouni Malinen | 1a2bc99 | 2018-06-22 11:50:59 +0300 | [diff] [blame] | 7007 | if (dut->program == PROGRAM_HS2_R3) { | 
|  | 7008 | fprintf(f, "radius_das_port=3799\n"); | 
|  | 7009 | fprintf(f, "radius_das_client=0.0.0.0 %s\n", | 
|  | 7010 | dut->ap_radius_password); | 
|  | 7011 | fprintf(f, "radius_das_require_event_timestamp=1\n"); | 
|  | 7012 | } | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7013 | break; | 
| Jouni Malinen | ad395a2 | 2017-09-01 21:13:46 +0300 | [diff] [blame] | 7014 | case AP_SUITEB: | 
|  | 7015 | fprintf(f, "ieee8021x=1\n"); | 
|  | 7016 | fprintf(f, "wpa=2\n"); | 
|  | 7017 | fprintf(f, "wpa_key_mgmt=WPA-EAP-SUITE-B-192\n"); | 
| Jouni Malinen | 3d633da | 2017-09-14 22:19:21 +0300 | [diff] [blame] | 7018 | fprintf(f, "wpa_pairwise=%s\n", | 
|  | 7019 | hostapd_cipher_name(dut->ap_cipher)); | 
| Jouni Malinen | 2ba2449 | 2017-11-17 12:43:59 +0200 | [diff] [blame] | 7020 | if (dut->ap_group_cipher != AP_NO_GROUP_CIPHER_SET) | 
|  | 7021 | fprintf(f, "group_cipher=%s\n", | 
|  | 7022 | hostapd_cipher_name(dut->ap_group_cipher)); | 
| Jouni Malinen | 3d633da | 2017-09-14 22:19:21 +0300 | [diff] [blame] | 7023 | if (dut->ap_group_mgmt_cipher != AP_NO_GROUP_MGMT_CIPHER_SET) | 
|  | 7024 | fprintf(f, "group_mgmt_cipher=%s\n", | 
|  | 7025 | hostapd_group_mgmt_cipher_name( | 
|  | 7026 | dut->ap_group_mgmt_cipher)); | 
| Jouni Malinen | ad395a2 | 2017-09-01 21:13:46 +0300 | [diff] [blame] | 7027 | fprintf(f, "auth_server_addr=%s\n", dut->ap_radius_ipaddr); | 
|  | 7028 | if (dut->ap_radius_port) | 
|  | 7029 | fprintf(f, "auth_server_port=%d\n", | 
|  | 7030 | dut->ap_radius_port); | 
|  | 7031 | fprintf(f, "auth_server_shared_secret=%s\n", | 
|  | 7032 | dut->ap_radius_password); | 
|  | 7033 | break; | 
| Jouni Malinen | 147b3c3 | 2017-10-09 16:51:54 +0300 | [diff] [blame] | 7034 | case AP_WPA2_OWE: | 
|  | 7035 | fprintf(f, "wpa=2\n"); | 
|  | 7036 | fprintf(f, "wpa_key_mgmt=OWE\n"); | 
|  | 7037 | fprintf(f, "rsn_pairwise=%s\n", | 
|  | 7038 | hostapd_cipher_name(dut->ap_cipher)); | 
| Jouni Malinen | 72461d4 | 2017-10-10 19:20:45 +0300 | [diff] [blame] | 7039 | if (dut->ap_sae_groups) | 
|  | 7040 | fprintf(f, "owe_groups=%s\n", dut->ap_sae_groups); | 
| Jouni Malinen | 147b3c3 | 2017-10-09 16:51:54 +0300 | [diff] [blame] | 7041 | break; | 
| Jouni Malinen | c2b9121 | 2018-09-12 02:26:39 +0300 | [diff] [blame] | 7042 | case AP_OSEN: | 
|  | 7043 | fprintf(f, "osen=1\n"); | 
|  | 7044 | fprintf(f, "disable_dgaf=1\n"); | 
|  | 7045 | fprintf(f, "wpa_pairwise=%s\n", | 
|  | 7046 | hostapd_cipher_name(dut->ap_cipher)); | 
|  | 7047 | if (dut->ap_group_cipher != AP_NO_GROUP_CIPHER_SET) | 
|  | 7048 | fprintf(f, "group_cipher=%s\n", | 
|  | 7049 | hostapd_cipher_name(dut->ap_group_cipher)); | 
|  | 7050 | fprintf(f, "auth_server_addr=%s\n", dut->ap_radius_ipaddr); | 
|  | 7051 | if (dut->ap_radius_port) | 
|  | 7052 | fprintf(f, "auth_server_port=%d\n", | 
|  | 7053 | dut->ap_radius_port); | 
|  | 7054 | fprintf(f, "auth_server_shared_secret=%s\n", | 
|  | 7055 | dut->ap_radius_password); | 
|  | 7056 | break; | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7057 | } | 
|  | 7058 |  | 
| Anilkumar Kolli | f0fd599 | 2017-02-23 12:54:01 +0530 | [diff] [blame] | 7059 | if (dut->ap_rsn_preauth) | 
|  | 7060 | fprintf(f, "rsn_preauth=1\n"); | 
|  | 7061 |  | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7062 | switch (dut->ap_pmf) { | 
|  | 7063 | case AP_PMF_DISABLED: | 
|  | 7064 | break; | 
|  | 7065 | case AP_PMF_OPTIONAL: | 
|  | 7066 | fprintf(f, "ieee80211w=1\n"); | 
| Jouni Malinen | 1287cd7 | 2018-01-04 17:08:01 +0200 | [diff] [blame] | 7067 | if (dut->ap_key_mgmt == AP_WPA2_PSK_SAE) | 
|  | 7068 | fprintf(f, "sae_require_mfp=1\n"); | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7069 | break; | 
|  | 7070 | case AP_PMF_REQUIRED: | 
|  | 7071 | fprintf(f, "ieee80211w=2\n"); | 
|  | 7072 | break; | 
|  | 7073 | } | 
|  | 7074 |  | 
| Jouni Malinen | 6be21c8 | 2018-08-01 18:47:24 +0300 | [diff] [blame] | 7075 | if (ap_ft_enabled(dut)) { | 
|  | 7076 | unsigned char own_addr[ETH_ALEN]; | 
|  | 7077 |  | 
|  | 7078 | fprintf(f, "mobility_domain=%s\n", dut->ap_mobility_domain); | 
|  | 7079 | fprintf(f, "ft_over_ds=0\n"); | 
|  | 7080 | fprintf(f, "nas_identifier=nas1.example.com\n"); | 
|  | 7081 | if (get_hwaddr(ifname, own_addr) < 0) { | 
|  | 7082 | memset(own_addr, 0, ETH_ALEN); | 
|  | 7083 | own_addr[0] = 0x02; | 
|  | 7084 | } | 
|  | 7085 | fprintf(f, "r1_key_holder=%02x%02x%02x%02x%02x%02x\n", | 
|  | 7086 | own_addr[0], own_addr[1], own_addr[2], | 
|  | 7087 | own_addr[3], own_addr[4], own_addr[5]); | 
|  | 7088 | fprintf(f, "ft_psk_generate_local=1\n"); | 
|  | 7089 | fprintf(f, "pmk_r1_push=0\n"); | 
|  | 7090 | fprintf(f, | 
|  | 7091 | "r0kh=ff:ff:ff:ff:ff:ff * 00112233445566778899aabbccddeeff00112233445566778899aabbccddeeff"); | 
|  | 7092 | fprintf(f, | 
|  | 7093 | "r1kh=00:00:00:00:00:00 00:00:00:00:00:00 00112233445566778899aabbccddeeff00112233445566778899aabbccddeeff"); | 
|  | 7094 | } | 
|  | 7095 |  | 
| Jouni Malinen | 3c367e8 | 2017-06-23 17:01:47 +0300 | [diff] [blame] | 7096 | if (dut->rsne_override) | 
|  | 7097 | fprintf(f, "own_ie_override=%s\n", dut->rsne_override); | 
|  | 7098 |  | 
| Jouni Malinen | 6814313 | 2017-09-02 02:34:08 +0300 | [diff] [blame] | 7099 | if (dut->sae_commit_override) | 
|  | 7100 | fprintf(f, "sae_commit_override=%s\n", | 
|  | 7101 | dut->sae_commit_override); | 
|  | 7102 |  | 
| Jouni Malinen | ed670f4 | 2017-08-31 01:39:28 +0300 | [diff] [blame] | 7103 | if (dut->ap_sae_groups) | 
|  | 7104 | fprintf(f, "sae_groups=%s\n", dut->ap_sae_groups); | 
| Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 7105 |  | 
| Jouni Malinen | 2f524ce | 2017-08-31 01:43:29 +0300 | [diff] [blame] | 7106 | if (dut->sae_anti_clogging_threshold >= 0) | 
|  | 7107 | fprintf(f, "sae_anti_clogging_threshold=%d\n", | 
|  | 7108 | dut->sae_anti_clogging_threshold); | 
| Jouni Malinen | b347db0 | 2017-09-02 01:36:03 +0300 | [diff] [blame] | 7109 | if (dut->sae_reflection) | 
|  | 7110 | fprintf(f, "sae_reflection_attack=1\n"); | 
| Jouni Malinen | 2f524ce | 2017-08-31 01:43:29 +0300 | [diff] [blame] | 7111 |  | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7112 | if (dut->ap_p2p_mgmt) | 
|  | 7113 | fprintf(f, "manage_p2p=1\n"); | 
|  | 7114 |  | 
|  | 7115 | if (dut->ap_tdls_prohibit || dut->ap_l2tif) | 
|  | 7116 | fprintf(f, "tdls_prohibit=1\n"); | 
|  | 7117 | if (dut->ap_tdls_prohibit_chswitch || dut->ap_l2tif) | 
|  | 7118 | fprintf(f, "tdls_prohibit_chan_switch=1\n"); | 
|  | 7119 | if (dut->ap_p2p_cross_connect >= 0) { | 
|  | 7120 | fprintf(f, "manage_p2p=1\n" | 
|  | 7121 | "allow_cross_connection=%d\n", | 
|  | 7122 | dut->ap_p2p_cross_connect); | 
|  | 7123 | } | 
|  | 7124 |  | 
| Jouni Malinen | 4d479c9 | 2018-11-06 00:43:36 +0200 | [diff] [blame] | 7125 | if (dut->ap_l2tif || dut->ap_proxy_arp || | 
|  | 7126 | dut->ap_key_mgmt == AP_WPA2_EAP_OSEN) { | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7127 | if (!dut->bridge) { | 
|  | 7128 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 7129 | "Bridge must be configured. Run with -b <brname>."); | 
|  | 7130 | fclose(f); | 
|  | 7131 | return -2; | 
|  | 7132 | } | 
|  | 7133 | fprintf(f, "ap_isolate=1\n"); | 
|  | 7134 | } | 
|  | 7135 |  | 
|  | 7136 | if (dut->ap_proxy_arp) | 
|  | 7137 | fprintf(f, "proxy_arp=1\n"); | 
|  | 7138 |  | 
| Pradeep Reddy POTTETI | 0d3db63 | 2016-03-11 15:21:11 +0530 | [diff] [blame] | 7139 | if (dut->ap_wme) | 
|  | 7140 | fprintf(f, "wmm_enabled=1\n"); | 
|  | 7141 |  | 
| Mohammed Shafi Shajakhan | 02e3b82 | 2017-02-23 04:15:02 +0530 | [diff] [blame] | 7142 | if (dut->ap_wmmps == AP_WMMPS_ON) | 
|  | 7143 | fprintf(f, "uapsd_advertisement_enabled=1\n"); | 
|  | 7144 |  | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7145 | if (dut->ap_hs2) { | 
|  | 7146 | if (dut->ap_bss_load) { | 
|  | 7147 | char *bss_load; | 
|  | 7148 |  | 
|  | 7149 | switch (dut->ap_bss_load) { | 
|  | 7150 | case -1: | 
|  | 7151 | bss_load = "bss_load_update_period=10"; | 
|  | 7152 | break; | 
|  | 7153 | case 1: | 
|  | 7154 | /* STA count: 1, CU: 50, AAC: 65535 */ | 
|  | 7155 | bss_load = "bss_load_test=1:50:65535"; | 
|  | 7156 | break; | 
|  | 7157 | case 2: | 
|  | 7158 | /* STA count: 1, CU: 200, AAC: 65535 */ | 
|  | 7159 | bss_load = "bss_load_test=1:200:65535"; | 
|  | 7160 | break; | 
|  | 7161 | case 3: | 
|  | 7162 | /* STA count: 1, CU: 75, AAC: 65535 */ | 
|  | 7163 | bss_load = "bss_load_test=1:75:65535"; | 
|  | 7164 | break; | 
|  | 7165 | default: | 
|  | 7166 | bss_load = NULL; | 
|  | 7167 | break; | 
|  | 7168 | } | 
|  | 7169 |  | 
|  | 7170 | if (!bss_load) { | 
|  | 7171 | fclose(f); | 
|  | 7172 | return -2; | 
|  | 7173 | } | 
|  | 7174 | fprintf(f, "%s\n", bss_load); | 
|  | 7175 | } | 
|  | 7176 |  | 
|  | 7177 | if (append_hostapd_conf_hs2(dut, f)) { | 
|  | 7178 | fclose(f); | 
|  | 7179 | return -2; | 
|  | 7180 | } | 
|  | 7181 | } | 
|  | 7182 |  | 
|  | 7183 | if (dut->ap_interworking && append_hostapd_conf_interworking(dut, f)) { | 
|  | 7184 | fclose(f); | 
|  | 7185 | return -2; | 
|  | 7186 | } | 
|  | 7187 |  | 
| Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 7188 | if (dut->ap_hs2 && strlen(dut->ap_tag_ssid[0])) { | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7189 | unsigned char bssid[6]; | 
|  | 7190 | char ifname2[50]; | 
|  | 7191 |  | 
| Pradeep Reddy POTTETI | 673d85c | 2016-07-26 19:08:07 +0530 | [diff] [blame] | 7192 | if (get_hwaddr(ifname, bssid)) { | 
|  | 7193 | fclose(f); | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7194 | return -2; | 
| Pradeep Reddy POTTETI | 673d85c | 2016-07-26 19:08:07 +0530 | [diff] [blame] | 7195 | } | 
| Jouni Malinen | b37f0bc | 2018-05-03 18:29:55 +0300 | [diff] [blame] | 7196 | if (bssid[0] & 0x02) | 
|  | 7197 | bssid[5] ^= 0x01; | 
|  | 7198 | else | 
|  | 7199 | bssid[0] |= 0x02; | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7200 |  | 
|  | 7201 | snprintf(ifname2, sizeof(ifname2), "%s_1", ifname); | 
| Jouni Malinen | 10b47b2 | 2018-06-07 23:28:07 +0300 | [diff] [blame] | 7202 | fprintf(f, "bss=%s\n", ifname2); | 
| Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 7203 | fprintf(f, "ssid=%s\n", dut->ap_tag_ssid[0]); | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7204 | if (dut->bridge) | 
|  | 7205 | fprintf(f, "bridge=%s\n", dut->bridge); | 
| Liangwei Dong | 911cb14 | 2019-01-10 14:35:55 +0800 | [diff] [blame] | 7206 |  | 
|  | 7207 | if (drv == DRIVER_LINUX_WCN) | 
|  | 7208 | fprintf(f, "use_driver_iface_addr=1\n"); | 
|  | 7209 | else | 
|  | 7210 | fprintf(f, "bssid=%02x:%02x:%02x:%02x:%02x:%02x\n", | 
|  | 7211 | bssid[0], bssid[1], bssid[2], bssid[3], | 
|  | 7212 | bssid[4], bssid[5]); | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7213 |  | 
| Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 7214 | if (dut->ap_tag_key_mgmt[0] == AP2_OSEN) { | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7215 | fprintf(f, "osen=1\n"); | 
| Sriram R | 61f5d95 | 2018-06-07 17:47:07 +0530 | [diff] [blame] | 7216 | /* Disable DGAF for OSEN BSS */ | 
|  | 7217 | fprintf(f, "disable_dgaf=1\n"); | 
| Jouni Malinen | dbbc2c4 | 2018-11-14 23:55:41 +0200 | [diff] [blame] | 7218 | fprintf(f, "ap_isolate=1\n"); | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7219 | if (strlen(dut->ap2_radius_ipaddr)) | 
|  | 7220 | fprintf(f, "auth_server_addr=%s\n", | 
|  | 7221 | dut->ap2_radius_ipaddr); | 
|  | 7222 | if (dut->ap2_radius_port) | 
|  | 7223 | fprintf(f, "auth_server_port=%d\n", | 
|  | 7224 | dut->ap2_radius_port); | 
|  | 7225 | if (strlen(dut->ap2_radius_password)) | 
|  | 7226 | fprintf(f, "auth_server_shared_secret=%s\n", | 
|  | 7227 | dut->ap2_radius_password); | 
| Jouni Malinen | dbbc2c4 | 2018-11-14 23:55:41 +0200 | [diff] [blame] | 7228 |  | 
|  | 7229 | set_ebtables_forward_drop(dut, ifname, ifname2); | 
|  | 7230 | } else if (dut->ap2_osu) { | 
|  | 7231 | fprintf(f, "ap_isolate=1\n"); | 
|  | 7232 | set_ebtables_forward_drop(dut, ifname, ifname2); | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7233 | } | 
|  | 7234 |  | 
|  | 7235 | if (dut->ap2_proxy_arp) { | 
|  | 7236 | if (!dut->bridge) { | 
|  | 7237 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 7238 | "Bridge must be configured. Run with -b <brname>."); | 
|  | 7239 | fclose(f); | 
|  | 7240 | return -2; | 
|  | 7241 | } | 
|  | 7242 | fprintf(f, "ap_isolate=1\n"); | 
|  | 7243 | fprintf(f, "proxy_arp=1\n"); | 
|  | 7244 |  | 
|  | 7245 | if (set_ebtables_proxy_arp(dut, "FORWARD", ifname2) || | 
|  | 7246 | set_ebtables_proxy_arp(dut, "OUTPUT", ifname2)) { | 
|  | 7247 | fclose(f); | 
|  | 7248 | return -2; | 
|  | 7249 | } | 
|  | 7250 |  | 
|  | 7251 | } | 
|  | 7252 | } | 
|  | 7253 |  | 
|  | 7254 | if (dut->program == PROGRAM_WPS) { | 
| Alexei Avshalom Lazar | d303e47 | 2018-12-23 16:49:49 +0200 | [diff] [blame] | 7255 | /* 60G WPS tests requires wps_state of 2 (configured) */ | 
|  | 7256 | int wps_state = is_60g_sigma_dut(dut) ? 2 : 1; | 
|  | 7257 |  | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7258 | fprintf(f, "eap_server=1\n" | 
| Alexei Avshalom Lazar | d303e47 | 2018-12-23 16:49:49 +0200 | [diff] [blame] | 7259 | "wps_state=%d\n" | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7260 | "device_name=QCA AP\n" | 
|  | 7261 | "manufacturer=QCA\n" | 
|  | 7262 | "device_type=6-0050F204-1\n" | 
| Alexei Avshalom Lazar | d303e47 | 2018-12-23 16:49:49 +0200 | [diff] [blame] | 7263 | "config_methods=label virtual_display %s" | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7264 | "virtual_push_button keypad%s\n" | 
|  | 7265 | "ap_pin=12345670\n" | 
|  | 7266 | "friendly_name=QCA Access Point\n" | 
|  | 7267 | "upnp_iface=%s\n", | 
| Alexei Avshalom Lazar | d303e47 | 2018-12-23 16:49:49 +0200 | [diff] [blame] | 7268 | wps_state, | 
|  | 7269 | is_60g_sigma_dut(dut) ? "physical_display " : "", | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7270 | dut->ap_wpsnfc ? " nfc_interface ext_nfc_token" : "", | 
|  | 7271 | dut->bridge ? dut->bridge : ifname); | 
| Alexei Avshalom Lazar | 33f700c | 2018-12-18 16:00:39 +0200 | [diff] [blame] | 7272 | if (dut->wsc_fragment) { | 
|  | 7273 | fprintf(f, "device_name=%s\n" | 
|  | 7274 | "manufacturer=%s\n" | 
|  | 7275 | "model_name=%s\n" | 
|  | 7276 | "model_number=%s\n" | 
|  | 7277 | "serial_number=%s\n", | 
|  | 7278 | WPS_LONG_DEVICE_NAME, | 
|  | 7279 | WPS_LONG_MANUFACTURER, | 
|  | 7280 | WPS_LONG_MODEL_NAME, | 
|  | 7281 | WPS_LONG_MODEL_NUMBER, | 
|  | 7282 | WPS_LONG_SERIAL_NUMBER); | 
|  | 7283 | } else { | 
|  | 7284 | fprintf(f, "device_name=QCA AP\n" | 
|  | 7285 | "manufacturer=QCA\n"); | 
|  | 7286 | } | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7287 | } | 
|  | 7288 |  | 
|  | 7289 | if (dut->program == PROGRAM_VHT) { | 
|  | 7290 | int vht_oper_centr_freq_idx; | 
|  | 7291 |  | 
|  | 7292 | if (check_channel(dut->ap_channel) < 0) { | 
|  | 7293 | send_resp(dut, conn, SIGMA_INVALID, | 
|  | 7294 | "errorCode,Invalid channel"); | 
| Pradeep Reddy POTTETI | 673d85c | 2016-07-26 19:08:07 +0530 | [diff] [blame] | 7295 | fclose(f); | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7296 | return 0; | 
|  | 7297 | } | 
|  | 7298 |  | 
|  | 7299 | switch (dut->ap_chwidth) { | 
|  | 7300 | case AP_20: | 
|  | 7301 | dut->ap_vht_chwidth = AP_20_40_VHT_OPER_CHWIDTH; | 
|  | 7302 | vht_oper_centr_freq_idx = | 
|  | 7303 | get_oper_centr_freq_seq_idx(20, | 
|  | 7304 | dut->ap_channel); | 
|  | 7305 | break; | 
|  | 7306 | case AP_40: | 
|  | 7307 | dut->ap_vht_chwidth = AP_20_40_VHT_OPER_CHWIDTH; | 
|  | 7308 | vht_oper_centr_freq_idx = | 
|  | 7309 | get_oper_centr_freq_seq_idx(40, | 
|  | 7310 | dut->ap_channel); | 
|  | 7311 | break; | 
|  | 7312 | case AP_80: | 
|  | 7313 | dut->ap_vht_chwidth = AP_80_VHT_OPER_CHWIDTH; | 
|  | 7314 | vht_oper_centr_freq_idx = | 
|  | 7315 | get_oper_centr_freq_seq_idx(80, | 
|  | 7316 | dut->ap_channel); | 
|  | 7317 | break; | 
|  | 7318 | case AP_160: | 
|  | 7319 | dut->ap_vht_chwidth = AP_160_VHT_OPER_CHWIDTH; | 
|  | 7320 | vht_oper_centr_freq_idx = | 
|  | 7321 | get_oper_centr_freq_seq_idx(160, | 
|  | 7322 | dut->ap_channel); | 
|  | 7323 | break; | 
|  | 7324 | default: | 
|  | 7325 | dut->ap_vht_chwidth = VHT_DEFAULT_OPER_CHWIDTH; | 
|  | 7326 | vht_oper_centr_freq_idx = | 
|  | 7327 | get_oper_centr_freq_seq_idx(80, | 
|  | 7328 | dut->ap_channel); | 
|  | 7329 | break; | 
|  | 7330 | } | 
|  | 7331 | fprintf(f, "vht_oper_centr_freq_seg0_idx=%d\n", | 
|  | 7332 | vht_oper_centr_freq_idx); | 
|  | 7333 | fprintf(f, "vht_oper_chwidth=%d\n", dut->ap_vht_chwidth); | 
|  | 7334 |  | 
| Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 7335 | if (dut->ap_sgi80 || dut->ap_txBF || | 
|  | 7336 | dut->ap_ldpc != VALUE_NOT_SET || | 
| Mohammed Shafi Shajakhan | f3e68d9 | 2016-06-02 20:10:57 +0530 | [diff] [blame] | 7337 | dut->ap_tx_stbc || dut->ap_mu_txBF) { | 
|  | 7338 | fprintf(f, "vht_capab=%s%s%s%s%s\n", | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7339 | dut->ap_sgi80 ? "[SHORT-GI-80]" : "", | 
| Mohammed Shafi Shajakhan | c039ce3 | 2016-06-02 20:10:58 +0530 | [diff] [blame] | 7340 | dut->ap_txBF ? | 
| Tamizh chelvam | 8312f6d | 2016-06-02 20:10:59 +0530 | [diff] [blame] | 7341 | "[SU-BEAMFORMER][SU-BEAMFORMEE][BF-ANTENNA-2][SOUNDING-DIMENSION-2]" : "", | 
| Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 7342 | (dut->ap_ldpc == VALUE_ENABLED) ? | 
|  | 7343 | "[RXLDPC]" : "", | 
| Mohammed Shafi Shajakhan | f3e68d9 | 2016-06-02 20:10:57 +0530 | [diff] [blame] | 7344 | dut->ap_tx_stbc ? "[TX-STBC-2BY1]" : "", | 
|  | 7345 | dut->ap_mu_txBF ? "[MU-BEAMFORMER]" : ""); | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7346 | } | 
|  | 7347 | } | 
|  | 7348 |  | 
| Jouni Malinen | 6d1d739 | 2017-10-10 20:35:29 +0300 | [diff] [blame] | 7349 | if (dut->ap_key_mgmt == AP_WPA2_OWE && dut->ap_tag_ssid[0][0] && | 
|  | 7350 | dut->ap_tag_key_mgmt[0] == AP2_OPEN) { | 
|  | 7351 | /* OWE transition mode */ | 
|  | 7352 | unsigned char bssid[6]; | 
|  | 7353 | char ifname2[50]; | 
|  | 7354 | unsigned long val; | 
|  | 7355 | FILE *f2; | 
|  | 7356 |  | 
|  | 7357 | snprintf(ifname2, sizeof(ifname2), "%s_1", ifname); | 
|  | 7358 |  | 
|  | 7359 | fprintf(f, "owe_transition_ifname=%s\n", ifname2); | 
|  | 7360 | val = 0x12345678; /* default to something */ | 
|  | 7361 | f2 = fopen("/dev/urandom", "r"); | 
|  | 7362 | if (f2) { | 
|  | 7363 | if (fread(&val, 1, sizeof(val), f2) != sizeof(val)) { | 
|  | 7364 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 7365 | "Could not read /dev/urandom"); | 
|  | 7366 | } | 
|  | 7367 | fclose(f2); | 
|  | 7368 | } | 
|  | 7369 | fprintf(f, "ssid=owe-%lx\n", val); | 
| Liangwei Dong | d3b87da | 2019-01-09 20:10:20 +0800 | [diff] [blame] | 7370 | fprintf(f, "ignore_broadcast_ssid=1\n"); | 
| Jouni Malinen | 6d1d739 | 2017-10-10 20:35:29 +0300 | [diff] [blame] | 7371 |  | 
|  | 7372 | if (get_hwaddr(ifname, bssid)) { | 
|  | 7373 | fclose(f); | 
|  | 7374 | return -2; | 
|  | 7375 | } | 
|  | 7376 | if (bssid[0] & 0x02) | 
|  | 7377 | bssid[5] ^= 0x01; | 
|  | 7378 | else | 
|  | 7379 | bssid[0] |= 0x02; | 
|  | 7380 |  | 
|  | 7381 | fprintf(f, "bss=%s\n", ifname2); | 
|  | 7382 | fprintf(f, "ssid=%s\n", dut->ap_ssid); | 
|  | 7383 | if (dut->bridge) | 
|  | 7384 | fprintf(f, "bridge=%s\n", dut->bridge); | 
| Liangwei Dong | 911cb14 | 2019-01-10 14:35:55 +0800 | [diff] [blame] | 7385 | if (drv == DRIVER_LINUX_WCN) | 
|  | 7386 | fprintf(f, "use_driver_iface_addr=1\n"); | 
|  | 7387 | else | 
|  | 7388 | fprintf(f, "bssid=%02x:%02x:%02x:%02x:%02x:%02x\n", | 
|  | 7389 | bssid[0], bssid[1], bssid[2], bssid[3], | 
|  | 7390 | bssid[4], bssid[5]); | 
| Jouni Malinen | 6d1d739 | 2017-10-10 20:35:29 +0300 | [diff] [blame] | 7391 | fprintf(f, "owe_transition_ifname=%s\n", ifname); | 
|  | 7392 | } | 
|  | 7393 |  | 
| Jouni Malinen | 353ba8b | 2018-01-10 17:04:12 +0200 | [diff] [blame] | 7394 | if (dut->ap_key_mgmt == AP_OPEN && | 
|  | 7395 | dut->ap_tag_key_mgmt[0] == AP2_WPA2_OWE) { | 
|  | 7396 | /* OWE transition mode */ | 
|  | 7397 | unsigned char bssid[6]; | 
|  | 7398 | char ifname2[50]; | 
|  | 7399 | unsigned long val; | 
|  | 7400 | FILE *f2; | 
|  | 7401 |  | 
|  | 7402 | snprintf(ifname2, sizeof(ifname2), "%s_1", ifname); | 
|  | 7403 |  | 
|  | 7404 | fprintf(f, "owe_transition_ifname=%s\n", ifname2); | 
|  | 7405 | fprintf(f, "ssid=%s\n", dut->ap_ssid); | 
|  | 7406 |  | 
|  | 7407 | if (get_hwaddr(ifname, bssid)) { | 
|  | 7408 | fclose(f); | 
|  | 7409 | return -2; | 
|  | 7410 | } | 
|  | 7411 | if (bssid[0] & 0x02) | 
|  | 7412 | bssid[5] ^= 0x01; | 
|  | 7413 | else | 
|  | 7414 | bssid[0] |= 0x02; | 
|  | 7415 |  | 
|  | 7416 | fprintf(f, "bss=%s\n", ifname2); | 
|  | 7417 | val = 0x12345678; /* default to something */ | 
|  | 7418 | f2 = fopen("/dev/urandom", "r"); | 
|  | 7419 | if (f2) { | 
|  | 7420 | if (fread(&val, 1, sizeof(val), f2) != sizeof(val)) { | 
|  | 7421 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 7422 | "Could not read /dev/urandom"); | 
|  | 7423 | } | 
|  | 7424 | fclose(f2); | 
|  | 7425 | } | 
|  | 7426 | fprintf(f, "ssid=owe-%lx\n", val); | 
|  | 7427 | if (dut->bridge) | 
|  | 7428 | fprintf(f, "bridge=%s\n", dut->bridge); | 
| Liangwei Dong | 911cb14 | 2019-01-10 14:35:55 +0800 | [diff] [blame] | 7429 | if (drv == DRIVER_LINUX_WCN) | 
|  | 7430 | fprintf(f, "use_driver_iface_addr=1\n"); | 
|  | 7431 | else | 
|  | 7432 | fprintf(f, "bssid=%02x:%02x:%02x:%02x:%02x:%02x\n", | 
|  | 7433 | bssid[0], bssid[1], bssid[2], bssid[3], | 
|  | 7434 | bssid[4], bssid[5]); | 
| Jouni Malinen | 353ba8b | 2018-01-10 17:04:12 +0200 | [diff] [blame] | 7435 | fprintf(f, "owe_transition_ifname=%s\n", ifname); | 
|  | 7436 | fprintf(f, "wpa=2\n"); | 
|  | 7437 | fprintf(f, "wpa_key_mgmt=OWE\n"); | 
|  | 7438 | fprintf(f, "rsn_pairwise=CCMP\n"); | 
|  | 7439 | fprintf(f, "ieee80211w=2\n"); | 
| Liangwei Dong | d3b87da | 2019-01-09 20:10:20 +0800 | [diff] [blame] | 7440 | fprintf(f, "ignore_broadcast_ssid=1\n"); | 
| Jouni Malinen | 353ba8b | 2018-01-10 17:04:12 +0200 | [diff] [blame] | 7441 | if (dut->ap_sae_groups) | 
|  | 7442 | fprintf(f, "owe_groups=%s\n", dut->ap_sae_groups); | 
|  | 7443 | } | 
|  | 7444 |  | 
| Ankita Bajaj | 0d5825b | 2017-10-25 16:20:17 +0530 | [diff] [blame] | 7445 | if (dut->program == PROGRAM_OCE) { | 
|  | 7446 | fprintf(f, "oce=%d\n", | 
|  | 7447 | dut->dev_role == DEVROLE_STA_CFON ? 2 : 1); | 
|  | 7448 | } | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7449 | fclose(f); | 
| Jouni Malinen | d6bf1b4 | 2017-06-23 17:51:01 +0300 | [diff] [blame] | 7450 | if (dut->use_hostapd_pid_file) | 
|  | 7451 | kill_hostapd_process_pid(dut); | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7452 | #ifdef __QNXNTO__ | 
|  | 7453 | if (system("slay hostapd") == 0) | 
|  | 7454 | #else /* __QNXNTO__ */ | 
| Jouni Malinen | d6bf1b4 | 2017-06-23 17:51:01 +0300 | [diff] [blame] | 7455 | if (!dut->use_hostapd_pid_file && | 
|  | 7456 | (kill_process(dut, "(hostapd)", 1, SIGTERM) == 0 || | 
|  | 7457 | system("killall hostapd") == 0)) | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7458 | #endif /* __QNXNTO__ */ | 
|  | 7459 | { | 
|  | 7460 | int i; | 
|  | 7461 | /* Wait some time to allow hostapd to complete cleanup before | 
|  | 7462 | * starting a new process */ | 
|  | 7463 | for (i = 0; i < 10; i++) { | 
|  | 7464 | usleep(500000); | 
|  | 7465 | #ifdef __QNXNTO__ | 
|  | 7466 | if (system("pidin | grep hostapd") != 0) | 
|  | 7467 | break; | 
|  | 7468 | #else /* __QNXNTO__ */ | 
|  | 7469 | if (system("pidof hostapd") != 0) | 
|  | 7470 | break; | 
|  | 7471 | #endif /* __QNXNTO__ */ | 
|  | 7472 | } | 
|  | 7473 | } | 
| Jouni Malinen | d86e582 | 2017-08-29 03:55:32 +0300 | [diff] [blame] | 7474 | dut->hostapd_running = 0; | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7475 |  | 
| Pradeep Reddy POTTETI | a076c30 | 2016-05-16 13:36:07 +0530 | [diff] [blame] | 7476 | #ifdef ANDROID | 
|  | 7477 | /* Set proper conf file permissions so that hostapd process | 
|  | 7478 | * can access it. | 
|  | 7479 | */ | 
|  | 7480 | if (chmod(SIGMA_TMPDIR "/sigma_dut-ap.conf", | 
|  | 7481 | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP) < 0) | 
|  | 7482 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 7483 | "Error changing permissions"); | 
|  | 7484 |  | 
| Srinivas Dasari | a1deeaa | 2018-06-18 22:54:04 +0530 | [diff] [blame] | 7485 | gr = getgrnam("wifi"); | 
|  | 7486 | if (!gr || | 
|  | 7487 | chown(SIGMA_TMPDIR "/sigma_dut-ap.conf", -1, gr->gr_gid) < 0) | 
| Pradeep Reddy POTTETI | a076c30 | 2016-05-16 13:36:07 +0530 | [diff] [blame] | 7488 | sigma_dut_print(dut, DUT_MSG_ERROR, "Error changing groupid"); | 
|  | 7489 | #endif /* ANDROID */ | 
|  | 7490 |  | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7491 | if (drv == DRIVER_QNXNTO) { | 
|  | 7492 | snprintf(buf, sizeof(buf), | 
| Pradeep Reddy POTTETI | bf4a974 | 2016-02-04 12:32:30 +0530 | [diff] [blame] | 7493 | "hostapd -B %s%s %s%s" SIGMA_TMPDIR | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7494 | "/sigma_dut-ap.conf", | 
|  | 7495 | dut->hostapd_debug_log ? "-ddKt -f " : "", | 
|  | 7496 | dut->hostapd_debug_log ? dut->hostapd_debug_log : "", | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7497 | dut->hostapd_entropy_log ? " -e" : "", | 
|  | 7498 | dut->hostapd_entropy_log ? dut->hostapd_entropy_log : | 
|  | 7499 | ""); | 
|  | 7500 | } else { | 
|  | 7501 | /* | 
|  | 7502 | * It looks like a monitor interface can cause some issues for | 
|  | 7503 | * beaconing, so remove it (if injection was used) before | 
|  | 7504 | * starting hostapd. | 
|  | 7505 | */ | 
|  | 7506 | if (if_nametoindex("sigmadut") > 0 && | 
|  | 7507 | system("iw dev sigmadut del") != 0) | 
|  | 7508 | sigma_dut_print(dut, DUT_MSG_ERROR, "Failed to remove " | 
|  | 7509 | "monitor interface"); | 
|  | 7510 |  | 
| Jouni Malinen | d6bf1b4 | 2017-06-23 17:51:01 +0300 | [diff] [blame] | 7511 | snprintf(path, sizeof(path), "%shostapd", | 
|  | 7512 | file_exists("hostapd") ? "./" : ""); | 
|  | 7513 | snprintf(buf, sizeof(buf), "%s -B%s%s%s%s%s " SIGMA_TMPDIR | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7514 | "/sigma_dut-ap.conf", | 
| Jouni Malinen | d6bf1b4 | 2017-06-23 17:51:01 +0300 | [diff] [blame] | 7515 | dut->hostapd_bin ? dut->hostapd_bin : path, | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7516 | dut->hostapd_debug_log ? " -ddKt -f" : "", | 
|  | 7517 | dut->hostapd_debug_log ? dut->hostapd_debug_log : "", | 
|  | 7518 | dut->hostapd_entropy_log ? " -e" : "", | 
|  | 7519 | dut->hostapd_entropy_log ? dut->hostapd_entropy_log : | 
| Jouni Malinen | d6bf1b4 | 2017-06-23 17:51:01 +0300 | [diff] [blame] | 7520 | "", | 
|  | 7521 | dut->use_hostapd_pid_file ? | 
|  | 7522 | " -P " SIGMA_DUT_HOSTAPD_PID_FILE : ""); | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7523 | } | 
|  | 7524 |  | 
| Jouni Malinen | d6bf1b4 | 2017-06-23 17:51:01 +0300 | [diff] [blame] | 7525 | sigma_dut_print(dut, DUT_MSG_DEBUG, "hostapd command: %s", buf); | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7526 | if (system(buf) != 0) { | 
|  | 7527 | send_resp(dut, conn, SIGMA_ERROR, | 
|  | 7528 | "errorCode,Failed to start hostapd"); | 
|  | 7529 | return 0; | 
|  | 7530 | } | 
|  | 7531 |  | 
|  | 7532 | /* allow some time for hostapd to start before returning success */ | 
|  | 7533 | usleep(500000); | 
|  | 7534 | if (run_hostapd_cli(dut, "ping") != 0) { | 
|  | 7535 | send_resp(dut, conn, SIGMA_ERROR, | 
|  | 7536 | "errorCode,Failed to talk to hostapd"); | 
|  | 7537 | return 0; | 
|  | 7538 | } | 
|  | 7539 |  | 
| Pradeep Reddy Potteti | 923a9b3 | 2017-06-14 12:18:59 +0530 | [diff] [blame] | 7540 | if (drv == DRIVER_LINUX_WCN) { | 
|  | 7541 | sigma_dut_print(dut, DUT_MSG_INFO, "setting ip addr %s mask %s", | 
|  | 7542 | ap_inet_addr, ap_inet_mask); | 
|  | 7543 | snprintf(buf, sizeof(buf), "ifconfig %s %s netmask %s up", | 
|  | 7544 | ifname, ap_inet_addr, ap_inet_mask); | 
|  | 7545 | if (system(buf) != 0) { | 
|  | 7546 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 7547 | "Failed to initialize the interface"); | 
|  | 7548 | return -1; | 
|  | 7549 | } | 
|  | 7550 | } | 
|  | 7551 |  | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7552 | if (dut->ap_l2tif) { | 
|  | 7553 | snprintf(path, sizeof(path), | 
|  | 7554 | "/sys/class/net/%s/brport/hairpin_mode", | 
|  | 7555 | ifname); | 
|  | 7556 | if (!file_exists(path)) { | 
|  | 7557 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 7558 | "%s must be binded to the bridge for L2TIF", | 
|  | 7559 | ifname); | 
|  | 7560 | return -2; | 
|  | 7561 | } | 
|  | 7562 |  | 
|  | 7563 | snprintf(buf, sizeof(buf), "echo 1 > %s", path); | 
|  | 7564 | if (system(buf) != 0) { | 
|  | 7565 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 7566 | "Failed to enable hairpin_mode for L2TIF"); | 
|  | 7567 | return -2; | 
|  | 7568 | } | 
|  | 7569 |  | 
|  | 7570 | snprintf(buf, sizeof(buf), "ebtables -P FORWARD ACCEPT"); | 
|  | 7571 | if (system(buf) != 0) { | 
|  | 7572 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 7573 | "Failed to set ebtables rules, RULE-9"); | 
|  | 7574 | return -2; | 
|  | 7575 | } | 
|  | 7576 |  | 
|  | 7577 | snprintf(buf, sizeof(buf), | 
|  | 7578 | "ebtables -A FORWARD -p IPv4 --ip-proto icmp -i %s -j DROP", | 
|  | 7579 | ifname); | 
|  | 7580 | if (system(buf) != 0) { | 
|  | 7581 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 7582 | "Failed to set ebtables rules, RULE-11"); | 
|  | 7583 | return -2; | 
|  | 7584 | } | 
|  | 7585 | } | 
|  | 7586 |  | 
|  | 7587 | if (dut->ap_proxy_arp) { | 
|  | 7588 | if (dut->ap_dgaf_disable) { | 
|  | 7589 | if (set_ebtables_disable_dgaf(dut, "FORWARD", ifname) || | 
|  | 7590 | set_ebtables_disable_dgaf(dut, "OUTPUT", ifname)) | 
|  | 7591 | return -2; | 
|  | 7592 | } else { | 
|  | 7593 | if (set_ebtables_proxy_arp(dut, "FORWARD", ifname) || | 
|  | 7594 | set_ebtables_proxy_arp(dut, "OUTPUT", ifname)) | 
|  | 7595 | return -2; | 
|  | 7596 | } | 
|  | 7597 |  | 
|  | 7598 | /* For 4.5-(c) */ | 
|  | 7599 | snprintf(buf, sizeof(buf), | 
|  | 7600 | "ebtables -A FORWARD -p ARP --arp-opcode 2 -i %s -j DROP", | 
|  | 7601 | ifname); | 
|  | 7602 | if (system(buf) != 0) { | 
|  | 7603 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 7604 | "Failed to set ebtables rules, RULE-10"); | 
|  | 7605 | return -2; | 
|  | 7606 | } | 
|  | 7607 | } | 
|  | 7608 |  | 
|  | 7609 | if (dut->ap_tdls_prohibit || dut->ap_l2tif) { | 
|  | 7610 | /* Drop TDLS frames */ | 
|  | 7611 | snprintf(buf, sizeof(buf), | 
|  | 7612 | "ebtables -A FORWARD -p 0x890d -i %s -j DROP", ifname); | 
|  | 7613 | if (system(buf) != 0) { | 
|  | 7614 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 7615 | "Failed to set ebtables rules, RULE-13"); | 
|  | 7616 | return -2; | 
|  | 7617 | } | 
|  | 7618 | } | 
|  | 7619 |  | 
|  | 7620 | if (dut->ap_fake_pkhash && | 
|  | 7621 | run_hostapd_cli(dut, "set wps_corrupt_pkhash 1") != 0) { | 
|  | 7622 | send_resp(dut, conn, SIGMA_ERROR, | 
|  | 7623 | "errorCode,Could not enable FakePubKey"); | 
|  | 7624 | return 0; | 
|  | 7625 | } | 
|  | 7626 |  | 
| Alexei Avshalom Lazar | bc180dc | 2018-12-18 16:01:14 +0200 | [diff] [blame] | 7627 | if (dut->program == PROGRAM_60GHZ && dut->ap_num_ese_allocs > 0) { | 
|  | 7628 | /* wait extra time for AP to start */ | 
|  | 7629 | sleep(2); | 
|  | 7630 | if (ap_set_60g_ese(dut, dut->ap_num_ese_allocs, | 
|  | 7631 | dut->ap_ese_allocs)) { | 
|  | 7632 | send_resp(dut, conn, SIGMA_ERROR, | 
|  | 7633 | "errorCode,Could not set ExtSch"); | 
|  | 7634 | return 0; | 
|  | 7635 | } | 
| Alexei Avshalom Lazar | aad97b0 | 2018-12-18 16:01:23 +0200 | [diff] [blame] | 7636 | if (dut->ap_fixed_rate) { | 
|  | 7637 | sigma_dut_print(dut, DUT_MSG_DEBUG, | 
|  | 7638 | "forcing TX MCS index %d", | 
|  | 7639 | dut->ap_mcs); | 
|  | 7640 | if (ap_set_force_mcs(dut, 1, dut->ap_mcs)) { | 
|  | 7641 | send_resp(dut, conn, SIGMA_ERROR, | 
|  | 7642 | "errorCode,Could not force MCS"); | 
|  | 7643 | return -2; | 
|  | 7644 | } | 
|  | 7645 | } | 
| Alexei Avshalom Lazar | bc180dc | 2018-12-18 16:01:14 +0200 | [diff] [blame] | 7646 | } | 
|  | 7647 |  | 
| Jouni Malinen | d86e582 | 2017-08-29 03:55:32 +0300 | [diff] [blame] | 7648 | dut->hostapd_running = 1; | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7649 | return 1; | 
|  | 7650 | } | 
|  | 7651 |  | 
|  | 7652 |  | 
| Pradeep Reddy POTTETI | eff4611 | 2016-10-13 17:22:03 +0530 | [diff] [blame] | 7653 | static int parse_qos_params(struct sigma_dut *dut, struct sigma_conn *conn, | 
|  | 7654 | struct qos_params *qos, const char *cwmin, | 
|  | 7655 | const char *cwmax, const char *aifs, | 
|  | 7656 | const char *txop, const char *acm) | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7657 | { | 
| Pradeep Reddy POTTETI | eff4611 | 2016-10-13 17:22:03 +0530 | [diff] [blame] | 7658 | int val; | 
|  | 7659 |  | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7660 | if (cwmin) { | 
|  | 7661 | qos->ac = 1; | 
| Pradeep Reddy POTTETI | eff4611 | 2016-10-13 17:22:03 +0530 | [diff] [blame] | 7662 | val = atoi(cwmin); | 
|  | 7663 | if (val < 0 || val > 15) { | 
|  | 7664 | send_resp(dut, conn, SIGMA_INVALID, | 
|  | 7665 | "errorCode,Invalid cwMin"); | 
|  | 7666 | return 0; | 
|  | 7667 | } | 
|  | 7668 | qos->cwmin = val; | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7669 | } | 
|  | 7670 |  | 
|  | 7671 | if (cwmax) { | 
|  | 7672 | qos->ac = 1; | 
| Pradeep Reddy POTTETI | eff4611 | 2016-10-13 17:22:03 +0530 | [diff] [blame] | 7673 | val = atoi(cwmax); | 
|  | 7674 | if (val < 0 || val > 15) { | 
|  | 7675 | send_resp(dut, conn, SIGMA_INVALID, | 
|  | 7676 | "errorCode,Invalid cwMax"); | 
|  | 7677 | return 0; | 
|  | 7678 | } | 
|  | 7679 | qos->cwmax = val; | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7680 | } | 
|  | 7681 |  | 
|  | 7682 | if (aifs) { | 
|  | 7683 | qos->ac = 1; | 
| Pradeep Reddy POTTETI | eff4611 | 2016-10-13 17:22:03 +0530 | [diff] [blame] | 7684 | val = atoi(aifs); | 
|  | 7685 | if (val < 1 || val > 255) { | 
|  | 7686 | send_resp(dut, conn, SIGMA_INVALID, | 
|  | 7687 | "errorCode,Invalid AIFS"); | 
|  | 7688 | return 0; | 
|  | 7689 | } | 
|  | 7690 | qos->aifs = val; | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7691 | } | 
|  | 7692 |  | 
|  | 7693 | if (txop) { | 
|  | 7694 | qos->ac = 1; | 
| Pradeep Reddy POTTETI | eff4611 | 2016-10-13 17:22:03 +0530 | [diff] [blame] | 7695 | val = atoi(txop); | 
|  | 7696 | if (val < 0 || val > 0xffff) { | 
|  | 7697 | send_resp(dut, conn, SIGMA_INVALID, | 
|  | 7698 | "errorCode,Invalid txop"); | 
|  | 7699 | return 0; | 
|  | 7700 | } | 
|  | 7701 | qos->txop = val * 32; | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7702 | } | 
|  | 7703 |  | 
|  | 7704 | if (acm) { | 
|  | 7705 | qos->ac = 1; | 
|  | 7706 | qos->acm = strcasecmp(acm, "on") == 0; | 
|  | 7707 | } | 
| Pradeep Reddy POTTETI | eff4611 | 2016-10-13 17:22:03 +0530 | [diff] [blame] | 7708 |  | 
|  | 7709 | return 1; | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7710 | } | 
|  | 7711 |  | 
|  | 7712 |  | 
|  | 7713 | static int cmd_ap_set_apqos(struct sigma_dut *dut, struct sigma_conn *conn, | 
|  | 7714 | struct sigma_cmd *cmd) | 
|  | 7715 | { | 
|  | 7716 | /* TXOP: The values provided here for VHT5G only */ | 
| Pradeep Reddy POTTETI | eff4611 | 2016-10-13 17:22:03 +0530 | [diff] [blame] | 7717 | if (!parse_qos_params(dut, conn, &dut->ap_qos[AP_AC_VO], | 
|  | 7718 | get_param(cmd, "cwmin_VO"), | 
|  | 7719 | get_param(cmd, "cwmax_VO"), | 
|  | 7720 | get_param(cmd, "AIFS_VO"), | 
|  | 7721 | get_param(cmd, "TXOP_VO"), | 
|  | 7722 | get_param(cmd, "ACM_VO")) || | 
|  | 7723 | !parse_qos_params(dut, conn, &dut->ap_qos[AP_AC_VI], | 
|  | 7724 | get_param(cmd, "cwmin_VI"), | 
|  | 7725 | get_param(cmd, "cwmax_VI"), | 
|  | 7726 | get_param(cmd, "AIFS_VI"), | 
|  | 7727 | get_param(cmd, "TXOP_VI"), | 
|  | 7728 | get_param(cmd, "ACM_VI")) || | 
|  | 7729 | !parse_qos_params(dut, conn, &dut->ap_qos[AP_AC_BE], | 
|  | 7730 | get_param(cmd, "cwmin_BE"), | 
|  | 7731 | get_param(cmd, "cwmax_BE"), | 
|  | 7732 | get_param(cmd, "AIFS_BE"), | 
|  | 7733 | get_param(cmd, "TXOP_BE"), | 
|  | 7734 | get_param(cmd, "ACM_BE")) || | 
|  | 7735 | !parse_qos_params(dut, conn, &dut->ap_qos[AP_AC_BK], | 
|  | 7736 | get_param(cmd, "cwmin_BK"), | 
|  | 7737 | get_param(cmd, "cwmax_BK"), | 
|  | 7738 | get_param(cmd, "AIFS_BK"), | 
|  | 7739 | get_param(cmd, "TXOP_BK"), | 
|  | 7740 | get_param(cmd, "ACM_BK"))) | 
|  | 7741 | return 0; | 
|  | 7742 |  | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7743 | return 1; | 
|  | 7744 | } | 
|  | 7745 |  | 
|  | 7746 |  | 
|  | 7747 | static int cmd_ap_set_staqos(struct sigma_dut *dut, struct sigma_conn *conn, | 
|  | 7748 | struct sigma_cmd *cmd) | 
|  | 7749 | { | 
| Pradeep Reddy POTTETI | eff4611 | 2016-10-13 17:22:03 +0530 | [diff] [blame] | 7750 | if (!parse_qos_params(dut, conn, &dut->ap_sta_qos[AP_AC_VO], | 
|  | 7751 | get_param(cmd, "cwmin_VO"), | 
|  | 7752 | get_param(cmd, "cwmax_VO"), | 
|  | 7753 | get_param(cmd, "AIFS_VO"), | 
|  | 7754 | get_param(cmd, "TXOP_VO"), | 
|  | 7755 | get_param(cmd, "ACM_VO")) || | 
|  | 7756 | !parse_qos_params(dut, conn, &dut->ap_sta_qos[AP_AC_VI], | 
|  | 7757 | get_param(cmd, "cwmin_VI"), | 
|  | 7758 | get_param(cmd, "cwmax_VI"), | 
|  | 7759 | get_param(cmd, "AIFS_VI"), | 
|  | 7760 | get_param(cmd, "TXOP_VI"), | 
|  | 7761 | get_param(cmd, "ACM_VI")) || | 
|  | 7762 | !parse_qos_params(dut, conn, &dut->ap_sta_qos[AP_AC_BE], | 
|  | 7763 | get_param(cmd, "cwmin_BE"), | 
|  | 7764 | get_param(cmd, "cwmax_BE"), | 
|  | 7765 | get_param(cmd, "AIFS_BE"), | 
|  | 7766 | get_param(cmd, "TXOP_BE"), | 
|  | 7767 | get_param(cmd, "ACM_BE")) || | 
|  | 7768 | !parse_qos_params(dut, conn, &dut->ap_sta_qos[AP_AC_BK], | 
|  | 7769 | get_param(cmd, "cwmin_BK"), | 
|  | 7770 | get_param(cmd, "cwmax_BK"), | 
|  | 7771 | get_param(cmd, "AIFS_BK"), | 
|  | 7772 | get_param(cmd, "TXOP_BK"), | 
|  | 7773 | get_param(cmd, "ACM_BK"))) | 
|  | 7774 | return 0; | 
|  | 7775 |  | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7776 | return 1; | 
|  | 7777 | } | 
|  | 7778 |  | 
|  | 7779 |  | 
|  | 7780 | static void cmd_ath_ap_hs2_reset(struct sigma_dut *dut) | 
|  | 7781 | { | 
|  | 7782 | unsigned char bssid[6]; | 
|  | 7783 | char buf[100]; | 
|  | 7784 | run_system(dut, "cfg -a AP_SSID=\"Hotspot 2.0\""); | 
|  | 7785 | run_system(dut, "cfg -a AP_PRIMARY_CH=1"); | 
|  | 7786 | run_system(dut, "cfg -a AP_SECMODE=WPA"); | 
|  | 7787 | run_system(dut, "cfg -a AP_SECFILE=EAP"); | 
|  | 7788 | run_system(dut, "cfg -a AP_WPA=2"); | 
|  | 7789 | run_system(dut, "cfg -a AP_CYPHER=CCMP"); | 
|  | 7790 | run_system(dut, "cfg -a AP_HOTSPOT=1"); | 
|  | 7791 | run_system(dut, "cfg -a AP_HOTSPOT_ANT=2"); | 
|  | 7792 | run_system(dut, "cfg -a AP_HOTSPOT_INTERNET=0"); | 
|  | 7793 | run_system(dut, "cfg -a AP_HOTSPOT_VENUEGROUP=2"); | 
|  | 7794 | run_system(dut, "cfg -a AP_HOTSPOT_VENUETYPE=8"); | 
|  | 7795 | run_system(dut, "cfg -a AP_HOTSPOT_ROAMINGCONSORTIUM=506f9a"); | 
|  | 7796 | run_system(dut, "cfg -a AP_HOTSPOT_ROAMINGCONSORTIUM2=001bc504bd"); | 
|  | 7797 | if (!get_hwaddr("ath0", bssid)) { | 
|  | 7798 | snprintf(buf, sizeof(buf), "cfg -a AP_HOTSPOT_HESSID=" | 
|  | 7799 | "%02x:%02x:%02x:%02x:%02x:%02x", | 
|  | 7800 | bssid[0], bssid[1], bssid[2], bssid[3], | 
|  | 7801 | bssid[4], bssid[5]); | 
|  | 7802 | run_system(dut, buf); | 
|  | 7803 | snprintf(dut->ap_hessid, sizeof(dut->ap_hessid), | 
|  | 7804 | "%02x:%02x:%02x:%02x:%02x:%02x", | 
|  | 7805 | bssid[0], bssid[1], bssid[2], bssid[3], | 
|  | 7806 | bssid[4], bssid[5]); | 
|  | 7807 | } else { | 
|  | 7808 | if (!get_hwaddr("wifi0", bssid)) { | 
|  | 7809 | snprintf(buf, sizeof(buf), "cfg -a AP_HOTSPOT_HESSID=" | 
|  | 7810 | "%02x:%02x:%02x:%02x:%02x:%02x", | 
|  | 7811 | bssid[0], bssid[1], bssid[2], bssid[3], | 
|  | 7812 | bssid[4], bssid[5]); | 
|  | 7813 | run_system(dut, buf); | 
|  | 7814 | snprintf(dut->ap_hessid, sizeof(dut->ap_hessid), | 
|  | 7815 | "%02x:%02x:%02x:%02x:%02x:%02x", | 
|  | 7816 | bssid[0], bssid[1], bssid[2], bssid[3], | 
|  | 7817 | bssid[4], bssid[5]); | 
|  | 7818 | } else { | 
|  | 7819 | /* load the driver and try again */ | 
|  | 7820 | run_system(dut, "/etc/rc.d/rc.wlan up"); | 
|  | 7821 |  | 
|  | 7822 | if (!get_hwaddr("wifi0", bssid)) { | 
|  | 7823 | snprintf(buf, sizeof(buf), | 
|  | 7824 | "cfg -a AP_HOTSPOT_HESSID=" | 
|  | 7825 | "%02x:%02x:%02x:%02x:%02x:%02x", | 
|  | 7826 | bssid[0], bssid[1], bssid[2], | 
|  | 7827 | bssid[3], bssid[4], bssid[5]); | 
|  | 7828 | run_system(dut, buf); | 
|  | 7829 | snprintf(dut->ap_hessid, | 
|  | 7830 | sizeof(dut->ap_hessid), | 
|  | 7831 | "%02x:%02x:%02x:%02x:%02x:%02x", | 
|  | 7832 | bssid[0], bssid[1], bssid[2], | 
|  | 7833 | bssid[3], bssid[4], bssid[5]); | 
|  | 7834 | } | 
|  | 7835 | } | 
|  | 7836 | } | 
|  | 7837 |  | 
|  | 7838 | run_system(dut, "cfg -r AP_SSID_2"); | 
|  | 7839 | run_system(dut, "cfg -c"); | 
|  | 7840 | /* run_system(dut, "cfg -s"); */ | 
|  | 7841 | } | 
|  | 7842 |  | 
|  | 7843 |  | 
|  | 7844 | static void ath_reset_vht_defaults(struct sigma_dut *dut) | 
|  | 7845 | { | 
|  | 7846 | run_system(dut, "cfg -x"); | 
|  | 7847 | run_system(dut, "cfg -a AP_RADIO_ID=1"); | 
|  | 7848 | run_system(dut, "cfg -a AP_PRIMARY_CH_2=36"); | 
|  | 7849 | run_system(dut, "cfg -a AP_STARTMODE=standard"); | 
|  | 7850 | run_system(dut, "cfg -a AP_CHMODE_2=11ACVHT80"); | 
|  | 7851 | run_system(dut, "cfg -a TX_CHAINMASK_2=7"); | 
|  | 7852 | run_system(dut, "cfg -a RX_CHAINMASK_2=7"); | 
|  | 7853 | run_system(dut, "cfg -a ATH_countrycode=0x348"); | 
|  | 7854 | /* NOTE: For Beeliner we have to turn off MU-MIMO */ | 
|  | 7855 | if (system("rm /tmp/secath*") != 0) { | 
|  | 7856 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 7857 | "Failed to remove secath file"); | 
|  | 7858 | } | 
|  | 7859 | } | 
|  | 7860 |  | 
|  | 7861 |  | 
|  | 7862 | static int cmd_ap_reset_default(struct sigma_dut *dut, struct sigma_conn *conn, | 
|  | 7863 | struct sigma_cmd *cmd) | 
|  | 7864 | { | 
| Ankita Bajaj | 0d5825b | 2017-10-25 16:20:17 +0530 | [diff] [blame] | 7865 | const char *type, *program; | 
| Pradeep Reddy POTTETI | 83b8067 | 2016-09-02 13:01:44 +0530 | [diff] [blame] | 7866 | enum driver_type drv; | 
| Alexei Avshalom Lazar | 2712cc8 | 2018-12-23 16:29:14 +0200 | [diff] [blame] | 7867 | char buf[128]; | 
| Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 7868 | int i; | 
|  | 7869 |  | 
|  | 7870 | for (i = 0; i < MAX_WLAN_TAGS - 1; i++) { | 
|  | 7871 | /* | 
|  | 7872 | * Reset all tagged SSIDs to NULL-string and all key management | 
|  | 7873 | * to open. | 
|  | 7874 | */ | 
|  | 7875 | dut->ap_tag_ssid[i][0] = '\0'; | 
|  | 7876 | dut->ap_tag_key_mgmt[i] = AP2_OPEN; | 
|  | 7877 | } | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7878 |  | 
| Pradeep Reddy POTTETI | 83b8067 | 2016-09-02 13:01:44 +0530 | [diff] [blame] | 7879 | drv = get_driver_type(); | 
| Ankita Bajaj | 0d5825b | 2017-10-25 16:20:17 +0530 | [diff] [blame] | 7880 |  | 
|  | 7881 | program = get_param(cmd, "program"); | 
|  | 7882 | if (!program) | 
|  | 7883 | program = get_param(cmd, "prog"); | 
|  | 7884 | dut->program = sigma_program_to_enum(program); | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7885 | dut->device_type = AP_unknown; | 
|  | 7886 | type = get_param(cmd, "type"); | 
|  | 7887 | if (type && strcasecmp(type, "Testbed") == 0) | 
|  | 7888 | dut->device_type = AP_testbed; | 
|  | 7889 | if (type && strcasecmp(type, "DUT") == 0) | 
|  | 7890 | dut->device_type = AP_dut; | 
|  | 7891 |  | 
|  | 7892 | dut->ap_rts = 0; | 
|  | 7893 | dut->ap_frgmnt = 0; | 
|  | 7894 | dut->ap_bcnint = 0; | 
|  | 7895 | dut->ap_key_mgmt = AP_OPEN; | 
|  | 7896 | dut->ap_ssid[0] = '\0'; | 
|  | 7897 | dut->ap_fake_pkhash = 0; | 
|  | 7898 | memset(dut->ap_qos, 0, sizeof(dut->ap_qos)); | 
|  | 7899 | memset(dut->ap_sta_qos, 0, sizeof(dut->ap_sta_qos)); | 
| Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 7900 | dut->ap_addba_reject = VALUE_NOT_SET; | 
|  | 7901 | dut->ap_noack = VALUE_NOT_SET; | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7902 | dut->ap_is_dual = 0; | 
|  | 7903 | dut->ap_mode = AP_inval; | 
|  | 7904 | dut->ap_mode_1 = AP_inval; | 
|  | 7905 |  | 
|  | 7906 | dut->ap_allow_vht_wep = 0; | 
|  | 7907 | dut->ap_allow_vht_tkip = 0; | 
|  | 7908 | dut->ap_disable_protection = 0; | 
|  | 7909 | memset(dut->ap_countrycode, 0, sizeof(dut->ap_countrycode)); | 
| Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 7910 | dut->ap_dyn_bw_sig = VALUE_NOT_SET; | 
|  | 7911 | dut->ap_ldpc = VALUE_NOT_SET; | 
|  | 7912 | dut->ap_sig_rts = VALUE_NOT_SET; | 
|  | 7913 | dut->ap_rx_amsdu = VALUE_NOT_SET; | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7914 | dut->ap_txBF = 0; | 
| Mohammed Shafi Shajakhan | 495fdb2 | 2016-06-02 20:10:56 +0530 | [diff] [blame] | 7915 | dut->ap_mu_txBF = 0; | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7916 | dut->ap_chwidth = AP_AUTO; | 
|  | 7917 |  | 
| Sarvepalli, Rajesh Babu | 24dc7e4 | 2016-03-18 21:27:26 +0530 | [diff] [blame] | 7918 | dut->ap_rsn_preauth = 0; | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7919 | dut->ap_wpsnfc = 0; | 
|  | 7920 | dut->ap_bss_load = -1; | 
|  | 7921 | dut->ap_p2p_cross_connect = -1; | 
|  | 7922 |  | 
| Pradeep Reddy POTTETI | fba27db | 2015-11-20 16:42:22 +0530 | [diff] [blame] | 7923 | dut->ap_regulatory_mode = AP_80211D_MODE_DISABLED; | 
|  | 7924 | dut->ap_dfs_mode = AP_DFS_MODE_DISABLED; | 
| Pradeep Reddy Potteti | 4b0cdee | 2017-03-15 12:37:33 +0530 | [diff] [blame] | 7925 | dut->ap_chwidth_offset = SEC_CH_NO; | 
| Pradeep Reddy POTTETI | fba27db | 2015-11-20 16:42:22 +0530 | [diff] [blame] | 7926 |  | 
| Adil Saeed Musthafa | 6906372 | 2017-04-10 23:13:40 -0700 | [diff] [blame] | 7927 | dut->mbo_pref_ap_cnt = 0; | 
| Adil Saeed Musthafa | 4ec61bd | 2017-04-10 23:13:41 -0700 | [diff] [blame] | 7928 | dut->ft_bss_mac_cnt = 0; | 
| priyadharshini gowthaman | 09d613e | 2017-12-20 11:43:44 -0800 | [diff] [blame] | 7929 | dut->ap_interface_5g = 0; | 
|  | 7930 | dut->ap_interface_2g = 0; | 
| priyadharshini gowthaman | a3fe8c6 | 2018-01-26 15:19:41 -0800 | [diff] [blame] | 7931 | dut->ap_pmf = AP_PMF_DISABLED; | 
| Adil Saeed Musthafa | 6906372 | 2017-04-10 23:13:40 -0700 | [diff] [blame] | 7932 |  | 
| Alexei Avshalom Lazar | 33f700c | 2018-12-18 16:00:39 +0200 | [diff] [blame] | 7933 | dut->wsc_fragment = 0; | 
|  | 7934 |  | 
| Mohammed Shafi Shajakhan | 02e3b82 | 2017-02-23 04:15:02 +0530 | [diff] [blame] | 7935 | if (dut->program == PROGRAM_HT || dut->program == PROGRAM_VHT) { | 
| Pradeep Reddy POTTETI | 0d3db63 | 2016-03-11 15:21:11 +0530 | [diff] [blame] | 7936 | dut->ap_wme = AP_WME_ON; | 
| Mohammed Shafi Shajakhan | 02e3b82 | 2017-02-23 04:15:02 +0530 | [diff] [blame] | 7937 | dut->ap_wmmps = AP_WMMPS_ON; | 
|  | 7938 | } else { | 
| Pradeep Reddy POTTETI | 0d3db63 | 2016-03-11 15:21:11 +0530 | [diff] [blame] | 7939 | dut->ap_wme = AP_WME_OFF; | 
| Mohammed Shafi Shajakhan | 02e3b82 | 2017-02-23 04:15:02 +0530 | [diff] [blame] | 7940 | dut->ap_wmmps = AP_WMMPS_OFF; | 
|  | 7941 | } | 
| Pradeep Reddy POTTETI | 0d3db63 | 2016-03-11 15:21:11 +0530 | [diff] [blame] | 7942 |  | 
| Jouni Malinen | 54a89b0 | 2018-05-01 00:16:26 +0300 | [diff] [blame] | 7943 | dut->ap_venue_url = 0; | 
| Jouni Malinen | f7ff42b | 2018-05-01 00:21:56 +0300 | [diff] [blame] | 7944 | dut->ap_advice_of_charge = 0; | 
| Jouni Malinen | ac10453 | 2018-05-01 00:27:37 +0300 | [diff] [blame] | 7945 | dut->ap_oper_icon_metadata = 0; | 
| Jouni Malinen | ac36714 | 2018-05-01 00:32:24 +0300 | [diff] [blame] | 7946 | dut->ap_tnc_file_name = 0; | 
|  | 7947 | dut->ap_tnc_time_stamp = 0; | 
| Jouni Malinen | 54a89b0 | 2018-05-01 00:16:26 +0300 | [diff] [blame] | 7948 |  | 
| Adil Saeed Musthafa | 33ea287 | 2017-04-10 23:13:24 -0700 | [diff] [blame] | 7949 | if (dut->program == PROGRAM_HS2 || dut->program == PROGRAM_HS2_R2 || | 
| Jouni Malinen | ba63045 | 2018-06-22 11:49:59 +0300 | [diff] [blame] | 7950 | dut->program == PROGRAM_HS2_R3 || | 
| Adil Saeed Musthafa | 33ea287 | 2017-04-10 23:13:24 -0700 | [diff] [blame] | 7951 | dut->program == PROGRAM_IOTLP) { | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7952 | int i; | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7953 |  | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 7954 | if (drv == DRIVER_ATHEROS) | 
|  | 7955 | cmd_ath_ap_hs2_reset(dut); | 
|  | 7956 | else if (drv == DRIVER_OPENWRT) | 
|  | 7957 | cmd_owrt_ap_hs2_reset(dut); | 
|  | 7958 |  | 
|  | 7959 | dut->ap_interworking = 1; | 
|  | 7960 | dut->ap_access_net_type = 2; | 
|  | 7961 | dut->ap_internet = 0; | 
|  | 7962 | dut->ap_venue_group = 2; | 
|  | 7963 | dut->ap_venue_type = 8; | 
|  | 7964 | dut->ap_domain_name_list[0] = '\0'; | 
|  | 7965 | dut->ap_hs2 = 1; | 
|  | 7966 | snprintf(dut->ap_roaming_cons, sizeof(dut->ap_roaming_cons), | 
|  | 7967 | "506f9a;001bc504bd"); | 
|  | 7968 | dut->ap_l2tif = 0; | 
|  | 7969 | dut->ap_proxy_arp = 0; | 
|  | 7970 | if (dut->bridge) { | 
|  | 7971 | char buf[50]; | 
|  | 7972 |  | 
|  | 7973 | snprintf(buf, sizeof(buf), "ip neigh flush dev %s", | 
|  | 7974 | dut->bridge); | 
|  | 7975 | if (system(buf) != 0) { | 
|  | 7976 | sigma_dut_print(dut, DUT_MSG_DEBUG, | 
|  | 7977 | "%s ip neigh table flushing failed", | 
|  | 7978 | dut->bridge); | 
|  | 7979 | } | 
|  | 7980 |  | 
|  | 7981 | snprintf(buf, sizeof(buf), "ebtables -F"); | 
|  | 7982 | if (system(buf) != 0) { | 
|  | 7983 | sigma_dut_print(dut, DUT_MSG_DEBUG, | 
|  | 7984 | "%s ebtables flushing failed", | 
|  | 7985 | dut->bridge); | 
|  | 7986 | } | 
|  | 7987 | } | 
|  | 7988 | dut->ap_dgaf_disable = 0; | 
|  | 7989 | dut->ap_p2p_cross_connect = 0; | 
|  | 7990 | dut->ap_gas_cb_delay = 0; | 
|  | 7991 | dut->ap_nai_realm_list = 0; | 
|  | 7992 | dut->ap_oper_name = 0; | 
|  | 7993 | dut->ap_venue_name = 0; | 
|  | 7994 | for (i = 0; i < 10; i++) { | 
|  | 7995 | dut->ap_plmn_mcc[i][0] = '\0'; | 
|  | 7996 | dut->ap_plmn_mnc[i][0] = '\0'; | 
|  | 7997 | } | 
|  | 7998 | dut->ap_wan_metrics = 0; | 
|  | 7999 | dut->ap_conn_capab = 0; | 
|  | 8000 | dut->ap_ip_addr_type_avail = 0; | 
|  | 8001 | dut->ap_net_auth_type = 0; | 
|  | 8002 | dut->ap_oper_class = 0; | 
|  | 8003 | dut->ap_pmf = 0; | 
|  | 8004 | dut->ap_add_sha256 = 0; | 
|  | 8005 | } | 
|  | 8006 |  | 
| Jouni Malinen | ba63045 | 2018-06-22 11:49:59 +0300 | [diff] [blame] | 8007 | if (dut->program == PROGRAM_HS2_R2 || dut->program == PROGRAM_HS2_R3 || | 
|  | 8008 | dut->program == PROGRAM_IOTLP) { | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8009 | int i; | 
|  | 8010 | const char hessid[] = "50:6f:9a:00:11:22"; | 
|  | 8011 |  | 
|  | 8012 | memcpy(dut->ap_hessid, hessid, strlen(hessid) + 1); | 
|  | 8013 | dut->ap_osu_ssid[0] = '\0'; | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8014 | dut->ap_pmf = 1; | 
|  | 8015 | dut->ap_osu_provider_list = 0; | 
| Jouni Malinen | 93a837f | 2018-11-01 17:09:22 +0200 | [diff] [blame] | 8016 | dut->ap_osu_provider_nai_list = 0; | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8017 | for (i = 0; i < 10; i++) { | 
|  | 8018 | dut->ap_osu_server_uri[i][0] = '\0'; | 
|  | 8019 | dut->ap_osu_method[i] = 0xFF; | 
|  | 8020 | } | 
|  | 8021 | dut->ap_qos_map_set = 0; | 
| Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 8022 | dut->ap_tag_key_mgmt[0] = AP2_OPEN; | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8023 | dut->ap2_proxy_arp = 0; | 
| Jouni Malinen | dbbc2c4 | 2018-11-14 23:55:41 +0200 | [diff] [blame] | 8024 | dut->ap2_osu = 0; | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8025 | dut->ap_osu_icon_tag = 0; | 
|  | 8026 | } | 
|  | 8027 |  | 
|  | 8028 | if (dut->program == PROGRAM_VHT) { | 
|  | 8029 | /* Set up the defaults */ | 
|  | 8030 | dut->ap_mode = AP_11ac; | 
|  | 8031 | dut->ap_channel = 36; | 
| Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 8032 | dut->ap_ampdu = VALUE_NOT_SET; | 
| priyadharshini gowthaman | 264d544 | 2016-02-25 15:52:22 -0800 | [diff] [blame] | 8033 | dut->ap_ndpa_frame = 1; | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8034 | if (dut->device_type == AP_testbed) { | 
| Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 8035 | dut->ap_amsdu = VALUE_DISABLED; | 
|  | 8036 | dut->ap_ldpc = VALUE_DISABLED; | 
|  | 8037 | dut->ap_rx_amsdu = VALUE_DISABLED; | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8038 | dut->ap_sgi80 = 0; | 
|  | 8039 | } else { | 
| Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 8040 | dut->ap_amsdu = VALUE_ENABLED; | 
| Pradeep Reddy POTTETI | 83b8067 | 2016-09-02 13:01:44 +0530 | [diff] [blame] | 8041 | /* | 
|  | 8042 | * As LDPC is optional, don't enable this by default | 
|  | 8043 | * for LINUX-WCN driver. The ap_set_wireless command | 
|  | 8044 | * can be used to enable LDPC, when needed. | 
|  | 8045 | */ | 
|  | 8046 | if (drv != DRIVER_LINUX_WCN) | 
| Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 8047 | dut->ap_ldpc = VALUE_ENABLED; | 
|  | 8048 | dut->ap_rx_amsdu = VALUE_ENABLED; | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8049 | dut->ap_sgi80 = 1; | 
|  | 8050 | } | 
|  | 8051 | dut->ap_fixed_rate = 0; | 
|  | 8052 | dut->ap_rx_streams = 3; | 
|  | 8053 | dut->ap_tx_streams = 3; | 
|  | 8054 | dut->ap_vhtmcs_map = 0; | 
|  | 8055 | dut->ap_chwidth = AP_80; | 
|  | 8056 | dut->ap_tx_stbc = 1; | 
| Jouni Malinen | 57fa3d8 | 2016-11-30 12:51:43 +0200 | [diff] [blame] | 8057 | dut->ap_dyn_bw_sig = VALUE_ENABLED; | 
| Mohammed Shafi Shajakhan | bae7230 | 2016-03-02 11:56:23 +0530 | [diff] [blame] | 8058 | if (get_openwrt_driver_type() == OPENWRT_DRIVER_ATHEROS) | 
|  | 8059 | dut->ap_dfs_mode = AP_DFS_MODE_ENABLED; | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8060 | if (get_driver_type() == DRIVER_ATHEROS) | 
|  | 8061 | ath_reset_vht_defaults(dut); | 
|  | 8062 | } | 
|  | 8063 |  | 
| Adil Saeed Musthafa | 33ea287 | 2017-04-10 23:13:24 -0700 | [diff] [blame] | 8064 | if (dut->program == PROGRAM_IOTLP) { | 
|  | 8065 | dut->wnm_bss_max_feature = VALUE_DISABLED; | 
|  | 8066 | dut->wnm_bss_max_idle_time = 0; | 
|  | 8067 | dut->wnm_bss_max_protection = VALUE_NOT_SET; | 
|  | 8068 | dut->ap_proxy_arp = 1; | 
|  | 8069 | } else { | 
|  | 8070 | /* | 
|  | 8071 | * Do not touch the BSS-MAX Idle time feature | 
|  | 8072 | * if the program is not IOTLP. | 
|  | 8073 | */ | 
|  | 8074 | dut->wnm_bss_max_feature = VALUE_NOT_SET; | 
|  | 8075 | dut->wnm_bss_max_idle_time = 0; | 
|  | 8076 | dut->wnm_bss_max_protection = VALUE_NOT_SET; | 
|  | 8077 | } | 
|  | 8078 |  | 
| priyadharshini gowthaman | a27b5b6 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 8079 | if (dut->program == PROGRAM_LOC) { | 
| priyadharshini gowthaman | 8e26ff4 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 8080 | dut->ap_rrm = 1; | 
|  | 8081 | dut->ap_rtt = 1; | 
|  | 8082 | dut->ap_lci = 0; | 
|  | 8083 | dut->ap_val_lci[0] = '\0'; | 
| priyadharshini gowthaman | c2357bd | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 8084 | dut->ap_infoz[0] = '\0'; | 
| priyadharshini gowthaman | 8e26ff4 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 8085 | dut->ap_lcr = 0; | 
|  | 8086 | dut->ap_val_lcr[0] = '\0'; | 
|  | 8087 | dut->ap_neighap = 0; | 
|  | 8088 | dut->ap_opchannel = 0; | 
|  | 8089 | dut->ap_scan = 0; | 
| priyadharshini gowthaman | c2357bd | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 8090 | dut->ap_fqdn_held = 0; | 
|  | 8091 | dut->ap_fqdn_supl = 0; | 
| priyadharshini gowthaman | c52fff8 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 8092 | dut->ap_interworking = 0; | 
|  | 8093 | dut->ap_gas_cb_delay = 0; | 
| priyadharshini gowthaman | a27b5b6 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 8094 | dut->ap_msnt_type = 0; | 
|  | 8095 | } | 
| Adil Saeed Musthafa | 4ec61bd | 2017-04-10 23:13:41 -0700 | [diff] [blame] | 8096 | dut->ap_ft_oa = 0; | 
| Adil Saeed Musthafa | 604c826 | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 8097 | dut->ap_reg_domain = REG_DOMAIN_NOT_SET; | 
| Adil Saeed Musthafa | cf752fa | 2017-04-10 23:13:32 -0700 | [diff] [blame] | 8098 | dut->ap_mobility_domain[0] = '\0'; | 
| priyadharshini gowthaman | a27b5b6 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 8099 |  | 
| priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 8100 | if (dut->program == PROGRAM_MBO) { | 
|  | 8101 | dut->ap_mbo = 1; | 
|  | 8102 | dut->ap_interworking = 1; | 
|  | 8103 | dut->ap_ne_class = 0; | 
|  | 8104 | dut->ap_ne_op_ch = 0; | 
|  | 8105 | dut->ap_set_bssidpref = 1; | 
| Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 8106 | dut->ap_btmreq_disassoc_imnt = 0; | 
|  | 8107 | dut->ap_btmreq_term_bit = 0; | 
|  | 8108 | dut->ap_disassoc_timer = 0; | 
|  | 8109 | dut->ap_btmreq_bss_term_dur = 0; | 
| Adil Saeed Musthafa | 16d9e63 | 2017-04-10 23:13:38 -0700 | [diff] [blame] | 8110 | dut->ap_channel = 36; | 
|  | 8111 | dut->ap_chwidth = AP_20; | 
| Adil Saeed Musthafa | 023108a | 2017-04-10 23:13:37 -0700 | [diff] [blame] | 8112 | dut->ap_cell_cap_pref = 0; | 
| Adil Saeed Musthafa | ed5faae | 2017-04-10 23:13:36 -0700 | [diff] [blame] | 8113 | dut->ap_gas_cb_delay = 0; | 
| Adil Saeed Musthafa | 6906372 | 2017-04-10 23:13:40 -0700 | [diff] [blame] | 8114 | dut->mbo_self_ap_tuple.ap_ne_class = -1; | 
|  | 8115 | dut->mbo_self_ap_tuple.ap_ne_pref = -1; /* Not set */ | 
|  | 8116 | dut->mbo_self_ap_tuple.ap_ne_op_ch = -1; | 
| priyadharshini gowthaman | 94062b5 | 2017-12-20 12:33:34 -0800 | [diff] [blame] | 8117 | dut->ap_btmreq_bss_term_tsf = 0; | 
| priyadharshini gowthaman | 776562e | 2017-12-20 12:33:34 -0800 | [diff] [blame] | 8118 | dut->ap_assoc_delay = 0; | 
| priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 8119 | } | 
|  | 8120 |  | 
| priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 8121 | if (dut->program == PROGRAM_OCE) { | 
|  | 8122 | if (dut->ap_dhcp_stop) | 
|  | 8123 | run_system(dut, "/etc/init.d/dnsmasq start"); | 
|  | 8124 |  | 
|  | 8125 | dut->ap_dhcp_stop = 0; | 
|  | 8126 | dut->ap_oce = VALUE_ENABLED; | 
|  | 8127 | dut->ap_broadcast_ssid = VALUE_ENABLED; | 
|  | 8128 | dut->ap_fils_dscv_int = 20; | 
|  | 8129 | dut->ap_filsdscv = VALUE_ENABLED; | 
|  | 8130 | dut->ap_filshlp = VALUE_DISABLED; | 
|  | 8131 | dut->ap_rnr = VALUE_DISABLED; | 
|  | 8132 | dut->ap_nairealm[0] = '\0'; | 
|  | 8133 | dut->ap_nairealm_int = 0; | 
|  | 8134 | dut->ap_blechanutil = 0; | 
|  | 8135 | dut->ap_ble_admit_cap = 0; | 
|  | 8136 | dut->ap_esp = VALUE_ENABLED; | 
|  | 8137 | dut->ap_datappdudura = 0; | 
|  | 8138 | dut->ap_airtimefract = 0; | 
|  | 8139 | dut->ap_blestacnt = 0; | 
| priyadharshini gowthaman | cb22e43 | 2017-12-28 15:23:31 -0800 | [diff] [blame] | 8140 | dut->ap_ul_availcap = 0; | 
|  | 8141 | dut->ap_dl_availcap = 0; | 
| priyadharshini gowthaman | de81f39 | 2017-12-28 15:28:49 -0800 | [diff] [blame] | 8142 | dut->ap_akm = 0; | 
|  | 8143 | dut->ap_add_sha256 = 0; | 
|  | 8144 | dut->ap_add_sha384 = 0; | 
|  | 8145 | dut->ap_pmksa = 0; | 
|  | 8146 | dut->ap_pmksa_caching = 0; | 
| priyadharshini gowthaman | 63ab848 | 2017-12-28 15:32:55 -0800 | [diff] [blame] | 8147 | dut->ap_80plus80 = 0; | 
| priyadharshini gowthaman | 00798a2 | 2017-12-28 15:15:00 -0800 | [diff] [blame] | 8148 | } | 
|  | 8149 |  | 
| priyadharshini gowthaman | 350f191 | 2018-06-04 13:09:12 -0700 | [diff] [blame] | 8150 | dut->ap_he_ppdu = PPDU_NOT_SET; | 
|  | 8151 |  | 
| priyadharshini gowthaman | 9149afc | 2018-01-15 13:40:18 -0800 | [diff] [blame] | 8152 | dut->ap_oper_chn = 0; | 
|  | 8153 |  | 
| Jouni Malinen | 3c367e8 | 2017-06-23 17:01:47 +0300 | [diff] [blame] | 8154 | free(dut->rsne_override); | 
|  | 8155 | dut->rsne_override = NULL; | 
|  | 8156 |  | 
| Jouni Malinen | 6814313 | 2017-09-02 02:34:08 +0300 | [diff] [blame] | 8157 | free(dut->sae_commit_override); | 
|  | 8158 | dut->sae_commit_override = NULL; | 
|  | 8159 |  | 
| Jouni Malinen | ed670f4 | 2017-08-31 01:39:28 +0300 | [diff] [blame] | 8160 | free(dut->ap_sae_groups); | 
|  | 8161 | dut->ap_sae_groups = NULL; | 
| Jouni Malinen | 30824df | 2017-08-22 21:21:38 +0300 | [diff] [blame] | 8162 |  | 
| Jouni Malinen | 2f524ce | 2017-08-31 01:43:29 +0300 | [diff] [blame] | 8163 | dut->sae_anti_clogging_threshold = -1; | 
| Jouni Malinen | b347db0 | 2017-09-02 01:36:03 +0300 | [diff] [blame] | 8164 | dut->sae_reflection = 0; | 
| Jouni Malinen | 2f524ce | 2017-08-31 01:43:29 +0300 | [diff] [blame] | 8165 |  | 
| Jouni Malinen | 3d633da | 2017-09-14 22:19:21 +0300 | [diff] [blame] | 8166 | dut->ap_cipher = AP_CCMP; | 
| Jouni Malinen | 2ba2449 | 2017-11-17 12:43:59 +0200 | [diff] [blame] | 8167 | dut->ap_group_cipher = AP_NO_GROUP_CIPHER_SET; | 
| Jouni Malinen | 3d633da | 2017-09-14 22:19:21 +0300 | [diff] [blame] | 8168 | dut->ap_group_mgmt_cipher = AP_NO_GROUP_MGMT_CIPHER_SET; | 
| Jouni Malinen | 6337062 | 2017-11-18 17:47:13 +0200 | [diff] [blame] | 8169 | dut->ap_passphrase[0] = '\0'; | 
|  | 8170 | dut->ap_psk[0] = '\0'; | 
| Jouni Malinen | 3d633da | 2017-09-14 22:19:21 +0300 | [diff] [blame] | 8171 |  | 
| Jouni Malinen | d86e582 | 2017-08-29 03:55:32 +0300 | [diff] [blame] | 8172 | dut->dpp_conf_id = -1; | 
|  | 8173 |  | 
| Alexei Avshalom Lazar | eee9ab0 | 2018-12-24 16:27:48 +0200 | [diff] [blame] | 8174 | if (is_60g_sigma_dut(dut)) { | 
| Alexei Avshalom Lazar | 2712cc8 | 2018-12-23 16:29:14 +0200 | [diff] [blame] | 8175 | dut->ap_mode = AP_11ad; | 
|  | 8176 | dut->ap_channel = 2; | 
| Alexei Avshalom Lazar | eee9ab0 | 2018-12-24 16:27:48 +0200 | [diff] [blame] | 8177 | dut->wps_disable = 0; /* WPS is enabled */ | 
| Alexei Avshalom Lazar | 2712cc8 | 2018-12-23 16:29:14 +0200 | [diff] [blame] | 8178 | dut->ap_pmf = 0; | 
| Alexei Avshalom Lazar | bc180dc | 2018-12-18 16:01:14 +0200 | [diff] [blame] | 8179 | dut->ap_num_ese_allocs = 0; | 
| Alexei Avshalom Lazar | 2712cc8 | 2018-12-23 16:29:14 +0200 | [diff] [blame] | 8180 | dut->ap_fixed_rate = 0; | 
|  | 8181 |  | 
|  | 8182 | dut->dev_role = DEVROLE_AP; | 
|  | 8183 |  | 
|  | 8184 | sigma_dut_print(dut, DUT_MSG_DEBUG, | 
|  | 8185 | "Setting msdu_size to MAX: 7912"); | 
|  | 8186 | snprintf(buf, sizeof(buf), "ifconfig %s mtu 7912", | 
|  | 8187 | get_main_ifname()); | 
|  | 8188 |  | 
|  | 8189 | if (system(buf) != 0) { | 
|  | 8190 | sigma_dut_print(dut, DUT_MSG_ERROR, "Failed to set %s", | 
|  | 8191 | buf); | 
| Jouni Malinen | 0e29cf2 | 2019-02-19 01:13:21 +0200 | [diff] [blame] | 8192 | return ERROR_SEND_STATUS; | 
| Alexei Avshalom Lazar | 2712cc8 | 2018-12-23 16:29:14 +0200 | [diff] [blame] | 8193 | } | 
|  | 8194 |  | 
| Alexei Avshalom Lazar | aad97b0 | 2018-12-18 16:01:23 +0200 | [diff] [blame] | 8195 | if (ap_set_force_mcs(dut, 0, 1)) { | 
|  | 8196 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 8197 | "Failed to reset force MCS"); | 
| Jouni Malinen | 0e29cf2 | 2019-02-19 01:13:21 +0200 | [diff] [blame] | 8198 | return ERROR_SEND_STATUS; | 
| Alexei Avshalom Lazar | aad97b0 | 2018-12-18 16:01:23 +0200 | [diff] [blame] | 8199 | } | 
|  | 8200 |  | 
| Alexei Avshalom Lazar | 2712cc8 | 2018-12-23 16:29:14 +0200 | [diff] [blame] | 8201 | if (set_ps(get_main_ifname(), dut, 1)) { | 
|  | 8202 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 8203 | "Failed to enable power save"); | 
| Jouni Malinen | 0e29cf2 | 2019-02-19 01:13:21 +0200 | [diff] [blame] | 8204 | return ERROR_SEND_STATUS; | 
| Alexei Avshalom Lazar | 2712cc8 | 2018-12-23 16:29:14 +0200 | [diff] [blame] | 8205 | } | 
|  | 8206 | } | 
|  | 8207 |  | 
| Jouni Malinen | d86e582 | 2017-08-29 03:55:32 +0300 | [diff] [blame] | 8208 | dut->hostapd_running = 0; | 
| priyadharshini gowthaman | 9947fd3 | 2018-01-26 15:19:41 -0800 | [diff] [blame] | 8209 |  | 
|  | 8210 | if (get_openwrt_driver_type() == OPENWRT_DRIVER_ATHEROS) | 
|  | 8211 | return 1; | 
|  | 8212 |  | 
| Jouni Malinen | d6bf1b4 | 2017-06-23 17:51:01 +0300 | [diff] [blame] | 8213 | if (dut->use_hostapd_pid_file) { | 
|  | 8214 | kill_hostapd_process_pid(dut); | 
|  | 8215 | } else if (kill_process(dut, "(hostapd)", 1, SIGTERM) == 0 || | 
|  | 8216 | system("killall hostapd") == 0) { | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8217 | int i; | 
|  | 8218 | /* Wait some time to allow hostapd to complete cleanup before | 
|  | 8219 | * starting a new process */ | 
|  | 8220 | for (i = 0; i < 10; i++) { | 
|  | 8221 | usleep(500000); | 
|  | 8222 | if (system("pidof hostapd") != 0) | 
|  | 8223 | break; | 
|  | 8224 | } | 
|  | 8225 | } | 
|  | 8226 |  | 
|  | 8227 | if (if_nametoindex("sigmadut") > 0 && | 
|  | 8228 | system("iw dev sigmadut del") != 0) | 
|  | 8229 | sigma_dut_print(dut, DUT_MSG_ERROR, "Failed to remove " | 
|  | 8230 | "monitor interface"); | 
|  | 8231 |  | 
|  | 8232 | return 1; | 
|  | 8233 | } | 
|  | 8234 |  | 
|  | 8235 |  | 
| Ankita Bajaj | 0d5825b | 2017-10-25 16:20:17 +0530 | [diff] [blame] | 8236 | int sta_cfon_reset_default(struct sigma_dut *dut, struct sigma_conn *conn, | 
|  | 8237 | struct sigma_cmd *cmd) | 
|  | 8238 | { | 
|  | 8239 | return cmd_ap_reset_default(dut, conn, cmd); | 
|  | 8240 | } | 
|  | 8241 |  | 
|  | 8242 |  | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8243 | static int cmd_ap_get_info(struct sigma_dut *dut, struct sigma_conn *conn, | 
|  | 8244 | struct sigma_cmd *cmd) | 
|  | 8245 | { | 
|  | 8246 | /* const char *name = get_param(cmd, "NAME"); */ | 
|  | 8247 | struct stat s; | 
|  | 8248 | char resp[200]; | 
|  | 8249 | FILE *f; | 
|  | 8250 | enum driver_type drv = get_driver_type(); | 
|  | 8251 |  | 
|  | 8252 | switch (drv) { | 
|  | 8253 | case DRIVER_ATHEROS: { | 
|  | 8254 | /* Atheros AP */ | 
|  | 8255 | struct utsname uts; | 
|  | 8256 | char *version, athver[100]; | 
|  | 8257 |  | 
|  | 8258 | if (stat("/proc/athversion", &s) != 0) { | 
|  | 8259 | if (system("/etc/rc.d/rc.wlan up") != 0) { | 
|  | 8260 | } | 
|  | 8261 | } | 
|  | 8262 |  | 
|  | 8263 | athver[0] = '\0'; | 
|  | 8264 | f = fopen("/proc/athversion", "r"); | 
|  | 8265 | if (f) { | 
|  | 8266 | if (fgets(athver, sizeof(athver), f)) { | 
|  | 8267 | char *pos = strchr(athver, '\n'); | 
|  | 8268 | if (pos) | 
|  | 8269 | *pos = '\0'; | 
|  | 8270 | } | 
|  | 8271 | fclose(f); | 
|  | 8272 | } | 
|  | 8273 |  | 
|  | 8274 | if (uname(&uts) == 0) | 
|  | 8275 | version = uts.release; | 
|  | 8276 | else | 
|  | 8277 | version = "Unknown"; | 
|  | 8278 |  | 
|  | 8279 | if (if_nametoindex("ath1") > 0) | 
|  | 8280 | snprintf(resp, sizeof(resp), "interface,ath0_24G " | 
|  | 8281 | "ath1_5G,agent,1.0,version,%s/drv:%s", | 
|  | 8282 | version, athver); | 
|  | 8283 | else | 
|  | 8284 | snprintf(resp, sizeof(resp), "interface,ath0_24G," | 
|  | 8285 | "agent,1.0,version,%s/drv:%s", | 
|  | 8286 | version, athver); | 
|  | 8287 |  | 
|  | 8288 | send_resp(dut, conn, SIGMA_COMPLETE, resp); | 
|  | 8289 | return 0; | 
|  | 8290 | } | 
| Sreelakshmi Konamki | b692f10 | 2016-04-26 19:47:00 +0530 | [diff] [blame] | 8291 | case DRIVER_LINUX_WCN: | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8292 | case DRIVER_MAC80211: { | 
|  | 8293 | struct utsname uts; | 
|  | 8294 | char *version; | 
|  | 8295 |  | 
|  | 8296 | if (uname(&uts) == 0) | 
|  | 8297 | version = uts.release; | 
|  | 8298 | else | 
|  | 8299 | version = "Unknown"; | 
|  | 8300 |  | 
|  | 8301 | if (if_nametoindex("wlan1") > 0) | 
|  | 8302 | snprintf(resp, sizeof(resp), "interface,wlan0_24G " | 
|  | 8303 | "wlan1_5G,agent,1.0,version,%s", version); | 
|  | 8304 | else | 
|  | 8305 | snprintf(resp, sizeof(resp), "interface,wlan0_any," | 
|  | 8306 | "agent,1.0,version,%s", version); | 
|  | 8307 |  | 
|  | 8308 | send_resp(dut, conn, SIGMA_COMPLETE, resp); | 
|  | 8309 | return 0; | 
|  | 8310 | } | 
|  | 8311 | case DRIVER_QNXNTO: { | 
|  | 8312 | struct utsname uts; | 
|  | 8313 | char *version; | 
|  | 8314 |  | 
|  | 8315 | if (uname(&uts) == 0) | 
|  | 8316 | version = uts.release; | 
|  | 8317 | else | 
|  | 8318 | version = "Unknown"; | 
|  | 8319 | snprintf(resp, sizeof(resp), | 
|  | 8320 | "interface,%s_any,agent,1.0,version,%s", | 
|  | 8321 | sigma_main_ifname ? sigma_main_ifname : "NA", | 
|  | 8322 | version); | 
|  | 8323 | send_resp(dut, conn, SIGMA_COMPLETE, resp); | 
|  | 8324 | return 0; | 
|  | 8325 | } | 
|  | 8326 | case DRIVER_OPENWRT: { | 
|  | 8327 | switch (get_openwrt_driver_type()) { | 
|  | 8328 | case OPENWRT_DRIVER_ATHEROS: { | 
|  | 8329 | struct utsname uts; | 
|  | 8330 | char *version; | 
|  | 8331 |  | 
|  | 8332 | if (uname(&uts) == 0) | 
|  | 8333 | version = uts.release; | 
|  | 8334 | else | 
|  | 8335 | version = "Unknown"; | 
|  | 8336 |  | 
|  | 8337 | if (if_nametoindex("ath1") > 0) | 
|  | 8338 | snprintf(resp, sizeof(resp), | 
|  | 8339 | "interface,ath0_5G ath1_24G,agent,1.0,version,%s", | 
|  | 8340 | version); | 
|  | 8341 | else | 
|  | 8342 | snprintf(resp, sizeof(resp), | 
|  | 8343 | "interface,ath0_any,agent,1.0,version,%s", | 
|  | 8344 | version); | 
|  | 8345 |  | 
|  | 8346 | send_resp(dut, conn, SIGMA_COMPLETE, resp); | 
|  | 8347 | return 0; | 
|  | 8348 | } | 
|  | 8349 | default: | 
|  | 8350 | send_resp(dut, conn, SIGMA_ERROR, | 
|  | 8351 | "errorCode,Unsupported openwrt driver"); | 
|  | 8352 | return 0; | 
|  | 8353 | } | 
|  | 8354 | } | 
|  | 8355 | default: | 
|  | 8356 | send_resp(dut, conn, SIGMA_ERROR, | 
|  | 8357 | "errorCode,Unsupported driver"); | 
|  | 8358 | return 0; | 
|  | 8359 | } | 
|  | 8360 | } | 
|  | 8361 |  | 
|  | 8362 |  | 
|  | 8363 | static int cmd_ap_deauth_sta(struct sigma_dut *dut, struct sigma_conn *conn, | 
|  | 8364 | struct sigma_cmd *cmd) | 
|  | 8365 | { | 
|  | 8366 | /* const char *name = get_param(cmd, "NAME"); */ | 
|  | 8367 | /* const char *ifname = get_param(cmd, "INTERFACE"); */ | 
|  | 8368 | const char *val; | 
|  | 8369 | char buf[100]; | 
|  | 8370 |  | 
|  | 8371 | val = get_param(cmd, "MinorCode"); | 
|  | 8372 | if (val) { | 
|  | 8373 | /* TODO: add support for P2P minor code */ | 
|  | 8374 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,MinorCode not " | 
|  | 8375 | "yet supported"); | 
|  | 8376 | return 0; | 
|  | 8377 | } | 
|  | 8378 |  | 
|  | 8379 | val = get_param(cmd, "STA_MAC_ADDRESS"); | 
|  | 8380 | if (val == NULL) | 
|  | 8381 | return -1; | 
|  | 8382 | snprintf(buf, sizeof(buf), "deauth %s", val); | 
|  | 8383 | if (run_hostapd_cli(dut, buf) != 0) | 
|  | 8384 | return -2; | 
|  | 8385 |  | 
|  | 8386 | return 1; | 
|  | 8387 | } | 
|  | 8388 |  | 
|  | 8389 |  | 
|  | 8390 | #ifdef __linux__ | 
|  | 8391 | int inject_frame(int s, const void *data, size_t len, int encrypt); | 
|  | 8392 | int open_monitor(const char *ifname); | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8393 | #endif /* __linux__ */ | 
|  | 8394 |  | 
|  | 8395 | enum send_frame_type { | 
|  | 8396 | DISASSOC, DEAUTH, SAQUERY | 
|  | 8397 | }; | 
|  | 8398 | enum send_frame_protection { | 
|  | 8399 | CORRECT_KEY, INCORRECT_KEY, UNPROTECTED | 
|  | 8400 | }; | 
|  | 8401 |  | 
|  | 8402 |  | 
|  | 8403 | static int ap_inject_frame(struct sigma_dut *dut, struct sigma_conn *conn, | 
|  | 8404 | enum send_frame_type frame, | 
|  | 8405 | enum send_frame_protection protected, | 
|  | 8406 | const char *sta_addr) | 
|  | 8407 | { | 
|  | 8408 | #ifdef __linux__ | 
|  | 8409 | unsigned char buf[1000], *pos; | 
|  | 8410 | int s, res; | 
|  | 8411 | unsigned char addr_sta[6], addr_own[6]; | 
|  | 8412 | char *ifname; | 
|  | 8413 | char cbuf[100]; | 
|  | 8414 | struct ifreq ifr; | 
|  | 8415 |  | 
|  | 8416 | if ((dut->ap_mode == AP_11a || dut->ap_mode == AP_11na || | 
|  | 8417 | dut->ap_mode == AP_11ac) && | 
|  | 8418 | if_nametoindex("wlan1") > 0) | 
|  | 8419 | ifname = "wlan1"; | 
|  | 8420 | else | 
|  | 8421 | ifname = "wlan0"; | 
|  | 8422 |  | 
|  | 8423 | if (hwaddr_aton(sta_addr, addr_sta) < 0) | 
|  | 8424 | return -1; | 
|  | 8425 |  | 
|  | 8426 | s = socket(AF_INET, SOCK_DGRAM, 0); | 
|  | 8427 | if (s < 0) | 
|  | 8428 | return -1; | 
|  | 8429 | memset(&ifr, 0, sizeof(ifr)); | 
| Peng Xu | b8fc5cc | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 8430 | strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8431 | if (ioctl(s, SIOCGIFHWADDR, &ifr) < 0) { | 
|  | 8432 | perror("ioctl"); | 
|  | 8433 | close(s); | 
|  | 8434 | return -1; | 
|  | 8435 | } | 
|  | 8436 | close(s); | 
|  | 8437 | memcpy(addr_own, ifr.ifr_hwaddr.sa_data, 6); | 
|  | 8438 |  | 
|  | 8439 | if (if_nametoindex("sigmadut") == 0) { | 
|  | 8440 | snprintf(cbuf, sizeof(cbuf), | 
|  | 8441 | "iw dev %s interface add sigmadut type monitor", | 
|  | 8442 | ifname); | 
|  | 8443 | if (system(cbuf) != 0 || | 
|  | 8444 | if_nametoindex("sigmadut") == 0) { | 
|  | 8445 | sigma_dut_print(dut, DUT_MSG_ERROR, "Failed to add " | 
|  | 8446 | "monitor interface with '%s'", cbuf); | 
|  | 8447 | return -2; | 
|  | 8448 | } | 
|  | 8449 | } | 
|  | 8450 |  | 
|  | 8451 | if (system("ifconfig sigmadut up") != 0) { | 
|  | 8452 | sigma_dut_print(dut, DUT_MSG_ERROR, "Failed to set " | 
|  | 8453 | "monitor interface up"); | 
|  | 8454 | return -2; | 
|  | 8455 | } | 
|  | 8456 |  | 
|  | 8457 | pos = buf; | 
|  | 8458 |  | 
|  | 8459 | /* Frame Control */ | 
|  | 8460 | switch (frame) { | 
|  | 8461 | case DISASSOC: | 
|  | 8462 | *pos++ = 0xa0; | 
|  | 8463 | break; | 
|  | 8464 | case DEAUTH: | 
|  | 8465 | *pos++ = 0xc0; | 
|  | 8466 | break; | 
|  | 8467 | case SAQUERY: | 
|  | 8468 | *pos++ = 0xd0; | 
|  | 8469 | break; | 
|  | 8470 | } | 
|  | 8471 |  | 
|  | 8472 | if (protected == INCORRECT_KEY) | 
|  | 8473 | *pos++ = 0x40; /* Set Protected field to 1 */ | 
|  | 8474 | else | 
|  | 8475 | *pos++ = 0x00; | 
|  | 8476 |  | 
|  | 8477 | /* Duration */ | 
|  | 8478 | *pos++ = 0x00; | 
|  | 8479 | *pos++ = 0x00; | 
|  | 8480 |  | 
|  | 8481 | /* addr1 = DA (station) */ | 
|  | 8482 | memcpy(pos, addr_sta, 6); | 
|  | 8483 | pos += 6; | 
|  | 8484 | /* addr2 = SA (own address) */ | 
|  | 8485 | memcpy(pos, addr_own, 6); | 
|  | 8486 | pos += 6; | 
|  | 8487 | /* addr3 = BSSID (own address) */ | 
|  | 8488 | memcpy(pos, addr_own, 6); | 
|  | 8489 | pos += 6; | 
|  | 8490 |  | 
|  | 8491 | /* Seq# (to be filled by driver/mac80211) */ | 
|  | 8492 | *pos++ = 0x00; | 
|  | 8493 | *pos++ = 0x00; | 
|  | 8494 |  | 
|  | 8495 | if (protected == INCORRECT_KEY) { | 
|  | 8496 | /* CCMP parameters */ | 
|  | 8497 | memcpy(pos, "\x61\x01\x00\x20\x00\x10\x00\x00", 8); | 
|  | 8498 | pos += 8; | 
|  | 8499 | } | 
|  | 8500 |  | 
|  | 8501 | if (protected == INCORRECT_KEY) { | 
|  | 8502 | switch (frame) { | 
|  | 8503 | case DEAUTH: | 
|  | 8504 | /* Reason code (encrypted) */ | 
|  | 8505 | memcpy(pos, "\xa7\x39", 2); | 
|  | 8506 | pos += 2; | 
|  | 8507 | break; | 
|  | 8508 | case DISASSOC: | 
|  | 8509 | /* Reason code (encrypted) */ | 
|  | 8510 | memcpy(pos, "\xa7\x39", 2); | 
|  | 8511 | pos += 2; | 
|  | 8512 | break; | 
|  | 8513 | case SAQUERY: | 
|  | 8514 | /* Category|Action|TransID (encrypted) */ | 
|  | 8515 | memcpy(pos, "\x6f\xbd\xe9\x4d", 4); | 
|  | 8516 | pos += 4; | 
|  | 8517 | break; | 
|  | 8518 | default: | 
|  | 8519 | return -1; | 
|  | 8520 | } | 
|  | 8521 |  | 
|  | 8522 | /* CCMP MIC */ | 
|  | 8523 | memcpy(pos, "\xc8\xd8\x3b\x06\x5d\xb7\x25\x68", 8); | 
|  | 8524 | pos += 8; | 
|  | 8525 | } else { | 
|  | 8526 | switch (frame) { | 
|  | 8527 | case DEAUTH: | 
|  | 8528 | /* reason code = 8 */ | 
|  | 8529 | *pos++ = 0x08; | 
|  | 8530 | *pos++ = 0x00; | 
|  | 8531 | break; | 
|  | 8532 | case DISASSOC: | 
|  | 8533 | /* reason code = 8 */ | 
|  | 8534 | *pos++ = 0x08; | 
|  | 8535 | *pos++ = 0x00; | 
|  | 8536 | break; | 
|  | 8537 | case SAQUERY: | 
|  | 8538 | /* Category - SA Query */ | 
|  | 8539 | *pos++ = 0x08; | 
|  | 8540 | /* SA query Action - Request */ | 
|  | 8541 | *pos++ = 0x00; | 
|  | 8542 | /* Transaction ID */ | 
|  | 8543 | *pos++ = 0x12; | 
|  | 8544 | *pos++ = 0x34; | 
|  | 8545 | break; | 
|  | 8546 | } | 
|  | 8547 | } | 
|  | 8548 |  | 
|  | 8549 | s = open_monitor("sigmadut"); | 
|  | 8550 | if (s < 0) { | 
|  | 8551 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,Failed to open " | 
|  | 8552 | "monitor socket"); | 
|  | 8553 | return 0; | 
|  | 8554 | } | 
|  | 8555 |  | 
|  | 8556 | res = inject_frame(s, buf, pos - buf, protected == CORRECT_KEY); | 
|  | 8557 | if (res < 0) { | 
|  | 8558 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,Failed to " | 
|  | 8559 | "inject frame"); | 
| Pradeep Reddy POTTETI | 673d85c | 2016-07-26 19:08:07 +0530 | [diff] [blame] | 8560 | close(s); | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8561 | return 0; | 
|  | 8562 | } | 
|  | 8563 | if (res < pos - buf) { | 
|  | 8564 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,Only partial " | 
|  | 8565 | "frame sent"); | 
| Pradeep Reddy POTTETI | 673d85c | 2016-07-26 19:08:07 +0530 | [diff] [blame] | 8566 | close(s); | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8567 | return 0; | 
|  | 8568 | } | 
|  | 8569 |  | 
|  | 8570 | close(s); | 
|  | 8571 |  | 
|  | 8572 | return 1; | 
|  | 8573 | #else /* __linux__ */ | 
|  | 8574 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,ap_send_frame not " | 
|  | 8575 | "yet supported"); | 
|  | 8576 | return 0; | 
|  | 8577 | #endif /* __linux__ */ | 
|  | 8578 | } | 
|  | 8579 |  | 
|  | 8580 |  | 
|  | 8581 | int ap_send_frame_hs2(struct sigma_dut *dut, struct sigma_conn *conn, | 
|  | 8582 | struct sigma_cmd *cmd) | 
|  | 8583 | { | 
|  | 8584 | const char *val, *dest; | 
|  | 8585 | char buf[100]; | 
|  | 8586 |  | 
|  | 8587 | val = get_param(cmd, "FrameName"); | 
|  | 8588 | if (val == NULL) | 
|  | 8589 | return -1; | 
|  | 8590 |  | 
|  | 8591 | if (strcasecmp(val, "QoSMapConfigure") == 0) { | 
|  | 8592 | dest = get_param(cmd, "Dest"); | 
|  | 8593 | if (!dest) | 
|  | 8594 | return -1; | 
|  | 8595 |  | 
|  | 8596 | val = get_param(cmd, "QoS_MAP_SET"); | 
|  | 8597 | if (val) { | 
|  | 8598 | dut->ap_qos_map_set = atoi(val); | 
|  | 8599 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_qos_map_set %d", | 
|  | 8600 | dut->ap_qos_map_set); | 
|  | 8601 | } | 
|  | 8602 |  | 
|  | 8603 | if (dut->ap_qos_map_set == 1) | 
|  | 8604 | run_hostapd_cli(dut, "set_qos_map_set " QOS_MAP_SET_1); | 
|  | 8605 | else if (dut->ap_qos_map_set == 2) | 
|  | 8606 | run_hostapd_cli(dut, "set_qos_map_set " QOS_MAP_SET_2); | 
|  | 8607 |  | 
|  | 8608 | snprintf(buf, sizeof(buf), "send_qos_map_conf %s", dest); | 
|  | 8609 | if (run_hostapd_cli(dut, buf) != 0) | 
|  | 8610 | return -1; | 
|  | 8611 | } | 
|  | 8612 |  | 
|  | 8613 | return 1; | 
|  | 8614 | } | 
|  | 8615 |  | 
|  | 8616 |  | 
|  | 8617 | static int ath_ap_send_frame_vht(struct sigma_dut *dut, struct sigma_conn *conn, | 
|  | 8618 | struct sigma_cmd *cmd) | 
|  | 8619 | { | 
|  | 8620 | const char *val; | 
|  | 8621 | char *ifname; | 
|  | 8622 | char buf[100]; | 
|  | 8623 | int chwidth, nss; | 
|  | 8624 |  | 
|  | 8625 | val = get_param(cmd, "FrameName"); | 
|  | 8626 | if (!val || strcasecmp(val, "op_md_notif_frm") != 0) { | 
|  | 8627 | send_resp(dut, conn, SIGMA_ERROR, | 
|  | 8628 | "errorCode,Unsupported FrameName"); | 
|  | 8629 | return 0; | 
|  | 8630 | } | 
|  | 8631 |  | 
|  | 8632 | /* | 
|  | 8633 | * Sequence of commands for Opmode notification on | 
|  | 8634 | * Peregrine based products | 
|  | 8635 | */ | 
|  | 8636 | ifname = get_main_ifname(); | 
|  | 8637 |  | 
|  | 8638 | /* Disable STBC */ | 
|  | 8639 | snprintf(buf, sizeof(buf), "iwpriv %s tx_stbc 0", ifname); | 
|  | 8640 | if (system(buf) != 0) { | 
|  | 8641 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 8642 | "iwpriv tx_stbc 0 failed!"); | 
|  | 8643 | } | 
|  | 8644 |  | 
|  | 8645 | /* Check whether optional arg channel width was passed */ | 
|  | 8646 | val = get_param(cmd, "Channel_width"); | 
|  | 8647 | if (val) { | 
|  | 8648 | switch (atoi(val)) { | 
|  | 8649 | case 20: | 
|  | 8650 | chwidth = 0; | 
|  | 8651 | break; | 
|  | 8652 | case 40: | 
|  | 8653 | chwidth = 1; | 
|  | 8654 | break; | 
|  | 8655 | case 80: | 
|  | 8656 | chwidth = 2; | 
|  | 8657 | break; | 
|  | 8658 | case 160: | 
|  | 8659 | chwidth = 3; | 
|  | 8660 | break; | 
|  | 8661 | default: | 
|  | 8662 | chwidth = 2; | 
|  | 8663 | break; | 
|  | 8664 | } | 
|  | 8665 | snprintf(buf, sizeof(buf), "iwpriv %s chwidth %d", | 
|  | 8666 | ifname, chwidth); | 
|  | 8667 | if (system(buf) != 0) { | 
|  | 8668 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 8669 | "iwpriv chwidth failed!"); | 
|  | 8670 | } | 
|  | 8671 | } | 
|  | 8672 |  | 
|  | 8673 | /* Check whether optional arg NSS was passed */ | 
|  | 8674 | val = get_param(cmd, "NSS"); | 
|  | 8675 | if (val) { | 
|  | 8676 | /* Convert nss to chainmask */ | 
|  | 8677 | switch (atoi(val)) { | 
|  | 8678 | case 1: | 
|  | 8679 | nss = 1; | 
|  | 8680 | break; | 
|  | 8681 | case 2: | 
|  | 8682 | nss = 3; | 
|  | 8683 | break; | 
|  | 8684 | case 3: | 
|  | 8685 | nss = 7; | 
|  | 8686 | break; | 
|  | 8687 | default: | 
|  | 8688 | /* We do not support NSS > 3 */ | 
|  | 8689 | nss = 3; | 
|  | 8690 | break; | 
|  | 8691 | } | 
|  | 8692 | snprintf(buf, sizeof(buf), "iwpriv %s rxchainmask %d", | 
|  | 8693 | ifname, nss); | 
|  | 8694 | if (system(buf) != 0) { | 
|  | 8695 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 8696 | "iwpriv rxchainmask failed!"); | 
|  | 8697 | } | 
|  | 8698 | } | 
|  | 8699 |  | 
|  | 8700 | /* Send the opmode notification */ | 
| Sunil Dutt | 27ec7f6 | 2017-09-14 18:22:59 +0300 | [diff] [blame] | 8701 | snprintf(buf, sizeof(buf), "iwpriv %s opmode_notify 1", ifname); | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 8702 | if (system(buf) != 0) { | 
|  | 8703 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 8704 | "iwpriv opmode_notify failed!"); | 
|  | 8705 | } | 
|  | 8706 |  | 
|  | 8707 | return 1; | 
|  | 8708 | } | 
|  | 8709 |  | 
|  | 8710 |  | 
| priyadharshini gowthaman | a27b5b6 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 8711 | static int ath_ap_send_frame_loc(struct sigma_dut *dut, struct sigma_conn *conn, | 
|  | 8712 | struct sigma_cmd *cmd) | 
|  | 8713 | { | 
|  | 8714 | const char *val; | 
|  | 8715 | FILE *f; | 
| priyadharshini gowthaman | a61badd | 2016-08-16 13:37:27 -0700 | [diff] [blame] | 8716 | int rand_int = 0; | 
| priyadharshini gowthaman | a27b5b6 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 8717 |  | 
|  | 8718 | val = get_param(cmd, "MsntType"); | 
|  | 8719 | if (val) { | 
|  | 8720 | if (dut->ap_msnt_type == 0) | 
|  | 8721 | dut->ap_msnt_type = atoi(val); | 
|  | 8722 |  | 
|  | 8723 | if (dut->ap_msnt_type != 5 && dut->ap_msnt_type != 2) { | 
|  | 8724 | dut->ap_msnt_type = atoi(val); | 
|  | 8725 | if (dut->ap_msnt_type == 1) { | 
| priyadharshini gowthaman | a61badd | 2016-08-16 13:37:27 -0700 | [diff] [blame] | 8726 | val = get_param(cmd, "RandInterval"); | 
|  | 8727 | if (val) | 
|  | 8728 | rand_int = atoi(val); | 
| priyadharshini gowthaman | a27b5b6 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 8729 | f = fopen("/tmp/ftmrr.txt", "a"); | 
|  | 8730 | if (!f) { | 
|  | 8731 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 8732 | "Failed to open /tmp/ftmrr.txt"); | 
|  | 8733 | return -1; | 
|  | 8734 | } | 
|  | 8735 |  | 
|  | 8736 | fprintf(f, "sta_mac = %s\n", cmd->values[3]); | 
| priyadharshini gowthaman | a61badd | 2016-08-16 13:37:27 -0700 | [diff] [blame] | 8737 | fprintf(f, "meas_type = 0x10\nrand_inter = 0x%x\nmin_ap_count = 0x%s\ndialogtoken = 0x1\nnum_repetitions = 0x0\nmeas_token = 0xf\nmeas_req_mode = 0x00\n", | 
|  | 8738 | rand_int, cmd->values[7]); | 
| priyadharshini gowthaman | a27b5b6 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 8739 | fclose(f); | 
|  | 8740 | dut->ap_msnt_type = 5; | 
|  | 8741 | run_system(dut, "wpc -f /tmp/ftmrr.txt"); | 
|  | 8742 | } | 
|  | 8743 | } else if (dut->ap_msnt_type == 5) { | 
|  | 8744 | run_system(dut, "wpc -f /tmp/ftmrr.txt"); | 
|  | 8745 | } else if (dut->ap_msnt_type == 2) { | 
|  | 8746 | f = fopen("/tmp/wru.txt", "w"); | 
|  | 8747 | if (!f) { | 
|  | 8748 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 8749 | "Failed to open /tmp/wru.txt"); | 
|  | 8750 | return -1; | 
|  | 8751 | } | 
|  | 8752 |  | 
|  | 8753 | fprintf(f, "sta_mac = %s\n", cmd->values[3]); | 
|  | 8754 | fprintf(f, "meas_type = 0x08\ndialogtoken = 0x1\nnum_repetitions = 0x0\nmeas_token = 0x1\nmeas_req_mode = 0x00\nloc_subject = 0x01\n"); | 
|  | 8755 | fclose(f); | 
|  | 8756 | run_system(dut, "wpc -w /tmp/wru.txt"); | 
|  | 8757 | } | 
|  | 8758 | } | 
|  | 8759 | return 1; | 
|  | 8760 | } | 
|  | 8761 |  | 
|  | 8762 |  | 
| Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 8763 | /* | 
|  | 8764 | * The following functions parse_send_frame_params_int(), | 
|  | 8765 | * parse_send_frame_params_str(), and parse_send_frame_params_mac() | 
|  | 8766 | * are used by ath_ap_send_frame_bcn_rpt_req(). | 
|  | 8767 | * Beacon Report Request is a frame used as part of the MBO program. | 
|  | 8768 | * The command for sending beacon report has a lot of | 
|  | 8769 | * arguments and having these functions reduces code size. | 
|  | 8770 | * | 
|  | 8771 | */ | 
|  | 8772 | static int parse_send_frame_params_int(char *param, struct sigma_cmd *cmd, | 
|  | 8773 | struct sigma_dut *dut, | 
|  | 8774 | char *buf, size_t buf_size) | 
|  | 8775 | { | 
|  | 8776 | const char *str_val; | 
|  | 8777 | int int_val; | 
|  | 8778 | char temp[100]; | 
|  | 8779 |  | 
|  | 8780 | str_val = get_param(cmd, param); | 
|  | 8781 | if (!str_val) { | 
|  | 8782 | sigma_dut_print(dut, DUT_MSG_ERROR, "%s not given", param); | 
|  | 8783 | return -1; | 
|  | 8784 | } | 
|  | 8785 | int_val = atoi(str_val); | 
|  | 8786 | snprintf(temp, sizeof(temp), " %d", int_val); | 
| Peng Xu | 591be45 | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 8787 | strlcat(buf, temp, buf_size); | 
| Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 8788 | return 0; | 
|  | 8789 | } | 
|  | 8790 |  | 
|  | 8791 |  | 
|  | 8792 | static int parse_send_frame_params_str(char *param, struct sigma_cmd *cmd, | 
|  | 8793 | struct sigma_dut *dut, | 
|  | 8794 | char *buf, size_t buf_size) | 
|  | 8795 | { | 
|  | 8796 | const char *str_val; | 
|  | 8797 | char temp[100]; | 
|  | 8798 |  | 
|  | 8799 | str_val = get_param(cmd, param); | 
|  | 8800 | if (!str_val) { | 
|  | 8801 | sigma_dut_print(dut, DUT_MSG_ERROR, "%s not given", param); | 
|  | 8802 | return -1; | 
|  | 8803 | } | 
|  | 8804 | snprintf(temp, sizeof(temp), " %s", str_val); | 
|  | 8805 | temp[sizeof(temp) - 1] = '\0'; | 
| Peng Xu | 591be45 | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 8806 | strlcat(buf, temp, buf_size); | 
| Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 8807 | return 0; | 
|  | 8808 | } | 
|  | 8809 |  | 
|  | 8810 |  | 
|  | 8811 | static int parse_send_frame_params_mac(char *param, struct sigma_cmd *cmd, | 
|  | 8812 | struct sigma_dut *dut, | 
|  | 8813 | char *buf, size_t buf_size) | 
|  | 8814 | { | 
|  | 8815 | const char *str_val; | 
|  | 8816 | unsigned char mac[6]; | 
|  | 8817 | char temp[100]; | 
|  | 8818 |  | 
|  | 8819 | str_val = get_param(cmd, param); | 
|  | 8820 | if (!str_val) { | 
|  | 8821 | sigma_dut_print(dut, DUT_MSG_ERROR, "%s not given", param); | 
|  | 8822 | return -1; | 
|  | 8823 | } | 
|  | 8824 |  | 
|  | 8825 | if (parse_mac_address(dut, str_val, mac) < 0) { | 
|  | 8826 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 8827 | "MAC Address not in proper format"); | 
|  | 8828 | return -1; | 
|  | 8829 | } | 
|  | 8830 | snprintf(temp, sizeof(temp), " %02x:%02x:%02x:%02x:%02x:%02x", | 
|  | 8831 | mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); | 
| Peng Xu | 591be45 | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 8832 | strlcat(buf, temp, buf_size); | 
| Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 8833 | return 0; | 
|  | 8834 | } | 
|  | 8835 |  | 
|  | 8836 |  | 
|  | 8837 | static void fill_1_or_0_based_on_presence(struct sigma_cmd *cmd, char *param, | 
|  | 8838 | char *buf, size_t buf_size) | 
|  | 8839 | { | 
|  | 8840 | const char *str_val; | 
|  | 8841 | char *value = " 1"; | 
|  | 8842 |  | 
|  | 8843 | str_val = get_param(cmd, param); | 
|  | 8844 | if (!str_val || str_val[0] == '\0') | 
|  | 8845 | value = " 0"; | 
| Peng Xu | 591be45 | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 8846 | strlcat(buf, value, buf_size); | 
| Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 8847 |  | 
|  | 8848 | } | 
|  | 8849 |  | 
|  | 8850 |  | 
|  | 8851 | /* | 
|  | 8852 | * wifitool athN sendbcnrpt | 
|  | 8853 | * <STA MAC        - Plugs in from Dest_MAC> | 
|  | 8854 | * <regclass       - Plugs in from RegClass - int> | 
|  | 8855 | * <channum        - Plugs in from Channel PARAM of dev_send_frame - int> | 
|  | 8856 | * <rand_ivl       - Plugs in from RandInt - string> | 
|  | 8857 | * <duration       - Plugs in from MeaDur - integer> | 
|  | 8858 | * <mode           - Plugs in from MeaMode - string> | 
|  | 8859 | * <req_ssid       - Plugs in from SSID PARAM of dev_send_frame - string> | 
|  | 8860 | * <rep_cond       - Plugs in from RptCond - integer> | 
|  | 8861 | * <rpt_detail     - Plugs in from RptDet - integer> | 
|  | 8862 | * <req_ie         - Plugs in from ReqInfo PARAM of dev_send_frame - string> | 
|  | 8863 | * <chanrpt_mode   - Plugs in from APChanRpt - integer> | 
|  | 8864 | * <specific_bssid - Plugs in from BSSID PARAM of dev_send_frame> | 
|  | 8865 | * [AP channel numbers] | 
|  | 8866 | */ | 
|  | 8867 | static int ath_ap_send_frame_bcn_rpt_req(struct sigma_dut *dut, | 
|  | 8868 | struct sigma_cmd *cmd, | 
|  | 8869 | const char *ifname) | 
|  | 8870 | { | 
|  | 8871 | char buf[100]; | 
|  | 8872 | int rpt_det; | 
|  | 8873 | const char *str_val; | 
|  | 8874 | const char *mea_mode; | 
|  | 8875 |  | 
|  | 8876 | snprintf(buf, sizeof(buf), "wifitool %s sendbcnrpt", ifname); | 
|  | 8877 |  | 
|  | 8878 | if (parse_send_frame_params_mac("Dest_MAC", cmd, dut, buf, sizeof(buf))) | 
|  | 8879 | return -1; | 
|  | 8880 | if (parse_send_frame_params_int("RegClass", cmd, dut, buf, sizeof(buf))) | 
|  | 8881 | return -1; | 
|  | 8882 | if (parse_send_frame_params_int("Channel", cmd, dut, buf, sizeof(buf))) | 
|  | 8883 | return -1; | 
|  | 8884 | if (parse_send_frame_params_str("RandInt", cmd, dut, buf, sizeof(buf))) | 
|  | 8885 | return -1; | 
|  | 8886 | if (parse_send_frame_params_int("MeaDur", cmd, dut, buf, sizeof(buf))) | 
|  | 8887 | return -1; | 
|  | 8888 |  | 
|  | 8889 | str_val = get_param(cmd, "MeaMode"); | 
|  | 8890 | if (!str_val) { | 
|  | 8891 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 8892 | "MeaMode parameter not present in send bcn-rpt-req"); | 
|  | 8893 | return -1; | 
|  | 8894 | } | 
|  | 8895 | if (strcasecmp(str_val, "passive") == 0) { | 
|  | 8896 | mea_mode = " 0"; | 
|  | 8897 | } else if (strcasecmp(str_val, "active") == 0) { | 
|  | 8898 | mea_mode = " 1"; | 
|  | 8899 | } else if (strcasecmp(str_val, "table") == 0) { | 
|  | 8900 | mea_mode = " 2"; | 
|  | 8901 | } else { | 
|  | 8902 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 8903 | "MEA-MODE Value not correctly given"); | 
|  | 8904 | return -1; | 
|  | 8905 | } | 
| Peng Xu | 591be45 | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 8906 | strlcat(buf, mea_mode, sizeof(buf)); | 
| Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 8907 |  | 
|  | 8908 | fill_1_or_0_based_on_presence(cmd, "SSID", buf, sizeof(buf)); | 
|  | 8909 |  | 
|  | 8910 | if (parse_send_frame_params_int("RptCond", cmd, dut, buf, sizeof(buf))) | 
|  | 8911 | return -1; | 
|  | 8912 |  | 
|  | 8913 | if (parse_send_frame_params_int("RptDet", cmd, dut, buf, sizeof(buf))) | 
|  | 8914 | return -1; | 
|  | 8915 | str_val = get_param(cmd, "RptDet"); | 
|  | 8916 | rpt_det = str_val ? atoi(str_val) : 0; | 
|  | 8917 |  | 
|  | 8918 | if (rpt_det) | 
|  | 8919 | fill_1_or_0_based_on_presence(cmd, "ReqInfo", buf, sizeof(buf)); | 
|  | 8920 | else | 
| Peng Xu | 591be45 | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 8921 | strlcat(buf, " 0", sizeof(buf)); | 
| Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 8922 |  | 
|  | 8923 | if (rpt_det) | 
|  | 8924 | fill_1_or_0_based_on_presence(cmd, "APChanRpt", buf, | 
|  | 8925 | sizeof(buf)); | 
|  | 8926 | else | 
| Peng Xu | 591be45 | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 8927 | strlcat(buf, " 0", sizeof(buf)); | 
| Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 8928 |  | 
|  | 8929 | if (parse_send_frame_params_mac("BSSID", cmd, dut, buf, sizeof(buf))) | 
|  | 8930 | return -1; | 
|  | 8931 |  | 
| priyadharshini gowthaman | 2a4d20e | 2017-12-28 13:01:34 -0800 | [diff] [blame] | 8932 | str_val = get_param(cmd, "APChanRpt"); | 
|  | 8933 | if (str_val) { | 
|  | 8934 | const char *pos; | 
|  | 8935 | int ap_chanrpt; | 
|  | 8936 | int ap_chanrpt_2 = 0; | 
|  | 8937 | char chanrpt[100]; | 
|  | 8938 |  | 
|  | 8939 | ap_chanrpt = atoi(str_val); | 
|  | 8940 | pos = strchr(str_val, '_'); | 
|  | 8941 | if (pos) { | 
|  | 8942 | pos++; | 
|  | 8943 | ap_chanrpt_2 = atoi(pos); | 
|  | 8944 | } | 
|  | 8945 | if (ap_chanrpt) { | 
|  | 8946 | snprintf(chanrpt, sizeof(chanrpt), " %d", ap_chanrpt); | 
|  | 8947 | strlcat(buf, chanrpt, sizeof(buf)); | 
|  | 8948 | } | 
|  | 8949 | if (ap_chanrpt_2) { | 
|  | 8950 | snprintf(chanrpt, sizeof(chanrpt), " %d", ap_chanrpt_2); | 
|  | 8951 | strlcat(buf, chanrpt, sizeof(buf)); | 
|  | 8952 | } | 
|  | 8953 | } | 
|  | 8954 |  | 
| Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 8955 | run_system(dut, buf); | 
|  | 8956 | return 0; | 
|  | 8957 | } | 
|  | 8958 |  | 
|  | 8959 |  | 
|  | 8960 | static void inform_and_sleep(struct sigma_dut *dut, int seconds) | 
|  | 8961 | { | 
|  | 8962 | sigma_dut_print(dut, DUT_MSG_DEBUG, "sleeping for %d seconds", seconds); | 
|  | 8963 | sleep(seconds); | 
|  | 8964 | sigma_dut_print(dut, DUT_MSG_DEBUG, "woke up after %d seconds", | 
|  | 8965 | seconds); | 
|  | 8966 | } | 
|  | 8967 |  | 
|  | 8968 |  | 
|  | 8969 | static int ath_ap_send_frame_btm_req(struct sigma_dut *dut, | 
|  | 8970 | struct sigma_cmd *cmd, const char *ifname) | 
|  | 8971 | { | 
|  | 8972 | unsigned char mac_addr[ETH_ALEN]; | 
|  | 8973 | int disassoc_timer; | 
|  | 8974 | char buf[100]; | 
|  | 8975 | const char *val; | 
|  | 8976 | int cand_list = 1; | 
| Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 8977 |  | 
|  | 8978 | val = get_param(cmd, "Dest_MAC"); | 
|  | 8979 | if (!val || parse_mac_address(dut, val, mac_addr) < 0) { | 
|  | 8980 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 8981 | "MAC Address not in proper format"); | 
|  | 8982 | return -1; | 
|  | 8983 | } | 
|  | 8984 |  | 
|  | 8985 | val = get_param(cmd, "Disassoc_Timer"); | 
|  | 8986 | if (val) | 
|  | 8987 | disassoc_timer = atoi(val); | 
|  | 8988 | else | 
|  | 8989 | disassoc_timer = dut->ap_disassoc_timer; | 
| Jouni Malinen | 032aeab | 2018-01-04 12:30:46 +0200 | [diff] [blame] | 8990 | if (disassoc_timer < 0) { | 
|  | 8991 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 8992 | "Invalid Disassoc_Timer value %d", | 
|  | 8993 | disassoc_timer); | 
|  | 8994 | return -1; | 
|  | 8995 | } | 
| Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 8996 |  | 
|  | 8997 | val = get_param(cmd, "Cand_List"); | 
|  | 8998 | if (val && val[0]) | 
|  | 8999 | cand_list = atoi(val); | 
|  | 9000 |  | 
|  | 9001 | val = get_param(cmd, "BTMQuery_Reason_Code"); | 
|  | 9002 | if (val) { | 
|  | 9003 | snprintf(buf, sizeof(buf), "iwpriv %s mbo_trans_rs %s", | 
|  | 9004 | ifname, val); | 
|  | 9005 | run_system(dut, buf); | 
|  | 9006 | } | 
|  | 9007 |  | 
| priyadharshini gowthaman | 776562e | 2017-12-20 12:33:34 -0800 | [diff] [blame] | 9008 | if (dut->ap_btmreq_disassoc_imnt && !dut->ap_assoc_delay) { | 
|  | 9009 | snprintf(buf, sizeof(buf), "iwpriv %s mbo_asoc_ret 1", ifname); | 
|  | 9010 | run_system(dut, buf); | 
|  | 9011 | } | 
|  | 9012 |  | 
| Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 9013 | snprintf(buf, sizeof(buf), | 
| priyadharshini gowthaman | 776562e | 2017-12-20 12:33:34 -0800 | [diff] [blame] | 9014 | "wifitool %s sendbstmreq %02x:%02x:%02x:%02x:%02x:%02x %d %d 15 %d %d %d %d", | 
| Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 9015 | ifname, mac_addr[0], mac_addr[1], mac_addr[2], mac_addr[3], | 
|  | 9016 | mac_addr[4], mac_addr[5], cand_list, disassoc_timer, | 
|  | 9017 | dut->ap_btmreq_disassoc_imnt, | 
|  | 9018 | dut->ap_btmreq_term_bit, | 
| priyadharshini gowthaman | 94062b5 | 2017-12-20 12:33:34 -0800 | [diff] [blame] | 9019 | dut->ap_btmreq_bss_term_tsf, | 
| Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 9020 | dut->ap_btmreq_bss_term_dur); | 
|  | 9021 | run_system(dut, buf); | 
|  | 9022 |  | 
|  | 9023 | if (dut->ap_btmreq_term_bit) { | 
| priyadharshini gowthaman | 94062b5 | 2017-12-20 12:33:34 -0800 | [diff] [blame] | 9024 | if (dut->ap_btmreq_bss_term_tsf >= 2) | 
|  | 9025 | inform_and_sleep(dut, dut->ap_btmreq_bss_term_tsf - 2); | 
| priyadharshini gowthaman | 776562e | 2017-12-20 12:33:34 -0800 | [diff] [blame] | 9026 | run_system_wrapper( | 
|  | 9027 | dut, "iwpriv %s kickmac %02x:%02x:%02x:%02x:%02x:%02x", | 
|  | 9028 | ifname, | 
|  | 9029 | mac_addr[0], mac_addr[1], mac_addr[2], | 
|  | 9030 | mac_addr[3], mac_addr[4], mac_addr[5]); | 
|  | 9031 | inform_and_sleep(dut, 2); | 
| Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 9032 | run_system_wrapper(dut, "ifconfig %s down", ifname); | 
| priyadharshini gowthaman | 776562e | 2017-12-20 12:33:34 -0800 | [diff] [blame] | 9033 | inform_and_sleep(dut, 5); | 
| Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 9034 | run_system_wrapper(dut, "ifconfig %s up", ifname); | 
|  | 9035 | } else if (dut->ap_btmreq_disassoc_imnt) { | 
|  | 9036 | inform_and_sleep(dut, (disassoc_timer / 1000) + 1); | 
|  | 9037 | run_system_wrapper(dut, | 
|  | 9038 | "iwpriv %s kickmac %02x:%02x:%02x:%02x:%02x:%02x", | 
|  | 9039 | ifname, | 
|  | 9040 | mac_addr[0], mac_addr[1], mac_addr[2], | 
|  | 9041 | mac_addr[3], mac_addr[4], mac_addr[5]); | 
|  | 9042 | } | 
|  | 9043 | return 0; | 
|  | 9044 | } | 
|  | 9045 |  | 
|  | 9046 |  | 
| priyadharshini gowthaman | 2a4d20e | 2017-12-28 13:01:34 -0800 | [diff] [blame] | 9047 | static int ath_ap_send_frame_disassoc(struct sigma_dut *dut, | 
|  | 9048 | struct sigma_cmd *cmd, const char *ifname) | 
|  | 9049 | { | 
|  | 9050 | unsigned char mac_addr[ETH_ALEN]; | 
|  | 9051 | const char *val; | 
|  | 9052 |  | 
|  | 9053 | val = get_param(cmd, "Dest_MAC"); | 
|  | 9054 | if (!val || parse_mac_address(dut, val, mac_addr) < 0) { | 
|  | 9055 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 9056 | "MAC Address not in proper format"); | 
|  | 9057 | return -1; | 
|  | 9058 | } | 
|  | 9059 |  | 
|  | 9060 | run_system_wrapper(dut, | 
|  | 9061 | "iwpriv %s kickmac %02x:%02x:%02x:%02x:%02x:%02x", | 
|  | 9062 | ifname, mac_addr[0], mac_addr[1], mac_addr[2], | 
|  | 9063 | mac_addr[3], mac_addr[4], mac_addr[5]); | 
|  | 9064 | return 0; | 
|  | 9065 | } | 
|  | 9066 |  | 
|  | 9067 |  | 
| priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 9068 | static int ath_ap_send_frame_mbo(struct sigma_dut *dut, struct sigma_conn *conn, | 
|  | 9069 | struct sigma_cmd *cmd) | 
|  | 9070 | { | 
|  | 9071 | const char *val; | 
|  | 9072 | char *ifname; | 
| priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 9073 |  | 
|  | 9074 | ifname = get_main_ifname(); | 
|  | 9075 |  | 
|  | 9076 | val = get_param(cmd, "FrameName"); | 
|  | 9077 | if (!val) | 
|  | 9078 | return -1; | 
|  | 9079 |  | 
| Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 9080 | if (strcasecmp(val, "BTMReq") == 0) | 
|  | 9081 | ath_ap_send_frame_btm_req(dut, cmd, ifname); | 
|  | 9082 | else if (strcasecmp(val, "BcnRptReq") == 0) | 
|  | 9083 | ath_ap_send_frame_bcn_rpt_req(dut, cmd, ifname); | 
| priyadharshini gowthaman | 2a4d20e | 2017-12-28 13:01:34 -0800 | [diff] [blame] | 9084 | else if (strcasecmp(val, "disassoc") == 0) | 
|  | 9085 | ath_ap_send_frame_disassoc(dut, cmd, ifname); | 
| Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 9086 | else | 
|  | 9087 | return -1; | 
| priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 9088 |  | 
|  | 9089 | return 1; | 
|  | 9090 | } | 
|  | 9091 |  | 
|  | 9092 |  | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9093 | static int ap_send_frame_vht(struct sigma_dut *dut, struct sigma_conn *conn, | 
|  | 9094 | struct sigma_cmd *cmd) | 
|  | 9095 | { | 
|  | 9096 | switch (get_driver_type()) { | 
|  | 9097 | case DRIVER_ATHEROS: | 
|  | 9098 | return ath_ap_send_frame_vht(dut, conn, cmd); | 
|  | 9099 | break; | 
|  | 9100 | case DRIVER_OPENWRT: | 
|  | 9101 | switch (get_openwrt_driver_type()) { | 
|  | 9102 | case OPENWRT_DRIVER_ATHEROS: | 
|  | 9103 | return ath_ap_send_frame_vht(dut, conn, cmd); | 
|  | 9104 | default: | 
|  | 9105 | send_resp(dut, conn, SIGMA_ERROR, | 
|  | 9106 | "errorCode,Unsupported ap_send_frame with the current openwrt driver"); | 
|  | 9107 | return 0; | 
|  | 9108 | } | 
|  | 9109 | default: | 
|  | 9110 | send_resp(dut, conn, SIGMA_ERROR, | 
|  | 9111 | "errorCode,Unsupported ap_send_frame with the current driver"); | 
|  | 9112 | return 0; | 
|  | 9113 | } | 
|  | 9114 | } | 
|  | 9115 |  | 
|  | 9116 |  | 
| priyadharshini gowthaman | a27b5b6 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 9117 | static int ap_send_frame_loc(struct sigma_dut *dut, struct sigma_conn *conn, | 
|  | 9118 | struct sigma_cmd *cmd) | 
|  | 9119 | { | 
|  | 9120 | switch (get_driver_type()) { | 
|  | 9121 | case DRIVER_ATHEROS: | 
|  | 9122 | return ath_ap_send_frame_loc(dut, conn, cmd); | 
|  | 9123 | case DRIVER_OPENWRT: | 
|  | 9124 | switch (get_openwrt_driver_type()) { | 
|  | 9125 | case OPENWRT_DRIVER_ATHEROS: | 
|  | 9126 | return ath_ap_send_frame_loc(dut, conn, cmd); | 
|  | 9127 | default: | 
|  | 9128 | send_resp(dut, conn, SIGMA_ERROR, | 
|  | 9129 | "errorCode,Unsupported ap_send_frame_loc with the current openwrt driver"); | 
|  | 9130 | return 0; | 
|  | 9131 | } | 
|  | 9132 | default: | 
|  | 9133 | send_resp(dut, conn, SIGMA_ERROR, | 
|  | 9134 | "errorCode,Unsupported ap_send_frame_loc with the current driver"); | 
|  | 9135 | return 0; | 
|  | 9136 | } | 
|  | 9137 | } | 
|  | 9138 |  | 
|  | 9139 |  | 
| priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 9140 | static int ap_send_frame_mbo(struct sigma_dut *dut, struct sigma_conn *conn, | 
|  | 9141 | struct sigma_cmd *cmd) | 
|  | 9142 | { | 
|  | 9143 | switch (get_driver_type()) { | 
|  | 9144 | case DRIVER_ATHEROS: | 
|  | 9145 | return ath_ap_send_frame_mbo(dut, conn, cmd); | 
|  | 9146 | case DRIVER_OPENWRT: | 
|  | 9147 | switch (get_openwrt_driver_type()) { | 
|  | 9148 | case OPENWRT_DRIVER_ATHEROS: | 
|  | 9149 | return ath_ap_send_frame_mbo(dut, conn, cmd); | 
|  | 9150 | default: | 
|  | 9151 | send_resp(dut, conn, SIGMA_ERROR, | 
|  | 9152 | "errorCode,Unsupported ap_send_frame with the current openwrt driver"); | 
|  | 9153 | return 0; | 
|  | 9154 | } | 
|  | 9155 | default: | 
|  | 9156 | send_resp(dut, conn, SIGMA_ERROR, | 
|  | 9157 | "errorCode,Unsupported ap_send_frame with the current driver"); | 
|  | 9158 | return 0; | 
|  | 9159 | } | 
|  | 9160 | } | 
|  | 9161 |  | 
|  | 9162 |  | 
| Lior David | 0fe101e | 2017-03-09 16:09:50 +0200 | [diff] [blame] | 9163 | static int ap_send_frame_60g(struct sigma_dut *dut, | 
|  | 9164 | struct sigma_conn *conn, | 
|  | 9165 | struct sigma_cmd *cmd) | 
|  | 9166 | { | 
|  | 9167 | switch (get_driver_type()) { | 
|  | 9168 | #ifdef __linux__ | 
|  | 9169 | case DRIVER_WIL6210: | 
|  | 9170 | return wil6210_send_frame_60g(dut, conn, cmd); | 
|  | 9171 | #endif /* __linux__ */ | 
|  | 9172 | default: | 
|  | 9173 | send_resp(dut, conn, SIGMA_ERROR, | 
|  | 9174 | "errorCode,Unsupported sta_set_frame(60G) with the current driver"); | 
|  | 9175 | return 0; | 
|  | 9176 | } | 
|  | 9177 | } | 
|  | 9178 |  | 
|  | 9179 |  | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9180 | int cmd_ap_send_frame(struct sigma_dut *dut, struct sigma_conn *conn, | 
|  | 9181 | struct sigma_cmd *cmd) | 
|  | 9182 | { | 
|  | 9183 | /* const char *name = get_param(cmd, "NAME"); */ | 
|  | 9184 | /* const char *ifname = get_param(cmd, "INTERFACE"); */ | 
|  | 9185 | const char *val; | 
|  | 9186 | enum send_frame_type frame; | 
|  | 9187 | enum send_frame_protection protected; | 
|  | 9188 | char buf[100]; | 
|  | 9189 |  | 
|  | 9190 | val = get_param(cmd, "Program"); | 
|  | 9191 | if (val) { | 
|  | 9192 | if (strcasecmp(val, "HS2") == 0 || | 
| Adil Saeed Musthafa | 33ea287 | 2017-04-10 23:13:24 -0700 | [diff] [blame] | 9193 | strcasecmp(val, "HS2-R2") == 0 || | 
|  | 9194 | strcasecmp(val, "IOTLP") == 0) | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9195 | return ap_send_frame_hs2(dut, conn, cmd); | 
|  | 9196 | if (strcasecmp(val, "VHT") == 0) | 
|  | 9197 | return ap_send_frame_vht(dut, conn, cmd); | 
| priyadharshini gowthaman | a27b5b6 | 2016-06-22 22:47:14 -0700 | [diff] [blame] | 9198 | if (strcasecmp(val, "LOC") == 0) | 
|  | 9199 | return ap_send_frame_loc(dut, conn, cmd); | 
| priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 9200 | if (strcasecmp(val, "MBO") == 0) | 
|  | 9201 | return ap_send_frame_mbo(dut, conn, cmd); | 
| Lior David | 0fe101e | 2017-03-09 16:09:50 +0200 | [diff] [blame] | 9202 | if (strcasecmp(val, "60GHz") == 0) | 
|  | 9203 | return ap_send_frame_60g(dut, conn, cmd); | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9204 | } | 
|  | 9205 |  | 
|  | 9206 | val = get_param(cmd, "PMFFrameType"); | 
|  | 9207 | if (val == NULL) | 
|  | 9208 | val = get_param(cmd, "FrameName"); | 
|  | 9209 | if (val == NULL) | 
|  | 9210 | val = get_param(cmd, "Type"); | 
|  | 9211 | if (val == NULL) | 
|  | 9212 | return -1; | 
|  | 9213 | if (strcasecmp(val, "disassoc") == 0) | 
|  | 9214 | frame = DISASSOC; | 
|  | 9215 | else if (strcasecmp(val, "deauth") == 0) | 
|  | 9216 | frame = DEAUTH; | 
|  | 9217 | else if (strcasecmp(val, "saquery") == 0) | 
|  | 9218 | frame = SAQUERY; | 
|  | 9219 | else { | 
|  | 9220 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,Unsupported " | 
|  | 9221 | "PMFFrameType"); | 
|  | 9222 | return 0; | 
|  | 9223 | } | 
|  | 9224 |  | 
|  | 9225 | val = get_param(cmd, "PMFProtected"); | 
|  | 9226 | if (val == NULL) | 
|  | 9227 | val = get_param(cmd, "Protected"); | 
|  | 9228 | if (val == NULL) | 
|  | 9229 | return -1; | 
|  | 9230 | if (strcasecmp(val, "Correct-key") == 0 || | 
|  | 9231 | strcasecmp(val, "CorrectKey") == 0) | 
|  | 9232 | protected = CORRECT_KEY; | 
|  | 9233 | else if (strcasecmp(val, "IncorrectKey") == 0) | 
|  | 9234 | protected = INCORRECT_KEY; | 
|  | 9235 | else if (strcasecmp(val, "Unprotected") == 0) | 
|  | 9236 | protected = UNPROTECTED; | 
|  | 9237 | else { | 
|  | 9238 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,Unsupported " | 
|  | 9239 | "PMFProtected"); | 
|  | 9240 | return 0; | 
|  | 9241 | } | 
|  | 9242 |  | 
|  | 9243 | val = get_param(cmd, "stationID"); | 
|  | 9244 | if (val == NULL) | 
|  | 9245 | return -1; | 
|  | 9246 |  | 
|  | 9247 | if (protected == INCORRECT_KEY || | 
|  | 9248 | (protected == UNPROTECTED && frame == SAQUERY)) | 
|  | 9249 | return ap_inject_frame(dut, conn, frame, protected, val); | 
|  | 9250 |  | 
|  | 9251 | switch (frame) { | 
|  | 9252 | case DISASSOC: | 
|  | 9253 | snprintf(buf, sizeof(buf), "disassoc %s test=%d", | 
|  | 9254 | val, protected == CORRECT_KEY); | 
|  | 9255 | break; | 
|  | 9256 | case DEAUTH: | 
|  | 9257 | snprintf(buf, sizeof(buf), "deauth %s test=%d", | 
|  | 9258 | val, protected == CORRECT_KEY); | 
|  | 9259 | break; | 
|  | 9260 | case SAQUERY: | 
|  | 9261 | snprintf(buf, sizeof(buf), "sa_query %s", val); | 
|  | 9262 | break; | 
|  | 9263 | } | 
|  | 9264 |  | 
|  | 9265 | if (run_hostapd_cli(dut, buf) != 0) | 
|  | 9266 | return -2; | 
|  | 9267 |  | 
|  | 9268 | return 1; | 
|  | 9269 | } | 
|  | 9270 |  | 
|  | 9271 |  | 
|  | 9272 | static int cmd_ap_get_mac_address(struct sigma_dut *dut, | 
|  | 9273 | struct sigma_conn *conn, | 
|  | 9274 | struct sigma_cmd *cmd) | 
|  | 9275 | { | 
|  | 9276 | #if defined( __linux__) | 
|  | 9277 | /* const char *name = get_param(cmd, "NAME"); */ | 
|  | 9278 | /* const char *ifname = get_param(cmd, "INTERFACE"); */ | 
| Jouni Malinen | f898464 | 2017-10-12 00:02:37 +0300 | [diff] [blame] | 9279 | char resp[100]; | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9280 | unsigned char addr[6]; | 
| Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 9281 | char ifname[50]; | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9282 | struct ifreq ifr; | 
| Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 9283 | int s, wlan_tag = 1; | 
|  | 9284 | const char *val; | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9285 |  | 
| Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 9286 | val = get_param(cmd, "WLAN_TAG"); | 
|  | 9287 | if (val) { | 
|  | 9288 | wlan_tag = atoi(val); | 
|  | 9289 | if (wlan_tag < 1 || wlan_tag > 3) { | 
|  | 9290 | /* | 
|  | 9291 | * The only valid WLAN Tags as of now as per the latest | 
|  | 9292 | * WFA scripts are 1, 2, and 3. | 
|  | 9293 | */ | 
| Jouni Malinen | f898464 | 2017-10-12 00:02:37 +0300 | [diff] [blame] | 9294 | send_resp(dut, conn, SIGMA_ERROR, | 
| Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 9295 | "errorCode,Unsupported WLAN_TAG"); | 
|  | 9296 | return 0; | 
|  | 9297 | } | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9298 | } | 
|  | 9299 |  | 
| Adil Saeed Musthafa | b7b297f | 2017-04-10 23:13:31 -0700 | [diff] [blame] | 9300 | get_if_name(dut, ifname, sizeof(ifname), wlan_tag); | 
|  | 9301 |  | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9302 | s = socket(AF_INET, SOCK_DGRAM, 0); | 
|  | 9303 | if (s < 0) | 
|  | 9304 | return -1; | 
|  | 9305 | memset(&ifr, 0, sizeof(ifr)); | 
| Peng Xu | b8fc5cc | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 9306 | strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9307 | if (ioctl(s, SIOCGIFHWADDR, &ifr) < 0) { | 
|  | 9308 | perror("ioctl"); | 
|  | 9309 | close(s); | 
| Jouni Malinen | f898464 | 2017-10-12 00:02:37 +0300 | [diff] [blame] | 9310 | snprintf(resp, sizeof(resp), | 
|  | 9311 | "errorCode,Could not find interface %s", ifname); | 
|  | 9312 | send_resp(dut, conn, SIGMA_ERROR, resp); | 
|  | 9313 | return 0; | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9314 | } | 
|  | 9315 | close(s); | 
|  | 9316 | memcpy(addr, ifr.ifr_hwaddr.sa_data, 6); | 
|  | 9317 |  | 
|  | 9318 | snprintf(resp, sizeof(resp), "mac,%02x:%02x:%02x:%02x:%02x:%02x", | 
|  | 9319 | addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]); | 
|  | 9320 | send_resp(dut, conn, SIGMA_COMPLETE, resp); | 
|  | 9321 | return 0; | 
|  | 9322 | #elif defined( __QNXNTO__) | 
|  | 9323 | char resp[50]; | 
|  | 9324 | unsigned char addr[6]; | 
|  | 9325 |  | 
|  | 9326 | if (!sigma_main_ifname) { | 
|  | 9327 | send_resp(dut, conn, SIGMA_ERROR, "ifname is null"); | 
|  | 9328 | return 0; | 
|  | 9329 | } | 
|  | 9330 |  | 
|  | 9331 | if (get_hwaddr(sigma_main_ifname, addr) != 0) { | 
|  | 9332 | send_resp(dut, conn, SIGMA_ERROR, | 
|  | 9333 | "errorCode,Failed to get address"); | 
|  | 9334 | return 0; | 
|  | 9335 | } | 
|  | 9336 | snprintf(resp, sizeof(resp), "mac,%02x:%02x:%02x:%02x:%02x:%02x", | 
|  | 9337 | addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]); | 
|  | 9338 | send_resp(dut, conn, SIGMA_COMPLETE, resp); | 
|  | 9339 | return 0; | 
|  | 9340 | #else /* __linux__ */ | 
|  | 9341 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,ap_get_mac_address not " | 
|  | 9342 | "yet supported"); | 
|  | 9343 | return 0; | 
|  | 9344 | #endif /* __linux__ */ | 
|  | 9345 | } | 
|  | 9346 |  | 
|  | 9347 |  | 
| Ankita Bajaj | 0d5825b | 2017-10-25 16:20:17 +0530 | [diff] [blame] | 9348 | int sta_cfon_get_mac_address(struct sigma_dut *dut, struct sigma_conn *conn, | 
|  | 9349 | struct sigma_cmd *cmd) | 
|  | 9350 | { | 
|  | 9351 | return cmd_ap_get_mac_address(dut, conn, cmd); | 
|  | 9352 | } | 
|  | 9353 |  | 
|  | 9354 |  | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9355 | static int cmd_ap_set_pmf(struct sigma_dut *dut, struct sigma_conn *conn, | 
|  | 9356 | struct sigma_cmd *cmd) | 
|  | 9357 | { | 
|  | 9358 | /* | 
|  | 9359 | * Ignore the command since the parameters are already handled through | 
|  | 9360 | * ap_set_security. | 
|  | 9361 | */ | 
|  | 9362 |  | 
|  | 9363 | return 1; | 
|  | 9364 | } | 
|  | 9365 |  | 
|  | 9366 |  | 
|  | 9367 | static int cmd_ap_set_hs2(struct sigma_dut *dut, struct sigma_conn *conn, | 
|  | 9368 | struct sigma_cmd *cmd) | 
|  | 9369 | { | 
|  | 9370 | /* const char *name = get_param(cmd, "NAME"); */ | 
|  | 9371 | /* const char *ifname = get_param(cmd, "INTERFACE"); */ | 
|  | 9372 | const char *val, *dest; | 
|  | 9373 | char *pos, buf[100]; | 
|  | 9374 | int i, wlan_tag = 1; | 
|  | 9375 |  | 
|  | 9376 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_set_hs2: Processing the " | 
|  | 9377 | "following parameters"); | 
|  | 9378 | for (i = 0; i < cmd->count; i++) { | 
|  | 9379 | sigma_dut_print(dut, DUT_MSG_INFO, "%s %s", cmd->params[i], | 
|  | 9380 | (cmd->values[i] ? cmd->values[i] : "NULL")); | 
|  | 9381 | } | 
|  | 9382 |  | 
|  | 9383 | val = get_param(cmd, "ICMPv4_ECHO"); | 
|  | 9384 | if (val && atoi(val)) { | 
|  | 9385 | snprintf(buf, sizeof(buf), "ebtables -F"); | 
|  | 9386 | if (system(buf) != 0) { | 
|  | 9387 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 9388 | "Failed to set ebtables rules, RULE-12"); | 
|  | 9389 | } | 
|  | 9390 | return 1; | 
|  | 9391 | } | 
|  | 9392 |  | 
|  | 9393 | val = get_param(cmd, "WLAN_TAG"); | 
|  | 9394 | if (val) { | 
|  | 9395 | wlan_tag = atoi(val); | 
|  | 9396 | if (wlan_tag != 1 && wlan_tag != 2) { | 
|  | 9397 | send_resp(dut, conn, SIGMA_INVALID, | 
|  | 9398 | "errorCode,Invalid WLAN_TAG"); | 
|  | 9399 | return 0; | 
|  | 9400 | } | 
|  | 9401 | } | 
|  | 9402 |  | 
|  | 9403 | if (wlan_tag == 2) { | 
|  | 9404 | val = get_param(cmd, "PROXY_ARP"); | 
|  | 9405 | if (val) | 
|  | 9406 | dut->ap2_proxy_arp = atoi(val); | 
| Jouni Malinen | dbbc2c4 | 2018-11-14 23:55:41 +0200 | [diff] [blame] | 9407 |  | 
|  | 9408 | val = get_param(cmd, "OSU"); | 
|  | 9409 | if (val) | 
|  | 9410 | dut->ap2_osu = atoi(val); | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9411 | return 1; | 
|  | 9412 | } | 
|  | 9413 |  | 
|  | 9414 | dest = get_param(cmd, "STA_MAC"); | 
|  | 9415 | if (dest) { | 
|  | 9416 | /* This is a special/ugly way of using this command. | 
|  | 9417 | * If "Dest" MAC is included, assume that this command | 
|  | 9418 | * is being issued after ap_config_commit for dynamically | 
|  | 9419 | * setting the QoS Map Set. | 
|  | 9420 | */ | 
|  | 9421 | val = get_param(cmd, "QoS_MAP_SET"); | 
|  | 9422 | if (val) { | 
|  | 9423 | dut->ap_qos_map_set = atoi(val); | 
|  | 9424 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_qos_map_set %d", | 
|  | 9425 | dut->ap_qos_map_set); | 
|  | 9426 | } | 
|  | 9427 |  | 
|  | 9428 | if (dut->ap_qos_map_set == 1) | 
|  | 9429 | run_hostapd_cli(dut, "set_qos_map_set " QOS_MAP_SET_1); | 
|  | 9430 | else if (dut->ap_qos_map_set == 2) | 
|  | 9431 | run_hostapd_cli(dut, "set_qos_map_set " QOS_MAP_SET_2); | 
|  | 9432 |  | 
|  | 9433 | snprintf(buf, sizeof(buf), "send_qos_map_conf %s", dest); | 
|  | 9434 | if (run_hostapd_cli(dut, buf) != 0) | 
|  | 9435 | return -1; | 
|  | 9436 | } | 
|  | 9437 |  | 
|  | 9438 | val = get_param(cmd, "DGAF_DISABLE"); | 
|  | 9439 | if (val) | 
|  | 9440 | dut->ap_dgaf_disable = atoi(val); | 
|  | 9441 |  | 
|  | 9442 | dut->ap_interworking = 1; | 
|  | 9443 |  | 
|  | 9444 | val = get_param(cmd, "INTERWORKING"); | 
|  | 9445 | if (val == NULL) | 
|  | 9446 | val = get_param(cmd, "INTERNETWORKING"); | 
|  | 9447 | if (val != NULL && atoi(val) == 0) { | 
|  | 9448 | dut->ap_interworking = 0; | 
|  | 9449 | dut->ap_hs2 = 0; | 
|  | 9450 | return 1; | 
|  | 9451 | } | 
|  | 9452 |  | 
|  | 9453 | val = get_param(cmd, "ACCS_NET_TYPE"); | 
|  | 9454 | if (val) { | 
|  | 9455 | if (strcasecmp(val, "Chargeable_Public_Network") == 0 || | 
|  | 9456 | strcasecmp(val, "Chargable_Public_Network") == 0 || | 
|  | 9457 | strcasecmp(val, "Chargable Public Network") == 0) | 
|  | 9458 | dut->ap_access_net_type = 2; | 
|  | 9459 | else | 
|  | 9460 | dut->ap_access_net_type = atoi(val); | 
|  | 9461 | } | 
|  | 9462 |  | 
|  | 9463 | val = get_param(cmd, "INTERNET"); | 
|  | 9464 | if (val) | 
|  | 9465 | dut->ap_internet = atoi(val); | 
|  | 9466 |  | 
|  | 9467 | val = get_param(cmd, "VENUE_GRP"); | 
|  | 9468 | if (val) { | 
|  | 9469 | if (strcasecmp(val, "Business") == 0) | 
|  | 9470 | dut->ap_venue_group = 2; | 
|  | 9471 | else | 
|  | 9472 | dut->ap_venue_group = atoi(val); | 
|  | 9473 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_venue_name %d", | 
|  | 9474 | dut->ap_venue_name); | 
|  | 9475 | } | 
|  | 9476 |  | 
|  | 9477 | val = get_param(cmd, "VENUE_TYPE"); | 
|  | 9478 | if (val) { | 
|  | 9479 | if (strcasecmp(val, "R&D") == 0) | 
|  | 9480 | dut->ap_venue_type = 8; | 
|  | 9481 | else | 
|  | 9482 | dut->ap_venue_type = atoi(val); | 
|  | 9483 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_venue_type %d", | 
|  | 9484 | dut->ap_venue_type); | 
|  | 9485 | } | 
|  | 9486 |  | 
|  | 9487 | val = get_param(cmd, "HESSID"); | 
|  | 9488 | if (val) { | 
|  | 9489 | if (strlen(val) >= sizeof(dut->ap_hessid)) { | 
|  | 9490 | send_resp(dut, conn, SIGMA_ERROR, | 
|  | 9491 | "errorCode,Invalid HESSID"); | 
|  | 9492 | return 0; | 
|  | 9493 | } | 
|  | 9494 | snprintf(dut->ap_hessid, sizeof(dut->ap_hessid), "%s", val); | 
|  | 9495 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_hessid %s", | 
|  | 9496 | dut->ap_hessid); | 
|  | 9497 | } | 
|  | 9498 |  | 
|  | 9499 | val = get_param(cmd, "ROAMING_CONS"); | 
|  | 9500 | if (val) { | 
|  | 9501 | if (strlen(val) >= sizeof(dut->ap_roaming_cons)) { | 
|  | 9502 | send_resp(dut, conn, SIGMA_ERROR, | 
|  | 9503 | "errorCode,Invalid ROAMING_CONS"); | 
|  | 9504 | return 0; | 
|  | 9505 | } | 
|  | 9506 | if (strcasecmp(val, "Disabled") == 0) { | 
|  | 9507 | dut->ap_roaming_cons[0] = '\0'; | 
|  | 9508 | } else { | 
|  | 9509 | snprintf(dut->ap_roaming_cons, | 
|  | 9510 | sizeof(dut->ap_roaming_cons), "%s", val); | 
|  | 9511 | } | 
|  | 9512 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_roaming_cons %s", | 
|  | 9513 | dut->ap_roaming_cons); | 
|  | 9514 | } | 
|  | 9515 |  | 
|  | 9516 | val = get_param(cmd, "ANQP"); | 
|  | 9517 | if (val) | 
|  | 9518 | dut->ap_anqpserver_on = atoi(val); | 
|  | 9519 |  | 
|  | 9520 | val = get_param(cmd, "NAI_REALM_LIST"); | 
|  | 9521 | if (val) { | 
|  | 9522 | dut->ap_nai_realm_list = atoi(val); | 
|  | 9523 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_nai_realm_list %d", | 
|  | 9524 | dut->ap_nai_realm_list); | 
|  | 9525 | } | 
|  | 9526 |  | 
|  | 9527 | val = get_param(cmd, "3GPP_INFO"); | 
|  | 9528 | if (val) { | 
|  | 9529 | /* What kind of encoding format is used?! */ | 
|  | 9530 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,3GPP_INFO " | 
|  | 9531 | "not yet supported (contents not fully defined)"); | 
|  | 9532 | return 0; | 
|  | 9533 | } | 
|  | 9534 |  | 
|  | 9535 | val = get_param(cmd, "DOMAIN_LIST"); | 
|  | 9536 | if (val) { | 
|  | 9537 | if (strlen(val) >= sizeof(dut->ap_domain_name_list)) { | 
|  | 9538 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,Too long " | 
|  | 9539 | "DOMAIN_LIST"); | 
|  | 9540 | return 0; | 
|  | 9541 | } | 
|  | 9542 | snprintf(dut->ap_domain_name_list, | 
|  | 9543 | sizeof(dut->ap_domain_name_list), "%s", val); | 
|  | 9544 | pos = dut->ap_domain_name_list; | 
|  | 9545 | while (*pos) { | 
|  | 9546 | if (*pos == ';') | 
|  | 9547 | *pos = ','; | 
|  | 9548 | pos++; | 
|  | 9549 | } | 
|  | 9550 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_domain_name_list %s", | 
|  | 9551 | dut->ap_domain_name_list); | 
|  | 9552 | } | 
|  | 9553 |  | 
|  | 9554 | val = get_param(cmd, "OPER_NAME"); | 
|  | 9555 | if (val) { | 
|  | 9556 | dut->ap_oper_name = atoi(val); | 
|  | 9557 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_oper_name %d", | 
|  | 9558 | dut->ap_oper_name); | 
|  | 9559 | } | 
|  | 9560 |  | 
|  | 9561 | val = get_param(cmd, "VENUE_NAME"); | 
|  | 9562 | if (val) { | 
|  | 9563 | dut->ap_venue_name = atoi(val); | 
|  | 9564 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_venue_name %d", | 
|  | 9565 | dut->ap_venue_name); | 
|  | 9566 | } | 
|  | 9567 |  | 
|  | 9568 | val = get_param(cmd, "GAS_CB_DELAY"); | 
|  | 9569 | if (val) { | 
|  | 9570 | dut->ap_gas_cb_delay = atoi(val); | 
|  | 9571 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_gas_cb_delay %d", | 
|  | 9572 | dut->ap_gas_cb_delay); | 
|  | 9573 | } | 
|  | 9574 |  | 
|  | 9575 | val = get_param(cmd, "MIH"); | 
|  | 9576 | if (val && atoi(val) > 0) { | 
|  | 9577 | send_resp(dut, conn, SIGMA_ERROR, "errorCode,MIH not " | 
|  | 9578 | "supported"); | 
|  | 9579 | return 0; | 
|  | 9580 | } | 
|  | 9581 |  | 
|  | 9582 | val = get_param(cmd, "L2_TRAFFIC_INSPECT"); | 
|  | 9583 | if (val) { | 
|  | 9584 | dut->ap_l2tif = atoi(val); | 
|  | 9585 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_l2tif %d", | 
|  | 9586 | dut->ap_l2tif); | 
|  | 9587 | } | 
|  | 9588 |  | 
|  | 9589 | val = get_param(cmd, "BCST_UNCST"); | 
|  | 9590 | if (val) { | 
|  | 9591 | send_resp(dut, conn, SIGMA_ERROR, | 
|  | 9592 | "errorCode,BCST_UNCST not yet supported"); | 
|  | 9593 | return 0; | 
|  | 9594 | } | 
|  | 9595 |  | 
|  | 9596 | val = get_param(cmd, "PLMN_MCC"); | 
|  | 9597 | if (val) { | 
|  | 9598 | char mcc[100], *start, *end; | 
|  | 9599 | int i = 0; | 
|  | 9600 | if (strlen(val) >= sizeof(mcc)) { | 
|  | 9601 | send_resp(dut, conn, SIGMA_ERROR, | 
|  | 9602 | "errorCode,PLMN_MCC too long"); | 
|  | 9603 | return 0; | 
|  | 9604 | } | 
| Peng Xu | b8fc5cc | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 9605 | strlcpy(mcc, val, sizeof(mcc)); | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9606 | start = mcc; | 
|  | 9607 | while ((end = strchr(start, ';'))) { | 
|  | 9608 | /* process all except the last */ | 
|  | 9609 | *end = '\0'; | 
|  | 9610 | if (strlen(start) != 3) { | 
|  | 9611 | send_resp(dut, conn, SIGMA_ERROR, | 
|  | 9612 | "errorCode,Invalid PLMN_MCC"); | 
|  | 9613 | return 0; | 
|  | 9614 | } | 
|  | 9615 | snprintf(dut->ap_plmn_mcc[i], | 
|  | 9616 | sizeof(dut->ap_plmn_mcc[i]), "%s", start); | 
|  | 9617 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_plmn_mcc %s", | 
|  | 9618 | dut->ap_plmn_mcc[i]); | 
|  | 9619 | i++; | 
|  | 9620 | start = end + 1; | 
|  | 9621 | *end = ';'; | 
|  | 9622 | } | 
|  | 9623 | if (strlen(start) != 3) { | 
|  | 9624 | send_resp(dut, conn, SIGMA_ERROR, | 
|  | 9625 | "errorCode,Invalid PLMN_MCC"); | 
|  | 9626 | return 0; | 
|  | 9627 | } | 
|  | 9628 | /* process last or only one */ | 
|  | 9629 | snprintf(dut->ap_plmn_mcc[i], | 
|  | 9630 | sizeof(dut->ap_plmn_mcc[i]), "%s", start); | 
|  | 9631 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_plmn_mcc %s", | 
|  | 9632 | dut->ap_plmn_mcc[i]); | 
|  | 9633 | } | 
|  | 9634 |  | 
|  | 9635 | val = get_param(cmd, "PLMN_MNC"); | 
|  | 9636 | if (val) { | 
|  | 9637 | char mnc[100], *start, *end; | 
|  | 9638 | int i = 0; | 
|  | 9639 | if (strlen(val) >= sizeof(mnc)) { | 
|  | 9640 | send_resp(dut, conn, SIGMA_ERROR, | 
|  | 9641 | "errorCode,PLMN_MNC too long"); | 
|  | 9642 | return 0; | 
|  | 9643 | } | 
| Peng Xu | b8fc5cc | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 9644 | strlcpy(mnc, val, sizeof(mnc)); | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9645 | start = mnc; | 
|  | 9646 | while ((end = strchr(start, ';'))) { | 
|  | 9647 | *end = '\0'; | 
|  | 9648 | if (strlen(start) != 2 && strlen(start) != 3) { | 
|  | 9649 | send_resp(dut, conn, SIGMA_ERROR, | 
|  | 9650 | "errorCode,Invalid PLMN_MNC"); | 
|  | 9651 | return 0; | 
|  | 9652 | } | 
|  | 9653 | snprintf(dut->ap_plmn_mnc[i], | 
|  | 9654 | sizeof(dut->ap_plmn_mnc[i]), "%s", start); | 
|  | 9655 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_plmn_mnc %s", | 
|  | 9656 | dut->ap_plmn_mnc[i]); | 
|  | 9657 | i++; | 
|  | 9658 | start = end + 1; | 
|  | 9659 | *end = ';'; | 
|  | 9660 | } | 
|  | 9661 | if (strlen(start) != 2 && strlen(start) != 3) { | 
|  | 9662 | send_resp(dut, conn, SIGMA_ERROR, | 
|  | 9663 | "errorCode,Invalid PLMN_MNC"); | 
|  | 9664 | return 0; | 
|  | 9665 | } | 
|  | 9666 | snprintf(dut->ap_plmn_mnc[i], | 
|  | 9667 | sizeof(dut->ap_plmn_mnc[i]), "%s", start); | 
|  | 9668 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_plmn_mnc %s", | 
|  | 9669 | dut->ap_plmn_mnc[i]); | 
|  | 9670 | } | 
|  | 9671 |  | 
|  | 9672 | val = get_param(cmd, "PROXY_ARP"); | 
|  | 9673 | if (val) { | 
|  | 9674 | dut->ap_proxy_arp = atoi(val); | 
|  | 9675 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_proxy_arp %d", | 
|  | 9676 | dut->ap_proxy_arp); | 
|  | 9677 | } | 
|  | 9678 |  | 
|  | 9679 | val = get_param(cmd, "WAN_METRICS"); | 
|  | 9680 | if (val) { | 
|  | 9681 | dut->ap_wan_metrics = atoi(val); | 
|  | 9682 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_wan_metrics %d", | 
|  | 9683 | dut->ap_wan_metrics); | 
|  | 9684 | } | 
|  | 9685 |  | 
|  | 9686 | val = get_param(cmd, "CONN_CAP"); | 
|  | 9687 | if (val) { | 
|  | 9688 | dut->ap_conn_capab = atoi(val); | 
|  | 9689 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_conn_capab %d", | 
|  | 9690 | dut->ap_conn_capab); | 
|  | 9691 | } | 
|  | 9692 |  | 
|  | 9693 | val = get_param(cmd, "IP_ADD_TYPE_AVAIL"); | 
|  | 9694 | if (val) { | 
|  | 9695 | dut->ap_ip_addr_type_avail = atoi(val); | 
|  | 9696 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_ip_addr_type_avail %d", | 
|  | 9697 | dut->ap_ip_addr_type_avail); | 
|  | 9698 | } | 
|  | 9699 |  | 
|  | 9700 | val = get_param(cmd, "NET_AUTH_TYPE"); | 
|  | 9701 | if (val) { | 
|  | 9702 | dut->ap_net_auth_type = atoi(val); | 
|  | 9703 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_net_auth_type %d", | 
|  | 9704 | dut->ap_net_auth_type); | 
|  | 9705 | } | 
|  | 9706 |  | 
|  | 9707 | val = get_param(cmd, "OP_CLASS"); | 
|  | 9708 | if (val == NULL) | 
|  | 9709 | val = get_param(cmd, "OPER_CLASS"); | 
|  | 9710 | if (val) { | 
|  | 9711 | dut->ap_oper_class = atoi(val); | 
|  | 9712 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_oper_class %d", | 
|  | 9713 | dut->ap_oper_class); | 
|  | 9714 | } | 
|  | 9715 |  | 
|  | 9716 | val = get_param(cmd, "OSU_PROVIDER_LIST"); | 
|  | 9717 | if (val) { | 
|  | 9718 | dut->ap_osu_provider_list = atoi(val); | 
|  | 9719 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_osu_provider_list %d", | 
|  | 9720 | dut->ap_osu_provider_list); | 
|  | 9721 | } | 
|  | 9722 |  | 
| Jouni Malinen | 93a837f | 2018-11-01 17:09:22 +0200 | [diff] [blame] | 9723 | val = get_param(cmd, "OSU_PROVIDER_NAI_LIST"); | 
|  | 9724 | if (val) { | 
|  | 9725 | dut->ap_osu_provider_nai_list = atoi(val); | 
|  | 9726 | sigma_dut_print(dut, DUT_MSG_INFO, | 
|  | 9727 | "ap_osu_provider_nai_list %d", | 
|  | 9728 | dut->ap_osu_provider_nai_list); | 
|  | 9729 | } | 
|  | 9730 |  | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9731 | val = get_param(cmd, "OSU_SERVER_URI"); | 
|  | 9732 | if (val) { | 
|  | 9733 | i = 0; | 
|  | 9734 | do { | 
|  | 9735 | int len; | 
|  | 9736 | const char *uri = val; | 
|  | 9737 | val = strchr(val, ' '); | 
|  | 9738 | len = val ? (val++ - uri) : (int) strlen(uri); | 
|  | 9739 | if (len > 0 && len < 256) { | 
|  | 9740 | memcpy(dut->ap_osu_server_uri[i], uri, len); | 
|  | 9741 | dut->ap_osu_server_uri[i][len] = '\0'; | 
|  | 9742 | sigma_dut_print(dut, DUT_MSG_INFO, | 
|  | 9743 | "ap_osu_server_uri[%d] %s", i, | 
|  | 9744 | dut->ap_osu_server_uri[i]); | 
|  | 9745 | } | 
|  | 9746 | } while (val && ++i < 10); | 
|  | 9747 | } | 
|  | 9748 |  | 
|  | 9749 | val = get_param(cmd, "OSU_METHOD"); | 
|  | 9750 | if (val) { | 
|  | 9751 | i = 0; | 
|  | 9752 | do { | 
|  | 9753 | int len; | 
|  | 9754 | const char *method = val; | 
|  | 9755 | val = strchr(val, ' '); | 
|  | 9756 | len = val ? (val++ - method) : (int) strlen(method); | 
|  | 9757 | if (len > 0) { | 
|  | 9758 | if (strncasecmp(method, "SOAP", len) == 0) | 
|  | 9759 | dut->ap_osu_method[i] = 1; | 
|  | 9760 | else if (strncasecmp(method, "OMADM", len) == 0) | 
|  | 9761 | dut->ap_osu_method[i] = 0; | 
|  | 9762 | else | 
|  | 9763 | return -2; | 
|  | 9764 | } | 
|  | 9765 | } while (val && ++i < 10); | 
|  | 9766 | } | 
|  | 9767 |  | 
|  | 9768 | val = get_param(cmd, "OSU_SSID"); | 
|  | 9769 | if (val) { | 
|  | 9770 | if (strlen(val) > 0 && strlen(val) <= 32) { | 
| Peng Xu | b8fc5cc | 2017-05-10 17:27:28 -0700 | [diff] [blame] | 9771 | strlcpy(dut->ap_osu_ssid, val, | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9772 | sizeof(dut->ap_osu_ssid)); | 
|  | 9773 | sigma_dut_print(dut, DUT_MSG_INFO, | 
|  | 9774 | "ap_osu_ssid %s", | 
|  | 9775 | dut->ap_osu_ssid); | 
|  | 9776 | } | 
|  | 9777 | } | 
|  | 9778 |  | 
|  | 9779 | val = get_param(cmd, "OSU_ICON_TAG"); | 
|  | 9780 | if (val) | 
|  | 9781 | dut->ap_osu_icon_tag = atoi(val); | 
|  | 9782 |  | 
|  | 9783 | val = get_param(cmd, "QoS_MAP_SET"); | 
|  | 9784 | if (val) { | 
|  | 9785 | dut->ap_qos_map_set = atoi(val); | 
|  | 9786 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_qos_map_set %d", | 
|  | 9787 | dut->ap_qos_map_set); | 
|  | 9788 | } | 
|  | 9789 |  | 
|  | 9790 | val = get_param(cmd, "BSS_LOAD"); | 
|  | 9791 | if (val) { | 
|  | 9792 | dut->ap_bss_load = atoi(val); | 
|  | 9793 | sigma_dut_print(dut, DUT_MSG_INFO, "ap_bss_load %d", | 
|  | 9794 | dut->ap_bss_load); | 
|  | 9795 | } | 
|  | 9796 |  | 
| Jouni Malinen | 54a89b0 | 2018-05-01 00:16:26 +0300 | [diff] [blame] | 9797 | val = get_param(cmd, "Venue_URL"); | 
|  | 9798 | if (val) | 
|  | 9799 | dut->ap_venue_url = atoi(val); | 
|  | 9800 |  | 
| Jouni Malinen | f7ff42b | 2018-05-01 00:21:56 +0300 | [diff] [blame] | 9801 | val = get_param(cmd, "Advice_of_Charge"); | 
|  | 9802 | if (val) | 
|  | 9803 | dut->ap_advice_of_charge = atoi(val); | 
|  | 9804 |  | 
| Jouni Malinen | ac10453 | 2018-05-01 00:27:37 +0300 | [diff] [blame] | 9805 | val = get_param(cmd, "Operator_Icon_Metadata"); | 
|  | 9806 | if (val) | 
|  | 9807 | dut->ap_oper_icon_metadata = atoi(val); | 
|  | 9808 |  | 
| Jouni Malinen | ac36714 | 2018-05-01 00:32:24 +0300 | [diff] [blame] | 9809 | val = get_param(cmd, "TnC_File_Name"); | 
|  | 9810 | if (val) | 
|  | 9811 | dut->ap_tnc_file_name = atoi(val); | 
|  | 9812 |  | 
|  | 9813 | val = get_param(cmd, "TnC_File_Time_Stamp"); | 
|  | 9814 | if (val) | 
|  | 9815 | dut->ap_tnc_time_stamp = strtol(val, NULL, 10); | 
|  | 9816 |  | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 9817 | return 1; | 
|  | 9818 | } | 
|  | 9819 |  | 
|  | 9820 |  | 
|  | 9821 | void nfc_status(struct sigma_dut *dut, const char *state, const char *oper) | 
|  | 9822 | { | 
|  | 9823 | char buf[100]; | 
|  | 9824 |  | 
|  | 9825 | if (!file_exists("nfc-status")) | 
|  | 9826 | return; | 
|  | 9827 |  | 
|  | 9828 | snprintf(buf, sizeof(buf), "./nfc-status %s %s", state, oper); | 
|  | 9829 | run_system(dut, buf); | 
|  | 9830 | } | 
|  | 9831 |  | 
|  | 9832 |  | 
|  | 9833 | static int run_nfc_command(struct sigma_dut *dut, const char *cmd, | 
|  | 9834 | const char *info) | 
|  | 9835 | { | 
|  | 9836 | int res; | 
|  | 9837 |  | 
|  | 9838 | printf("\n\n\n=====[ NFC operation ]=========================\n\n"); | 
|  | 9839 | printf("%s\n\n", info); | 
|  | 9840 |  | 
|  | 9841 | nfc_status(dut, "START", info); | 
|  | 9842 | res = run_system(dut, cmd); | 
|  | 9843 | nfc_status(dut, res ? "FAIL" : "SUCCESS", info); | 
|  | 9844 | if (res) { | 
|  | 9845 | sigma_dut_print(dut, DUT_MSG_INFO, "Failed to run '%s': %d", | 
|  | 9846 | cmd, res); | 
|  | 9847 | return res; | 
|  | 9848 | } | 
|  | 9849 |  | 
|  | 9850 | return 0; | 
|  | 9851 | } | 
|  | 9852 |  | 
|  | 9853 |  | 
|  | 9854 | static int ap_nfc_write_config_token(struct sigma_dut *dut, | 
|  | 9855 | struct sigma_conn *conn, | 
|  | 9856 | struct sigma_cmd *cmd) | 
|  | 9857 | { | 
|  | 9858 | int res; | 
|  | 9859 | char buf[300]; | 
|  | 9860 |  | 
|  | 9861 | run_system(dut, "killall wps-ap-nfc.py"); | 
|  | 9862 | unlink("nfc-success"); | 
|  | 9863 | snprintf(buf, sizeof(buf), | 
|  | 9864 | "./wps-ap-nfc.py --no-wait %s%s --success nfc-success write-config", | 
|  | 9865 | dut->summary_log ? "--summary " : "", | 
|  | 9866 | dut->summary_log ? dut->summary_log : ""); | 
|  | 9867 | res = run_nfc_command(dut, buf, | 
|  | 9868 | "Touch NFC Tag to write WPS configuration token"); | 
|  | 9869 | if (res || !file_exists("nfc-success")) { | 
|  | 9870 | send_resp(dut, conn, SIGMA_ERROR, | 
|  | 9871 | "ErrorCode,Failed to write tag"); | 
|  | 9872 | return 0; | 
|  | 9873 | } | 
|  | 9874 |  | 
|  | 9875 | return 1; | 
|  | 9876 | } | 
|  | 9877 |  | 
|  | 9878 |  | 
|  | 9879 | static int ap_nfc_wps_read_passwd(struct sigma_dut *dut, | 
|  | 9880 | struct sigma_conn *conn, | 
|  | 9881 | struct sigma_cmd *cmd) | 
|  | 9882 | { | 
|  | 9883 | int res; | 
|  | 9884 | char buf[300]; | 
|  | 9885 |  | 
|  | 9886 | run_system(dut, "killall wps-ap-nfc.py"); | 
|  | 9887 |  | 
|  | 9888 | unlink("nfc-success"); | 
|  | 9889 | snprintf(buf, sizeof(buf), | 
|  | 9890 | "./wps-ap-nfc.py -1 --no-wait %s%s --success nfc-success", | 
|  | 9891 | dut->summary_log ? "--summary " : "", | 
|  | 9892 | dut->summary_log ? dut->summary_log : ""); | 
|  | 9893 | res = run_nfc_command(dut, buf, "Touch NFC Tag to read it"); | 
|  | 9894 | if (res || !file_exists("nfc-success")) { | 
|  | 9895 | send_resp(dut, conn, SIGMA_ERROR, | 
|  | 9896 | "ErrorCode,Failed to read tag"); | 
|  | 9897 | return 0; | 
|  | 9898 | } | 
|  | 9899 |  | 
|  | 9900 | return 1; | 
|  | 9901 | } | 
|  | 9902 |  | 
|  | 9903 |  | 
|  | 9904 | static int ap_nfc_write_password_token(struct sigma_dut *dut, | 
|  | 9905 | struct sigma_conn *conn, | 
|  | 9906 | struct sigma_cmd *cmd) | 
|  | 9907 | { | 
|  | 9908 | int res; | 
|  | 9909 | char buf[300]; | 
|  | 9910 |  | 
|  | 9911 | run_system(dut, "killall wps-ap-nfc.py"); | 
|  | 9912 | unlink("nfc-success"); | 
|  | 9913 | snprintf(buf, sizeof(buf), | 
|  | 9914 | "./wps-ap-nfc.py --no-wait %s%s --success nfc-success write-password", | 
|  | 9915 | dut->summary_log ? "--summary " : "", | 
|  | 9916 | dut->summary_log ? dut->summary_log : ""); | 
|  | 9917 | res = run_nfc_command(dut, buf, | 
|  | 9918 | "Touch NFC Tag to write WPS password token"); | 
|  | 9919 | if (res || !file_exists("nfc-success")) { | 
|  | 9920 | send_resp(dut, conn, SIGMA_ERROR, | 
|  | 9921 | "ErrorCode,Failed to write tag"); | 
|  | 9922 | return 0; | 
|  | 9923 | } | 
|  | 9924 |  | 
|  | 9925 | if (run_hostapd_cli(dut, "wps_nfc_token enable") != 0) { | 
|  | 9926 | send_resp(dut, conn, SIGMA_ERROR, | 
|  | 9927 | "ErrorCode,Failed to enable NFC password token"); | 
|  | 9928 | return 0; | 
|  | 9929 | } | 
|  | 9930 |  | 
|  | 9931 | return 1; | 
|  | 9932 | } | 
|  | 9933 |  | 
|  | 9934 |  | 
|  | 9935 | static int ap_nfc_wps_connection_handover(struct sigma_dut *dut, | 
|  | 9936 | struct sigma_conn *conn, | 
|  | 9937 | struct sigma_cmd *cmd) | 
|  | 9938 | { | 
|  | 9939 | int res; | 
|  | 9940 | char buf[300]; | 
|  | 9941 |  | 
|  | 9942 | run_system(dut, "killall wps-ap-nfc.py"); | 
|  | 9943 | unlink("nfc-success"); | 
|  | 9944 | snprintf(buf, sizeof(buf), | 
|  | 9945 | "./wps-ap-nfc.py -1 --no-wait %s%s --success nfc-success", | 
|  | 9946 | dut->summary_log ? "--summary " : "", | 
|  | 9947 | dut->summary_log ? dut->summary_log : ""); | 
|  | 9948 | res = run_nfc_command(dut, buf, | 
|  | 9949 | "Touch NFC Device to respond to WPS connection handover"); | 
|  | 9950 | if (res) { | 
|  | 9951 | send_resp(dut, conn, SIGMA_ERROR, | 
|  | 9952 | "ErrorCode,Failed to enable NFC for connection " | 
|  | 9953 | "handover"); | 
|  | 9954 | return 0; | 
|  | 9955 | } | 
|  | 9956 | if (!file_exists("nfc-success")) { | 
|  | 9957 | send_resp(dut, conn, SIGMA_ERROR, | 
|  | 9958 | "ErrorCode,Failed to complete NFC connection handover"); | 
|  | 9959 | return 0; | 
|  | 9960 | } | 
|  | 9961 |  | 
|  | 9962 | return 1; | 
|  | 9963 | } | 
|  | 9964 |  | 
|  | 9965 |  | 
|  | 9966 | static int cmd_ap_nfc_action(struct sigma_dut *dut, struct sigma_conn *conn, | 
|  | 9967 | struct sigma_cmd *cmd) | 
|  | 9968 | { | 
|  | 9969 | /* const char *name = get_param(cmd, "Name"); */ | 
|  | 9970 | /* const char *intf = get_param(cmd, "Interface"); */ | 
|  | 9971 | const char *oper = get_param(cmd, "Operation"); | 
|  | 9972 |  | 
|  | 9973 | if (oper == NULL) | 
|  | 9974 | return -1; | 
|  | 9975 |  | 
|  | 9976 | if (strcasecmp(oper, "WRITE_CONFIG") == 0) | 
|  | 9977 | return ap_nfc_write_config_token(dut, conn, cmd); | 
|  | 9978 | if (strcasecmp(oper, "WRITE_PASSWD") == 0) | 
|  | 9979 | return ap_nfc_write_password_token(dut, conn, cmd); | 
|  | 9980 | if (strcasecmp(oper, "WPS_READ_PASSWD") == 0) | 
|  | 9981 | return ap_nfc_wps_read_passwd(dut, conn, cmd); | 
|  | 9982 | if (strcasecmp(oper, "WPS_CONN_HNDOVR") == 0) | 
|  | 9983 | return ap_nfc_wps_connection_handover(dut, conn, cmd); | 
|  | 9984 |  | 
|  | 9985 | send_resp(dut, conn, SIGMA_ERROR, "ErrorCode,Unsupported operation"); | 
|  | 9986 | return 0; | 
|  | 9987 | } | 
|  | 9988 |  | 
|  | 9989 |  | 
|  | 9990 | static int cmd_ap_wps_read_pin(struct sigma_dut *dut, struct sigma_conn *conn, | 
|  | 9991 | struct sigma_cmd *cmd) | 
|  | 9992 | { | 
|  | 9993 | char *pin = "12345670"; /* TODO: use random PIN */ | 
|  | 9994 | char resp[100]; | 
|  | 9995 |  | 
|  | 9996 | snprintf(resp, sizeof(resp), "PIN,%s", pin); | 
|  | 9997 | send_resp(dut, conn, SIGMA_COMPLETE, resp); | 
|  | 9998 |  | 
|  | 9999 | return 0; | 
|  | 10000 | } | 
|  | 10001 |  | 
|  | 10002 |  | 
| Alexei Avshalom Lazar | 6427969 | 2018-12-23 16:49:49 +0200 | [diff] [blame] | 10003 | static int cmd_ap_wps_enter_pin(struct sigma_dut *dut, struct sigma_conn *conn, | 
|  | 10004 | struct sigma_cmd *cmd) | 
|  | 10005 | { | 
|  | 10006 | const char *pin = get_param(cmd, "PIN"); | 
|  | 10007 | char wps_pin[11]; | 
|  | 10008 |  | 
|  | 10009 | if (!pin) | 
|  | 10010 | return -1; | 
|  | 10011 |  | 
|  | 10012 | sigma_dut_print(dut, DUT_MSG_DEBUG, | 
|  | 10013 | "Authorize a client to join with WPS PIN %s", pin); | 
|  | 10014 |  | 
|  | 10015 | strlcpy(wps_pin, pin, sizeof(wps_pin)); | 
|  | 10016 | /* we need to tolerate extra '-' characters entered */ | 
|  | 10017 | str_remove_chars(wps_pin, '-'); | 
|  | 10018 | strlcpy(dut->wps_pin, wps_pin, sizeof(dut->wps_pin)); | 
|  | 10019 | dut->wps_method = WFA_CS_WPS_PIN_KEYPAD; | 
|  | 10020 |  | 
|  | 10021 | return 1; | 
|  | 10022 | } | 
|  | 10023 |  | 
|  | 10024 |  | 
|  | 10025 | static int cmd_ap_wps_set_pbc(struct sigma_dut *dut, struct sigma_conn *conn, | 
|  | 10026 | struct sigma_cmd *cmd) | 
|  | 10027 | { | 
|  | 10028 | sigma_dut_print(dut, DUT_MSG_DEBUG, | 
|  | 10029 | "Selecting the push button configuration method"); | 
|  | 10030 |  | 
|  | 10031 | dut->wps_method = WFA_CS_WPS_PBC; | 
|  | 10032 |  | 
|  | 10033 | return 1; | 
|  | 10034 | } | 
|  | 10035 |  | 
|  | 10036 |  | 
| Alexei Avshalom Lazar | 0c1d82d | 2018-12-23 17:02:42 +0200 | [diff] [blame] | 10037 | static int cmd_ap_get_parameter(struct sigma_dut *dut, struct sigma_conn *conn, | 
|  | 10038 | struct sigma_cmd *cmd) | 
|  | 10039 | { | 
|  | 10040 | char value[256], resp[512]; | 
|  | 10041 | const char *param = get_param(cmd, "parameter"); | 
|  | 10042 | const char *ifname = get_param(cmd, "Interface"); | 
|  | 10043 |  | 
|  | 10044 | if (!ifname) | 
|  | 10045 | ifname = get_main_ifname(); | 
|  | 10046 |  | 
|  | 10047 | if (!param) { | 
|  | 10048 | send_resp(dut, conn, SIGMA_ERROR, | 
|  | 10049 | "ErrorCode,Parameter not specified"); | 
|  | 10050 | return 0; | 
|  | 10051 | } | 
|  | 10052 |  | 
|  | 10053 | if (strcasecmp(param, "SSID") == 0) { | 
|  | 10054 | if (get_hapd_config(ifname, "ssid", value, sizeof(value))) { | 
|  | 10055 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 10056 | "Failed to get SSID"); | 
|  | 10057 | return -2; | 
|  | 10058 | } | 
|  | 10059 | snprintf(resp, sizeof(resp), "SSID,%s", value); | 
|  | 10060 | } else if (strcasecmp(param, "PSK") == 0) { | 
|  | 10061 | if (get_hapd_config(ifname, "passphrase", value, | 
|  | 10062 | sizeof(value))) { | 
|  | 10063 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 10064 | "Failed to get PSK"); | 
|  | 10065 | return -2; | 
|  | 10066 | } | 
|  | 10067 | snprintf(resp, sizeof(resp), "PSK,%s", value); | 
|  | 10068 | } else { | 
|  | 10069 | send_resp(dut, conn, SIGMA_ERROR, | 
|  | 10070 | "ErrorCode,Unsupported parameter"); | 
|  | 10071 | return 0; | 
|  | 10072 | } | 
|  | 10073 |  | 
|  | 10074 | send_resp(dut, conn, SIGMA_COMPLETE, resp); | 
|  | 10075 | return 0; | 
|  | 10076 | } | 
|  | 10077 |  | 
|  | 10078 |  | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 10079 | static int ath_vht_op_mode_notif(struct sigma_dut *dut, const char *ifname, | 
|  | 10080 | const char *val) | 
|  | 10081 | { | 
|  | 10082 | char *token, *result; | 
|  | 10083 | int nss = 0, chwidth = 0; | 
|  | 10084 | char buf[100]; | 
| Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 10085 | char *saveptr; | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 10086 |  | 
|  | 10087 | /* | 
|  | 10088 | * The following commands should be invoked to generate | 
|  | 10089 | * VHT op mode notification | 
|  | 10090 | */ | 
|  | 10091 |  | 
|  | 10092 | /* Extract the NSS info */ | 
|  | 10093 | token = strdup(val); | 
|  | 10094 | if (!token) | 
|  | 10095 | return -1; | 
| Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 10096 | result = strtok_r(token, ";", &saveptr); | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 10097 | if (result) { | 
|  | 10098 | int count = atoi(result); | 
|  | 10099 |  | 
|  | 10100 | /* We do not support NSS > 3 */ | 
|  | 10101 | if (count < 0 || count > 3) { | 
|  | 10102 | free(token); | 
|  | 10103 | return -1; | 
|  | 10104 | } | 
|  | 10105 |  | 
|  | 10106 | /* Convert nss to chainmask */ | 
|  | 10107 | while (count--) | 
|  | 10108 | nss = (nss << 1) | 1; | 
|  | 10109 |  | 
|  | 10110 | snprintf(buf, sizeof(buf), "iwpriv %s rxchainmask %d", | 
|  | 10111 | ifname, nss); | 
|  | 10112 | if (system(buf) != 0) { | 
|  | 10113 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 10114 | "iwpriv wifi1 rxchainmask failed!"); | 
|  | 10115 | } | 
|  | 10116 | } | 
|  | 10117 |  | 
|  | 10118 | /* Extract the Channel width info */ | 
| Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 10119 | result = strtok_r(NULL, ";", &saveptr); | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 10120 | if (result) { | 
|  | 10121 | switch (atoi(result)) { | 
|  | 10122 | case 20: | 
|  | 10123 | chwidth = 0; | 
|  | 10124 | break; | 
|  | 10125 | case 40: | 
|  | 10126 | chwidth = 1; | 
|  | 10127 | break; | 
|  | 10128 | case 80: | 
|  | 10129 | chwidth = 2; | 
|  | 10130 | break; | 
|  | 10131 | case 160: | 
|  | 10132 | chwidth = 3; | 
|  | 10133 | break; | 
|  | 10134 | default: | 
|  | 10135 | chwidth = 2; | 
|  | 10136 | break; | 
|  | 10137 | } | 
|  | 10138 | snprintf(buf, sizeof(buf), "iwpriv %s chwidth %d", | 
|  | 10139 | ifname, chwidth); | 
|  | 10140 | if (system(buf) != 0) { | 
|  | 10141 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 10142 | "iwpriv chwidth failed!"); | 
|  | 10143 | } | 
|  | 10144 | } | 
|  | 10145 |  | 
|  | 10146 | /* Send the opmode notification */ | 
| Sunil Dutt | 27ec7f6 | 2017-09-14 18:22:59 +0300 | [diff] [blame] | 10147 | snprintf(buf, sizeof(buf), "iwpriv %s opmode_notify 1", ifname); | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 10148 | if (system(buf) != 0) { | 
|  | 10149 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 10150 | "iwpriv opmode_notify failed!"); | 
|  | 10151 | } | 
|  | 10152 | free(token); | 
|  | 10153 |  | 
|  | 10154 | return 0; | 
|  | 10155 | } | 
|  | 10156 |  | 
|  | 10157 |  | 
|  | 10158 | static int ath_vht_nss_mcs(struct sigma_dut *dut, const char *ifname, | 
|  | 10159 | const char *val) | 
|  | 10160 | { | 
|  | 10161 | /* String (nss_operating_mode; mcs_operating_mode) */ | 
|  | 10162 | int nss, mcs; | 
|  | 10163 | char *token, *result; | 
|  | 10164 | char buf[100]; | 
| Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 10165 | char *saveptr; | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 10166 |  | 
|  | 10167 | token = strdup(val); | 
|  | 10168 | if (!token) | 
|  | 10169 | return -1; | 
| Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 10170 | result = strtok_r(token, ";", &saveptr); | 
| Pradeep Reddy POTTETI | 41b8c54 | 2016-06-15 16:09:46 +0530 | [diff] [blame] | 10171 | if (!result) { | 
|  | 10172 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 10173 | "VHT NSS not specified"); | 
|  | 10174 | goto end; | 
|  | 10175 | } | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 10176 | if (strcasecmp(result, "def") != 0) { | 
|  | 10177 | nss = atoi(result); | 
|  | 10178 |  | 
|  | 10179 | if (nss == 4) | 
|  | 10180 | ath_disable_txbf(dut, ifname); | 
|  | 10181 |  | 
|  | 10182 | snprintf(buf, sizeof(buf), "iwpriv %s nss %d", ifname, nss); | 
|  | 10183 | if (system(buf) != 0) { | 
|  | 10184 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 10185 | "iwpriv nss failed"); | 
|  | 10186 | } | 
|  | 10187 | } else { | 
|  | 10188 | if (dut->device_type == AP_testbed && dut->ap_sgi80 == 1) { | 
|  | 10189 | snprintf(buf, sizeof(buf), "iwpriv %s nss 1", ifname); | 
|  | 10190 | if (system(buf) != 0) { | 
|  | 10191 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 10192 | "iwpriv nss failed"); | 
|  | 10193 | } | 
|  | 10194 | } | 
|  | 10195 | } | 
|  | 10196 |  | 
| Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 10197 | result = strtok_r(NULL, ";", &saveptr); | 
| Pradeep Reddy POTTETI | 41b8c54 | 2016-06-15 16:09:46 +0530 | [diff] [blame] | 10198 | if (!result) { | 
|  | 10199 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 10200 | "VHT MCS not specified"); | 
|  | 10201 | goto end; | 
|  | 10202 | } | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 10203 | if (strcasecmp(result, "def") == 0) { | 
|  | 10204 | if (dut->device_type == AP_testbed && dut->ap_sgi80 == 1) { | 
|  | 10205 | snprintf(buf, sizeof(buf), "iwpriv %s vhtmcs 7", | 
|  | 10206 | ifname); | 
|  | 10207 | if (system(buf) != 0) { | 
|  | 10208 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 10209 | "iwpriv vhtmcs failed"); | 
|  | 10210 | } | 
|  | 10211 | } else { | 
|  | 10212 | snprintf(buf, sizeof(buf), | 
|  | 10213 | "iwpriv %s set11NRates 0", ifname); | 
|  | 10214 | if (system(buf) != 0) { | 
|  | 10215 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 10216 | "iwpriv set11NRates failed"); | 
|  | 10217 | } | 
|  | 10218 | } | 
|  | 10219 | } else { | 
|  | 10220 | mcs = atoi(result); | 
|  | 10221 | snprintf(buf, sizeof(buf), "iwpriv %s vhtmcs %d", ifname, mcs); | 
|  | 10222 | if (system(buf) != 0) { | 
|  | 10223 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 10224 | "iwpriv vhtmcs failed"); | 
|  | 10225 | } | 
|  | 10226 | } | 
|  | 10227 |  | 
| Pradeep Reddy POTTETI | 41b8c54 | 2016-06-15 16:09:46 +0530 | [diff] [blame] | 10228 | end: | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 10229 | free(token); | 
|  | 10230 | return 0; | 
|  | 10231 | } | 
|  | 10232 |  | 
|  | 10233 |  | 
|  | 10234 | static int ath_vht_chnum_band(struct sigma_dut *dut, const char *ifname, | 
|  | 10235 | const char *val) | 
|  | 10236 | { | 
|  | 10237 | char *token, *result; | 
|  | 10238 | int channel = 36; | 
|  | 10239 | int chwidth = 80; | 
|  | 10240 | char buf[100]; | 
| Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 10241 | char *saveptr; | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 10242 |  | 
|  | 10243 | /* Extract the channel info */ | 
|  | 10244 | token = strdup(val); | 
|  | 10245 | if (!token) | 
|  | 10246 | return -1; | 
| Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 10247 | result = strtok_r(token, ";", &saveptr); | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 10248 | if (result) | 
|  | 10249 | channel = atoi(result); | 
|  | 10250 |  | 
|  | 10251 | /* Extract the channel width info */ | 
| Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 10252 | result = strtok_r(NULL, ";", &saveptr); | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 10253 | if (result) | 
|  | 10254 | chwidth = atoi(result); | 
|  | 10255 |  | 
|  | 10256 | /* Issue the channel switch command */ | 
|  | 10257 | snprintf(buf, sizeof(buf), "iwpriv %s doth_ch_chwidth %d 10 %d", | 
|  | 10258 | ifname, channel, chwidth); | 
|  | 10259 | if (system(buf) != 0) { | 
|  | 10260 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 10261 | "iwpriv doth_ch_chwidth failed!"); | 
|  | 10262 | } | 
|  | 10263 |  | 
|  | 10264 | free(token); | 
|  | 10265 | return 0; | 
|  | 10266 | } | 
|  | 10267 |  | 
|  | 10268 |  | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 10269 | static int ath_ndpa_stainfo_mac(struct sigma_dut *dut, const char *ifname, | 
|  | 10270 | const char *val) | 
|  | 10271 | { | 
|  | 10272 | char buf[80]; | 
|  | 10273 | unsigned char mac_addr[6]; | 
|  | 10274 |  | 
|  | 10275 | if (parse_mac_address(dut, val, mac_addr) < 0) | 
|  | 10276 | return -1; | 
|  | 10277 |  | 
|  | 10278 | snprintf(buf, sizeof(buf), | 
|  | 10279 | "wifitool %s beeliner_fw_test 92 0x%02x%02x%02x%02x", | 
|  | 10280 | ifname, mac_addr[0], mac_addr[1], mac_addr[2], mac_addr[3]); | 
|  | 10281 | run_system(dut, buf); | 
|  | 10282 |  | 
|  | 10283 | snprintf(buf, sizeof(buf), "wifitool %s beeliner_fw_test 93 0x%02x%02x", | 
|  | 10284 | ifname, mac_addr[4], mac_addr[5]); | 
|  | 10285 | run_system(dut, buf); | 
|  | 10286 |  | 
|  | 10287 | snprintf(buf, sizeof(buf), "wifitool %s beeliner_fw_test 94 1", ifname); | 
|  | 10288 | run_system(dut, buf); | 
|  | 10289 |  | 
|  | 10290 | return 0; | 
|  | 10291 | } | 
|  | 10292 |  | 
|  | 10293 |  | 
| priyadharshini gowthaman | e5e2517 | 2015-12-08 14:53:48 -0800 | [diff] [blame] | 10294 | void novap_reset(struct sigma_dut *dut, const char *ifname) | 
| Priyadharshini Gowthaman | 39beafa | 2015-11-09 14:11:25 -0800 | [diff] [blame] | 10295 | { | 
|  | 10296 | char buf[60]; | 
|  | 10297 |  | 
|  | 10298 | snprintf(buf, sizeof(buf), "iwpriv %s novap_reset 1", ifname); | 
|  | 10299 | if (system(buf) != 0) { | 
|  | 10300 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 10301 | "disabling novap reset failed"); | 
|  | 10302 | } | 
|  | 10303 | } | 
|  | 10304 |  | 
|  | 10305 |  | 
| Adil Saeed Musthafa | 6906372 | 2017-04-10 23:13:40 -0700 | [diff] [blame] | 10306 | struct mbo_pref_ap * mbo_find_nebor_ap_entry(struct sigma_dut *dut, | 
|  | 10307 | const uint8_t *mac_addr) | 
| priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 10308 | { | 
| Adil Saeed Musthafa | 6906372 | 2017-04-10 23:13:40 -0700 | [diff] [blame] | 10309 | int i; | 
| priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 10310 |  | 
| Adil Saeed Musthafa | 6906372 | 2017-04-10 23:13:40 -0700 | [diff] [blame] | 10311 | for (i = 0; i < dut->mbo_pref_ap_cnt; i++) { | 
|  | 10312 | if (memcmp(mac_addr, dut->mbo_pref_aps[i].mac_addr, | 
|  | 10313 | ETH_ALEN) == 0) | 
|  | 10314 | return &dut->mbo_pref_aps[i]; | 
|  | 10315 | } | 
|  | 10316 | return NULL; | 
|  | 10317 | } | 
|  | 10318 |  | 
|  | 10319 |  | 
|  | 10320 | static void mbo_add_nebor_entry(struct sigma_dut *dut, const uint8_t *mac_addr, | 
|  | 10321 | int ap_ne_class, int ap_ne_op_ch, | 
|  | 10322 | int ap_ne_pref) | 
|  | 10323 | { | 
|  | 10324 | struct mbo_pref_ap *entry; | 
|  | 10325 | uint8_t self_mac[ETH_ALEN]; | 
|  | 10326 | char ifname[50]; | 
|  | 10327 |  | 
|  | 10328 | get_if_name(dut, ifname, sizeof(ifname), 1); | 
|  | 10329 | get_hwaddr(ifname, self_mac); | 
|  | 10330 |  | 
|  | 10331 | if (memcmp(mac_addr, self_mac, ETH_ALEN) == 0) | 
|  | 10332 | entry = &dut->mbo_self_ap_tuple; | 
|  | 10333 | else | 
|  | 10334 | entry = mbo_find_nebor_ap_entry(dut, mac_addr); | 
|  | 10335 |  | 
|  | 10336 | if (!entry) { | 
|  | 10337 | if (dut->mbo_pref_ap_cnt >= MBO_MAX_PREF_BSSIDS) { | 
|  | 10338 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 10339 | "Nebor AP List is full. Not adding"); | 
|  | 10340 | return; | 
|  | 10341 | } | 
|  | 10342 | entry = &dut->mbo_pref_aps[dut->mbo_pref_ap_cnt]; | 
|  | 10343 | dut->mbo_pref_ap_cnt++; | 
|  | 10344 | memcpy(entry->mac_addr, mac_addr, ETH_ALEN); | 
|  | 10345 | entry->ap_ne_class = -1; | 
|  | 10346 | entry->ap_ne_op_ch = -1; | 
|  | 10347 | entry->ap_ne_pref = -1; | 
|  | 10348 | } | 
|  | 10349 | if (ap_ne_class != -1) | 
|  | 10350 | entry->ap_ne_class = ap_ne_class; | 
|  | 10351 | if (ap_ne_op_ch != -1) | 
|  | 10352 | entry->ap_ne_op_ch = ap_ne_op_ch; | 
|  | 10353 | if (ap_ne_pref != -1) | 
|  | 10354 | entry->ap_ne_pref = ap_ne_pref; | 
|  | 10355 | } | 
|  | 10356 |  | 
|  | 10357 |  | 
|  | 10358 | static int ath_set_nebor_bssid(struct sigma_dut *dut, const char *ifname, | 
|  | 10359 | struct sigma_cmd *cmd) | 
|  | 10360 | { | 
|  | 10361 | unsigned char mac_addr[ETH_ALEN]; | 
|  | 10362 | const char *val; | 
|  | 10363 | /* | 
|  | 10364 | * -1 is invalid value for the following | 
|  | 10365 | *  to differentiate between unset and set values | 
|  | 10366 | *  -1 => implies not set by CAPI | 
|  | 10367 | */ | 
|  | 10368 | int ap_ne_class = -1, ap_ne_op_ch = -1, ap_ne_pref = -1; | 
|  | 10369 | int list_offset = dut->mbo_pref_ap_cnt; | 
|  | 10370 |  | 
|  | 10371 | if (list_offset >= MBO_MAX_PREF_BSSIDS) { | 
|  | 10372 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 10373 | "AP Pref Entry list is full"); | 
|  | 10374 | return -1; | 
|  | 10375 | } | 
|  | 10376 |  | 
|  | 10377 | val = get_param(cmd, "Nebor_Op_Class"); | 
|  | 10378 | if (val) | 
|  | 10379 | ap_ne_class = atoi(val); | 
|  | 10380 |  | 
|  | 10381 | val = get_param(cmd, "Nebor_Op_Ch"); | 
|  | 10382 | if (val) | 
|  | 10383 | ap_ne_op_ch = atoi(val); | 
|  | 10384 |  | 
|  | 10385 | val = get_param(cmd, "Nebor_Pref"); | 
|  | 10386 | if (val) | 
|  | 10387 | ap_ne_pref = atoi(val); | 
|  | 10388 |  | 
|  | 10389 | val = get_param(cmd, "Nebor_BSSID"); | 
|  | 10390 | if (!val || parse_mac_address(dut, val, mac_addr) < 0) | 
| priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 10391 | return -1; | 
|  | 10392 |  | 
| Adil Saeed Musthafa | 6906372 | 2017-04-10 23:13:40 -0700 | [diff] [blame] | 10393 | mbo_add_nebor_entry(dut, mac_addr, ap_ne_class, ap_ne_op_ch, | 
|  | 10394 | ap_ne_pref); | 
|  | 10395 | apply_mbo_pref_ap_list(dut); | 
| priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 10396 | return 0; | 
|  | 10397 | } | 
|  | 10398 |  | 
|  | 10399 |  | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 10400 | static int ath_ap_set_rfeature(struct sigma_dut *dut, struct sigma_conn *conn, | 
|  | 10401 | struct sigma_cmd *cmd) | 
|  | 10402 | { | 
|  | 10403 | const char *val; | 
|  | 10404 | char *ifname; | 
|  | 10405 |  | 
|  | 10406 | ifname = get_main_ifname(); | 
|  | 10407 |  | 
| Priyadharshini Gowthaman | 39beafa | 2015-11-09 14:11:25 -0800 | [diff] [blame] | 10408 | /* Disable vap reset between the commands */ | 
|  | 10409 | novap_reset(dut, ifname); | 
|  | 10410 |  | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 10411 | val = get_param(cmd, "Opt_md_notif_ie"); | 
|  | 10412 | if (val && ath_vht_op_mode_notif(dut, ifname, val) < 0) | 
|  | 10413 | return -1; | 
|  | 10414 |  | 
|  | 10415 | /* TODO: Optional arguments */ | 
|  | 10416 |  | 
|  | 10417 | val = get_param(cmd, "nss_mcs_opt"); | 
|  | 10418 | if (val && ath_vht_nss_mcs(dut, ifname, val) < 0) | 
|  | 10419 | return -1; | 
|  | 10420 |  | 
|  | 10421 | val = get_param(cmd, "chnum_band"); | 
|  | 10422 | if (val && ath_vht_chnum_band(dut, ifname, val) < 0) | 
|  | 10423 | return -1; | 
|  | 10424 |  | 
|  | 10425 | val = get_param(cmd, "RTS_FORCE"); | 
|  | 10426 | if (val) | 
|  | 10427 | ath_config_rts_force(dut, ifname, val); | 
|  | 10428 |  | 
|  | 10429 | val = get_param(cmd, "DYN_BW_SGNL"); | 
|  | 10430 | if (val) | 
|  | 10431 | ath_config_dyn_bw_sig(dut, ifname, val); | 
|  | 10432 |  | 
|  | 10433 | val = get_param(cmd, "CTS_WIDTH"); | 
|  | 10434 | if (val) | 
|  | 10435 | ath_set_cts_width(dut, ifname, val); | 
|  | 10436 |  | 
|  | 10437 | val = get_param(cmd, "Ndpa_stainfo_mac"); | 
|  | 10438 | if (val && ath_ndpa_stainfo_mac(dut, ifname, val) < 0) | 
|  | 10439 | return -1; | 
|  | 10440 |  | 
|  | 10441 | val = get_param(cmd, "txBandwidth"); | 
|  | 10442 | if (val && ath_set_width(dut, conn, ifname, val) < 0) | 
|  | 10443 | return -1; | 
|  | 10444 |  | 
| priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 10445 | val = get_param(cmd, "Assoc_Disallow"); | 
|  | 10446 | if (val) | 
|  | 10447 | ath_set_assoc_disallow(dut, ifname, val); | 
|  | 10448 |  | 
| priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 10449 |  | 
| Adil Saeed Musthafa | 6906372 | 2017-04-10 23:13:40 -0700 | [diff] [blame] | 10450 | ath_set_nebor_bssid(dut, ifname, cmd); | 
| priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 10451 | val = get_param(cmd, "BTMReq_DisAssoc_Imnt"); | 
| priyadharshini gowthaman | 776562e | 2017-12-20 12:33:34 -0800 | [diff] [blame] | 10452 | if (val) { | 
| priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 10453 | dut->ap_btmreq_disassoc_imnt = atoi(val); | 
| priyadharshini gowthaman | 776562e | 2017-12-20 12:33:34 -0800 | [diff] [blame] | 10454 | dut->ap_disassoc_timer = 1000; | 
|  | 10455 | } | 
| priyadharshini gowthaman | b4e05fc | 2016-10-13 15:02:35 -0700 | [diff] [blame] | 10456 |  | 
|  | 10457 | val = get_param(cmd, "BTMReq_Term_Bit"); | 
|  | 10458 | if (val) | 
|  | 10459 | dut->ap_btmreq_term_bit = atoi(val); | 
|  | 10460 |  | 
| Adil Saeed Musthafa | 48c5ab9 | 2017-04-10 23:13:35 -0700 | [diff] [blame] | 10461 | val = get_param(cmd, "Assoc_Delay"); | 
| priyadharshini gowthaman | 776562e | 2017-12-20 12:33:34 -0800 | [diff] [blame] | 10462 | if (val) { | 
|  | 10463 | dut->ap_assoc_delay = 1; | 
| Adil Saeed Musthafa | 48c5ab9 | 2017-04-10 23:13:35 -0700 | [diff] [blame] | 10464 | run_system_wrapper(dut, "iwpriv %s mbo_asoc_ret %s", | 
|  | 10465 | ifname, val); | 
| priyadharshini gowthaman | 776562e | 2017-12-20 12:33:34 -0800 | [diff] [blame] | 10466 | } | 
| Adil Saeed Musthafa | 48c5ab9 | 2017-04-10 23:13:35 -0700 | [diff] [blame] | 10467 |  | 
| Adil Saeed Musthafa | 7d9ae38 | 2017-04-10 23:13:33 -0700 | [diff] [blame] | 10468 | val = get_param(cmd, "Disassoc_Timer"); | 
|  | 10469 | if (val) | 
|  | 10470 | dut->ap_disassoc_timer = atoi(val); | 
|  | 10471 |  | 
|  | 10472 | val = get_param(cmd, "BSS_Term_Duration"); | 
|  | 10473 | if (val) | 
|  | 10474 | dut->ap_btmreq_bss_term_dur = atoi(val); | 
|  | 10475 |  | 
| priyadharshini gowthaman | 94062b5 | 2017-12-20 12:33:34 -0800 | [diff] [blame] | 10476 | val = get_param(cmd, "BSS_Term_TSF"); | 
|  | 10477 | if (val) | 
|  | 10478 | dut->ap_btmreq_bss_term_tsf = atoi(val); | 
|  | 10479 |  | 
| priyadharshini gowthaman | cb22e43 | 2017-12-28 15:23:31 -0800 | [diff] [blame] | 10480 | val = get_param(cmd, "TxPower"); | 
|  | 10481 | if (val) | 
|  | 10482 | ath_set_txpower(dut, ifname, val); | 
|  | 10483 |  | 
|  | 10484 | val = get_param(cmd, "DownlinkAvailCap"); | 
|  | 10485 | if (val) | 
|  | 10486 | dut->ap_dl_availcap = atoi(val); | 
|  | 10487 |  | 
|  | 10488 | val = get_param(cmd, "UplinkAvailCap"); | 
|  | 10489 | if (val) { | 
|  | 10490 | dut->ap_ul_availcap = atoi(val); | 
|  | 10491 | run_system_wrapper(dut, "iwpriv %s oce_wan_mtr %d %d", ifname, | 
|  | 10492 | dut->ap_dl_availcap, dut->ap_ul_availcap); | 
|  | 10493 | } | 
|  | 10494 |  | 
|  | 10495 | val = get_param(cmd, "RSSIthreshold"); | 
|  | 10496 | if (val) { | 
|  | 10497 | int rssithreshold; | 
|  | 10498 |  | 
|  | 10499 | run_system_wrapper(dut, "iwpriv %s oce_asoc_rej 1", ifname); | 
|  | 10500 | rssithreshold = atoi(val); | 
|  | 10501 | run_system_wrapper(dut, "iwpriv %s oce_asoc_rssi %d", ifname, | 
|  | 10502 | rssithreshold); | 
|  | 10503 | } | 
|  | 10504 |  | 
|  | 10505 | val = get_param(cmd, "RetryDelay"); | 
|  | 10506 | if (val) { | 
|  | 10507 | int retrydelay; | 
|  | 10508 |  | 
|  | 10509 | run_system_wrapper(dut, "iwpriv %s oce_asoc_rej 1", ifname); | 
|  | 10510 | retrydelay = atoi(val); | 
|  | 10511 | run_system_wrapper(dut, "iwpriv %s oce_asoc_dly %d", ifname, | 
|  | 10512 | retrydelay); | 
|  | 10513 | } | 
|  | 10514 |  | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 10515 | return 1; | 
|  | 10516 | } | 
|  | 10517 |  | 
|  | 10518 |  | 
| Pradeep Reddy POTTETI | 88fd82c | 2016-03-14 12:20:18 +0530 | [diff] [blame] | 10519 | static int wcn_vht_chnum_band(struct sigma_dut *dut, const char *ifname, | 
|  | 10520 | const char *val) | 
|  | 10521 | { | 
|  | 10522 | char *token, *result; | 
|  | 10523 | int channel = 36; | 
|  | 10524 | char buf[100]; | 
| Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 10525 | char *saveptr; | 
| Pradeep Reddy POTTETI | 88fd82c | 2016-03-14 12:20:18 +0530 | [diff] [blame] | 10526 |  | 
|  | 10527 | /* Extract the channel info */ | 
|  | 10528 | token = strdup(val); | 
|  | 10529 | if (!token) | 
|  | 10530 | return -1; | 
| Pradeep Reddy POTTETI | dbf7d71 | 2016-04-28 18:42:07 +0530 | [diff] [blame] | 10531 | result = strtok_r(token, ";", &saveptr); | 
| Pradeep Reddy POTTETI | 88fd82c | 2016-03-14 12:20:18 +0530 | [diff] [blame] | 10532 | if (result) | 
|  | 10533 | channel = atoi(result); | 
|  | 10534 |  | 
|  | 10535 | /* Issue the channel switch command */ | 
|  | 10536 | snprintf(buf, sizeof(buf), "iwpriv %s setChanChange %d", | 
|  | 10537 | ifname, channel); | 
|  | 10538 | if (system(buf) != 0) { | 
|  | 10539 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 10540 | "iwpriv setChanChange failed!"); | 
|  | 10541 | } | 
|  | 10542 |  | 
|  | 10543 | free(token); | 
|  | 10544 | return 0; | 
|  | 10545 | } | 
|  | 10546 |  | 
|  | 10547 |  | 
|  | 10548 | static int wcn_ap_set_rfeature(struct sigma_dut *dut, struct sigma_conn *conn, | 
|  | 10549 | struct sigma_cmd *cmd) | 
|  | 10550 | { | 
|  | 10551 | const char *val; | 
|  | 10552 | char *ifname; | 
|  | 10553 |  | 
|  | 10554 | ifname = get_main_ifname(); | 
|  | 10555 |  | 
|  | 10556 | val = get_param(cmd, "chnum_band"); | 
|  | 10557 | if (val && wcn_vht_chnum_band(dut, ifname, val) < 0) | 
|  | 10558 | return -1; | 
|  | 10559 |  | 
|  | 10560 | return 1; | 
|  | 10561 | } | 
|  | 10562 |  | 
|  | 10563 |  | 
| Mohammed Shafi Shajakhan | b53d8f9 | 2017-02-28 09:05:15 +0530 | [diff] [blame] | 10564 | static int mac80211_vht_chnum_band(struct sigma_dut *dut, const char *ifname, | 
|  | 10565 | const char *val) | 
|  | 10566 | { | 
|  | 10567 | char *token, *result; | 
|  | 10568 | int channel = 36, chwidth = 80, center_freq_idx, center_freq, | 
|  | 10569 | channel_freq; | 
|  | 10570 | char buf[100]; | 
|  | 10571 | char *saveptr; | 
|  | 10572 |  | 
|  | 10573 | /* Extract the channel info */ | 
|  | 10574 | token = strdup(val); | 
|  | 10575 | if (!token) | 
|  | 10576 | return -1; | 
|  | 10577 | result = strtok_r(token, ";", &saveptr); | 
|  | 10578 | if (result) | 
|  | 10579 | channel = atoi(result); | 
|  | 10580 |  | 
|  | 10581 | /* Extract the channel width info */ | 
|  | 10582 | result = strtok_r(NULL, ";", &saveptr); | 
|  | 10583 | if (result) | 
|  | 10584 | chwidth = atoi(result); | 
|  | 10585 |  | 
|  | 10586 | center_freq_idx = get_oper_centr_freq_seq_idx(chwidth, channel); | 
|  | 10587 | if (center_freq_idx < 0) { | 
|  | 10588 | free(token); | 
|  | 10589 | return -1; | 
|  | 10590 | } | 
|  | 10591 |  | 
|  | 10592 | center_freq = get_5g_channel_freq(center_freq_idx); | 
|  | 10593 | channel_freq = get_5g_channel_freq(channel); | 
|  | 10594 |  | 
|  | 10595 | /* Issue the channel switch command */ | 
|  | 10596 | snprintf(buf, sizeof(buf), | 
|  | 10597 | " -i %s chan_switch 10 %d sec_channel_offset=1 center_freq1=%d bandwidth=%d blocktx vht", | 
|  | 10598 | ifname, channel_freq, center_freq, chwidth); | 
|  | 10599 | if (run_hostapd_cli(dut,buf) != 0) { | 
|  | 10600 | sigma_dut_print(dut, DUT_MSG_ERROR, | 
|  | 10601 | "hostapd_cli chan_switch failed"); | 
|  | 10602 | } | 
|  | 10603 |  | 
|  | 10604 | free(token); | 
|  | 10605 | return 0; | 
|  | 10606 | } | 
|  | 10607 |  | 
|  | 10608 |  | 
|  | 10609 | static int mac80211_ap_set_rfeature(struct sigma_dut *dut, | 
|  | 10610 | struct sigma_conn *conn, | 
|  | 10611 | struct sigma_cmd *cmd) | 
|  | 10612 | { | 
|  | 10613 | const char *val; | 
|  | 10614 | char *ifname; | 
|  | 10615 |  | 
|  | 10616 | ifname = get_main_ifname(); | 
|  | 10617 | val = get_param(cmd, "chnum_band"); | 
|  | 10618 | if (val && mac80211_vht_chnum_band(dut, ifname, val) < 0) | 
|  | 10619 | return -1; | 
|  | 10620 |  | 
|  | 10621 | return 1; | 
|  | 10622 | } | 
|  | 10623 |  | 
|  | 10624 |  | 
| Alexei Avshalom Lazar | bc180dc | 2018-12-18 16:01:14 +0200 | [diff] [blame] | 10625 | #ifdef __linux__ | 
|  | 10626 | static int wil6210_ap_set_rfeature(struct sigma_dut *dut, | 
|  | 10627 | struct sigma_conn *conn, | 
|  | 10628 | struct sigma_cmd *cmd) | 
|  | 10629 | { | 
|  | 10630 | const char *val; | 
|  | 10631 |  | 
|  | 10632 | val = get_param(cmd, "ExtSchIE"); | 
|  | 10633 | if (val && !strcasecmp(val, "Enable")) { | 
|  | 10634 | struct sigma_ese_alloc allocs[MAX_ESE_ALLOCS]; | 
|  | 10635 | int count = MAX_ESE_ALLOCS; | 
|  | 10636 |  | 
|  | 10637 | if (sta_extract_60g_ese(dut, cmd, allocs, &count)) | 
|  | 10638 | return -1; | 
|  | 10639 | if (wil6210_set_ese(dut, count, allocs)) | 
|  | 10640 | return -1; | 
|  | 10641 | return 1; | 
|  | 10642 | } | 
|  | 10643 |  | 
|  | 10644 | send_resp(dut, conn, SIGMA_ERROR, | 
|  | 10645 | "errorCode,Invalid ap_set_rfeature(60G)"); | 
|  | 10646 | return 0; | 
|  | 10647 | } | 
|  | 10648 | #endif /* __linux__ */ | 
|  | 10649 |  | 
|  | 10650 |  | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 10651 | static int cmd_ap_set_rfeature(struct sigma_dut *dut, struct sigma_conn *conn, | 
|  | 10652 | struct sigma_cmd *cmd) | 
|  | 10653 | { | 
|  | 10654 | /* const char *name = get_param(cmd, "NAME"); */ | 
|  | 10655 | /* const char *type = get_param(cmd, "Type"); */ | 
|  | 10656 |  | 
|  | 10657 | switch (get_driver_type()) { | 
|  | 10658 | case DRIVER_ATHEROS: | 
|  | 10659 | return ath_ap_set_rfeature(dut, conn, cmd); | 
|  | 10660 | case DRIVER_OPENWRT: | 
|  | 10661 | switch (get_openwrt_driver_type()) { | 
|  | 10662 | case OPENWRT_DRIVER_ATHEROS: | 
|  | 10663 | return ath_ap_set_rfeature(dut, conn, cmd); | 
|  | 10664 | default: | 
|  | 10665 | send_resp(dut, conn, SIGMA_ERROR, | 
|  | 10666 | "errorCode,Unsupported ap_set_rfeature with the current openwrt driver"); | 
|  | 10667 | return 0; | 
|  | 10668 | } | 
| Sreelakshmi Konamki | 0e4fcf9 | 2016-04-26 19:55:01 +0530 | [diff] [blame] | 10669 | case DRIVER_LINUX_WCN: | 
| Pradeep Reddy POTTETI | 88fd82c | 2016-03-14 12:20:18 +0530 | [diff] [blame] | 10670 | case DRIVER_WCN: | 
|  | 10671 | return wcn_ap_set_rfeature(dut, conn, cmd); | 
| Mohammed Shafi Shajakhan | b53d8f9 | 2017-02-28 09:05:15 +0530 | [diff] [blame] | 10672 | case DRIVER_MAC80211: | 
|  | 10673 | return mac80211_ap_set_rfeature(dut, conn, cmd); | 
| Alexei Avshalom Lazar | bc180dc | 2018-12-18 16:01:14 +0200 | [diff] [blame] | 10674 | #ifdef __linux__ | 
|  | 10675 | case DRIVER_WIL6210: | 
|  | 10676 | return wil6210_ap_set_rfeature(dut, conn, cmd); | 
|  | 10677 | #endif /* __linux__ */ | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 10678 | default: | 
|  | 10679 | send_resp(dut, conn, SIGMA_ERROR, | 
|  | 10680 | "errorCode,Unsupported ap_set_rfeature with the current driver"); | 
|  | 10681 | return 0; | 
|  | 10682 | } | 
|  | 10683 | } | 
|  | 10684 |  | 
|  | 10685 |  | 
|  | 10686 | static int cmd_accesspoint(struct sigma_dut *dut, struct sigma_conn *conn, | 
|  | 10687 | struct sigma_cmd *cmd) | 
|  | 10688 | { | 
|  | 10689 | /* const char *name = get_param(cmd, "NAME"); */ | 
|  | 10690 | return 1; | 
|  | 10691 | } | 
|  | 10692 |  | 
|  | 10693 |  | 
| priyadharshini gowthaman | 9149afc | 2018-01-15 13:40:18 -0800 | [diff] [blame] | 10694 | static int cmd_ap_preset_testparameters(struct sigma_dut *dut, | 
|  | 10695 | struct sigma_conn *conn, | 
|  | 10696 | struct sigma_cmd *cmd) | 
|  | 10697 | { | 
|  | 10698 | const char *val; | 
|  | 10699 |  | 
|  | 10700 | val = get_param(cmd, "Oper_Chn"); | 
|  | 10701 | if (val) { | 
|  | 10702 | dut->ap_oper_chn = 1; | 
|  | 10703 | dut->ap_channel = atoi(val); | 
|  | 10704 | } | 
|  | 10705 |  | 
|  | 10706 | return 1; | 
|  | 10707 | } | 
|  | 10708 |  | 
|  | 10709 |  | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 10710 | void ap_register_cmds(void) | 
|  | 10711 | { | 
|  | 10712 | sigma_dut_reg_cmd("ap_ca_version", NULL, cmd_ap_ca_version); | 
|  | 10713 | sigma_dut_reg_cmd("ap_set_wireless", NULL, cmd_ap_set_wireless); | 
|  | 10714 | sigma_dut_reg_cmd("ap_send_addba_req", NULL, cmd_ap_send_addba_req); | 
|  | 10715 | sigma_dut_reg_cmd("ap_set_11n_wireless", NULL, cmd_ap_set_wireless); | 
|  | 10716 | sigma_dut_reg_cmd("ap_set_11n", NULL, cmd_ap_set_wireless); | 
|  | 10717 | 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] | 10718 | sigma_dut_reg_cmd("ap_set_11h", NULL, cmd_ap_set_wireless); | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 10719 | sigma_dut_reg_cmd("ap_set_security", NULL, cmd_ap_set_security); | 
|  | 10720 | sigma_dut_reg_cmd("ap_set_apqos", NULL, cmd_ap_set_apqos); | 
|  | 10721 | sigma_dut_reg_cmd("ap_set_staqos", NULL, cmd_ap_set_staqos); | 
|  | 10722 | sigma_dut_reg_cmd("ap_set_radius", NULL, cmd_ap_set_radius); | 
|  | 10723 | sigma_dut_reg_cmd("ap_reboot", NULL, cmd_ap_reboot); | 
|  | 10724 | sigma_dut_reg_cmd("ap_config_commit", NULL, cmd_ap_config_commit); | 
|  | 10725 | sigma_dut_reg_cmd("ap_reset_default", NULL, cmd_ap_reset_default); | 
|  | 10726 | sigma_dut_reg_cmd("ap_get_info", NULL, cmd_ap_get_info); | 
|  | 10727 | sigma_dut_reg_cmd("ap_deauth_sta", NULL, cmd_ap_deauth_sta); | 
|  | 10728 | sigma_dut_reg_cmd("ap_send_frame", NULL, cmd_ap_send_frame); | 
|  | 10729 | sigma_dut_reg_cmd("ap_get_mac_address", NULL, cmd_ap_get_mac_address); | 
|  | 10730 | sigma_dut_reg_cmd("ap_set_pmf", NULL, cmd_ap_set_pmf); | 
|  | 10731 | sigma_dut_reg_cmd("ap_set_hs2", NULL, cmd_ap_set_hs2); | 
|  | 10732 | sigma_dut_reg_cmd("ap_set_rfeature", NULL, cmd_ap_set_rfeature); | 
|  | 10733 | sigma_dut_reg_cmd("ap_nfc_action", NULL, cmd_ap_nfc_action); | 
|  | 10734 | sigma_dut_reg_cmd("ap_wps_read_pin", NULL, cmd_ap_wps_read_pin); | 
| Alexei Avshalom Lazar | 6427969 | 2018-12-23 16:49:49 +0200 | [diff] [blame] | 10735 | sigma_dut_reg_cmd("ap_wps_enter_pin", NULL, cmd_ap_wps_enter_pin); | 
|  | 10736 | sigma_dut_reg_cmd("ap_wps_set_pbc", NULL, cmd_ap_wps_set_pbc); | 
| Alexei Avshalom Lazar | 0c1d82d | 2018-12-23 17:02:42 +0200 | [diff] [blame] | 10737 | sigma_dut_reg_cmd("ap_get_parameter", NULL, cmd_ap_get_parameter); | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 10738 | sigma_dut_reg_cmd("AccessPoint", NULL, cmd_accesspoint); | 
| priyadharshini gowthaman | 9149afc | 2018-01-15 13:40:18 -0800 | [diff] [blame] | 10739 | sigma_dut_reg_cmd("ap_preset_testparameters", NULL, | 
|  | 10740 | cmd_ap_preset_testparameters); | 
| Jouni Malinen | cd4e3c3 | 2015-10-29 12:39:56 +0200 | [diff] [blame] | 10741 | } |