1# Copyright 2019 - The Android Open Source Project 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14 15from acts import utils 16 17from acts.controllers.ap_lib import hostapd_config 18from acts.controllers.ap_lib import hostapd_constants 19from acts.controllers.ap_lib import hostapd_utils 20 21 22def linksys_ea4500(iface_wlan_2g=None, 23 iface_wlan_5g=None, 24 channel=None, 25 security=None, 26 ssid=None): 27 # TODO(b/143104825): Permit RIFS once it is supported 28 # TODO(b/144446076): Address non-whirlwind hardware capabilities. 29 """A simulated implementation of what a Linksys EA4500 AP 30 Args: 31 iface_wlan_2g: The 2.4Ghz interface of the test AP. 32 iface_wlan_5g: The 5GHz interface of the test AP. 33 channel: What channel to use. 34 security: A security profile (None or WPA2). 35 ssid: The network name. 36 Returns: 37 A hostapd config. 38 Differences from real EA4500: 39 CF (Contention-Free) Parameter IE: 40 EA4500: has CF Parameter IE 41 Simulated: does not have CF Parameter IE 42 HT Capab: 43 Info: 44 EA4500: Green Field supported 45 Simulated: Green Field not supported on Whirlwind. 46 A-MPDU 47 RTAC66U: MPDU Density 4 48 Simulated: MPDU Density 8 49 RSN Capab (w/ WPA2): 50 EA4500: 51 RSN PTKSA Replay Counter Capab: 1 52 Simulated: 53 RSN PTKSA Replay Counter Capab: 16 54 """ 55 # Verify interface and security 56 hostapd_utils.verify_interface(iface_wlan_2g, 57 hostapd_constants.INTERFACE_2G_LIST) 58 hostapd_utils.verify_interface(iface_wlan_5g, 59 hostapd_constants.INTERFACE_5G_LIST) 60 hostapd_utils.verify_security_mode(security, 61 [None, hostapd_constants.WPA2]) 62 if security: 63 hostapd_utils.verify_cipher(security, 64 [hostapd_constants.WPA2_DEFAULT_CIPER]) 65 66 # Common Parameters 67 rates = hostapd_constants.CCK_AND_OFDM_DATA_RATES 68 69 n_capabilities = [ 70 hostapd_constants.N_CAPABILITY_SGI20, 71 hostapd_constants.N_CAPABILITY_SGI40, 72 hostapd_constants.N_CAPABILITY_TX_STBC, 73 hostapd_constants.N_CAPABILITY_RX_STBC1, 74 hostapd_constants.N_CAPABILITY_DSSS_CCK_40 75 ] 76 77 # Epigram HT Capabilities IE 78 # Epigram HT Additional Capabilities IE 79 # Marvell Semiconductor, Inc. IE 80 vendor_elements = { 81 'vendor_elements': 82 'dd1e00904c33fc0117ffffff0000000000000000000000000000000000000000' 83 'dd1a00904c3424000000000000000000000000000000000000000000' 84 'dd06005043030000' 85 } 86 87 # 2.4GHz 88 if channel <= 11: 89 interface = iface_wlan_2g 90 rates.update(hostapd_constants.CCK_AND_OFDM_BASIC_RATES) 91 obss_interval = 180 92 n_capabilities.append(hostapd_constants.N_CAPABILITY_HT40_PLUS) 93 94 # 5GHz 95 else: 96 interface = iface_wlan_5g 97 rates.update(hostapd_constants.OFDM_ONLY_BASIC_RATES) 98 obss_interval = None 99 100 additional_params = utils.merge_dicts(rates, vendor_elements, 101 hostapd_constants.UAPSD_ENABLED) 102 103 config = hostapd_config.HostapdConfig( 104 ssid=ssid, 105 channel=channel, 106 hidden=False, 107 security=security, 108 interface=interface, 109 mode=hostapd_constants.MODE_11N_MIXED, 110 force_wmm=True, 111 beacon_interval=100, 112 dtim_period=1, 113 short_preamble=True, 114 obss_interval=obss_interval, 115 n_capabilities=n_capabilities, 116 additional_parameters=additional_params) 117 118 return config 119 120 121def linksys_ea9500(iface_wlan_2g=None, 122 iface_wlan_5g=None, 123 channel=None, 124 security=None, 125 ssid=None): 126 """A simulated implementation of what a Linksys EA9500 AP 127 Args: 128 iface_wlan_2g: The 2.4Ghz interface of the test AP. 129 iface_wlan_5g: The 5GHz interface of the test AP. 130 channel: What channel to use. 131 security: A security profile (None or WPA2). 132 ssid: The network name. 133 Returns: 134 A hostapd config. 135 Differences from real EA9500: 136 2.4GHz: 137 Rates: 138 EA9500: 139 Supported: 1, 2, 5.5, 11, 18, 24, 36, 54 140 Extended: 6, 9, 12, 48 141 Simulated: 142 Supported: 1, 2, 5.5, 11, 6, 9, 12, 18 143 Extended: 24, 36, 48, 54 144 RSN Capab (w/ WPA2): 145 EA9500: 146 RSN PTKSA Replay Counter Capab: 16 147 Simulated: 148 RSN PTKSA Replay Counter Capab: 1 149 """ 150 # Verify interface and security 151 hostapd_utils.verify_interface(iface_wlan_2g, 152 hostapd_constants.INTERFACE_2G_LIST) 153 hostapd_utils.verify_interface(iface_wlan_5g, 154 hostapd_constants.INTERFACE_5G_LIST) 155 hostapd_utils.verify_security_mode(security, 156 [None, hostapd_constants.WPA2]) 157 if security: 158 hostapd_utils.verify_cipher(security, 159 [hostapd_constants.WPA2_DEFAULT_CIPER]) 160 161 # Common Parameters 162 rates = hostapd_constants.CCK_AND_OFDM_DATA_RATES 163 qbss = {'bss_load_update_period': 50, 'chan_util_avg_period': 600} 164 # Measurement Pilot Transmission IE 165 vendor_elements = {'vendor_elements': '42020000'} 166 167 # 2.4GHz 168 if channel <= 11: 169 interface = iface_wlan_2g 170 mode = hostapd_constants.MODE_11G 171 rates.update(hostapd_constants.CCK_AND_OFDM_BASIC_RATES) 172 173 # 5GHz 174 else: 175 interface = iface_wlan_5g 176 mode = hostapd_constants.MODE_11A 177 rates.update(hostapd_constants.OFDM_ONLY_BASIC_RATES) 178 179 additional_params = utils.merge_dicts(rates, qbss, vendor_elements) 180 181 config = hostapd_config.HostapdConfig( 182 ssid=ssid, 183 channel=channel, 184 hidden=False, 185 security=security, 186 interface=interface, 187 mode=mode, 188 force_wmm=False, 189 beacon_interval=100, 190 dtim_period=1, 191 short_preamble=False, 192 additional_parameters=additional_params) 193 return config 194 195 196def linksys_wrt1900acv2(iface_wlan_2g=None, 197 iface_wlan_5g=None, 198 channel=None, 199 security=None, 200 ssid=None): 201 # TODO(b/144446076): Address non-whirlwind hardware capabilities. 202 """A simulated implementation of what a Linksys WRT1900ACV2 AP 203 Args: 204 iface_wlan_2g: The 2.4Ghz interface of the test AP. 205 iface_wlan_5g: The 5GHz interface of the test AP. 206 channel: What channel to use. 207 security: A security profile (None or WPA2). 208 ssid: The network name. 209 Returns: 210 A hostapd config. 211 Differences from real WRT1900ACV2: 212 5 GHz: 213 Simulated: Has two country code IEs, one that matches 214 the actual, and another explicit IE that was required for 215 hostapd's 802.11d to work. 216 Both: 217 HT Capab: 218 A-MPDU 219 WRT1900ACV2: MPDU Density 4 220 Simulated: MPDU Density 8 221 VHT Capab: 222 WRT1900ACV2: 223 SU Beamformer Supported, 224 SU Beamformee Supported, 225 Beamformee STS Capability: 4, 226 Number of Sounding Dimensions: 4, 227 Simulated: 228 Above are not supported on Whirlwind. 229 RSN Capabilities (w/ WPA2): 230 WRT1900ACV2: 231 RSN PTKSA Replay Counter Capab: 1 232 Simulated: 233 RSN PTKSA Replay Counter Capab: 16 234 """ 235 # Verify interface and security 236 hostapd_utils.verify_interface(iface_wlan_2g, 237 hostapd_constants.INTERFACE_2G_LIST) 238 hostapd_utils.verify_interface(iface_wlan_5g, 239 hostapd_constants.INTERFACE_5G_LIST) 240 hostapd_utils.verify_security_mode(security, 241 [None, hostapd_constants.WPA2]) 242 if security: 243 hostapd_utils.verify_cipher(security, 244 [hostapd_constants.WPA2_DEFAULT_CIPER]) 245 246 # Common Parameters 247 rates = hostapd_constants.CCK_AND_OFDM_DATA_RATES 248 n_capabilities = [ 249 hostapd_constants.N_CAPABILITY_LDPC, 250 hostapd_constants.N_CAPABILITY_SGI20, 251 hostapd_constants.N_CAPABILITY_SGI40 252 ] 253 ac_capabilities = [ 254 hostapd_constants.AC_CAPABILITY_RXLDPC, 255 hostapd_constants.AC_CAPABILITY_SHORT_GI_80, 256 hostapd_constants.AC_CAPABILITY_RX_STBC_1, 257 hostapd_constants.AC_CAPABILITY_RX_ANTENNA_PATTERN, 258 hostapd_constants.AC_CAPABILITY_TX_ANTENNA_PATTERN, 259 hostapd_constants.AC_CAPABILITY_MAX_A_MPDU_LEN_EXP7 260 ] 261 vht_channel_width = 20 262 # Epigram, Inc. HT Capabilities IE 263 # Epigram, Inc. HT Additional Capabilities IE 264 # Marvell Semiconductor IE 265 vendor_elements = { 266 'vendor_elements': 267 'dd1e00904c336c0017ffffff0001000000000000000000000000001fff071800' 268 'dd1a00904c3424000000000000000000000000000000000000000000' 269 'dd06005043030000' 270 } 271 272 # 2.4GHz 273 if channel <= 11: 274 interface = iface_wlan_2g 275 rates.update(hostapd_constants.CCK_AND_OFDM_BASIC_RATES) 276 obss_interval = 180 277 spectrum_mgmt = False 278 local_pwr_constraint = {} 279 280 # 5GHz 281 else: 282 interface = iface_wlan_5g 283 rates.update(hostapd_constants.OFDM_ONLY_BASIC_RATES) 284 obss_interval = None 285 spectrum_mgmt = True, 286 local_pwr_constraint = {'local_pwr_constraint': 3} 287 # Country Information IE (w/ individual channel info) 288 vendor_elements['vendor_elements'] += '071e5553202401112801112c011130' \ 289 '01119501179901179d0117a10117a50117' 290 291 additional_params = utils.merge_dicts(rates, vendor_elements, 292 hostapd_constants.UAPSD_ENABLED, 293 local_pwr_constraint) 294 295 config = hostapd_config.HostapdConfig( 296 ssid=ssid, 297 channel=channel, 298 hidden=False, 299 security=security, 300 interface=interface, 301 mode=hostapd_constants.MODE_11AC_MIXED, 302 force_wmm=True, 303 beacon_interval=100, 304 dtim_period=1, 305 short_preamble=True, 306 obss_interval=obss_interval, 307 n_capabilities=n_capabilities, 308 ac_capabilities=ac_capabilities, 309 vht_channel_width=vht_channel_width, 310 spectrum_mgmt_required=spectrum_mgmt, 311 additional_parameters=additional_params) 312 return config 313