def setup_class(self): super().setup_class() if len(self.fuchsia_devices) < 1: raise signals.TestFailure("No fuchsia devices found.") for fd in self.fuchsia_devices: # Initialize the Policy client controller for each Fuchsia device fd.wlan_policy_lib.wlanCreateClientController() if len(self.access_points) < 1: raise signals.TestFailure("No access points found.") # Prepare the AP self.access_point = self.access_points[0] self.access_point.stop_all_aps() # Generate network params. bss_settings_2g = [] bss_settings_5g = [] open_network = self.get_open_network(False, []) self.open_network_2g = open_network["2g"] self.open_network_5g = open_network["5g"] wpa2_settings = self.get_psk_network(False, []) self.wpa2_network_2g = wpa2_settings["2g"] self.wpa2_network_5g = wpa2_settings["5g"] bss_settings_2g.append( hostapd_bss_settings.BssSettings( name=self.wpa2_network_2g["SSID"], ssid=self.wpa2_network_2g["SSID"], security=hostapd_security.Security( security_mode=self.wpa2_network_2g["security"], password=self.wpa2_network_2g["password"]))) bss_settings_5g.append( hostapd_bss_settings.BssSettings( name=self.wpa2_network_5g["SSID"], ssid=self.wpa2_network_5g["SSID"], security=hostapd_security.Security( security_mode=self.wpa2_network_5g["security"], password=self.wpa2_network_5g["password"]))) self.ap_2g = hostapd_ap_preset.create_ap_preset( iface_wlan_2g=self.access_points[0].wlan_2g, iface_wlan_5g=self.access_points[0].wlan_5g, channel=hostapd_constants.AP_DEFAULT_CHANNEL_2G, ssid=self.open_network_2g["SSID"], bss_settings=bss_settings_2g) self.ap_5g = hostapd_ap_preset.create_ap_preset( iface_wlan_2g=self.access_points[0].wlan_2g, iface_wlan_5g=self.access_points[0].wlan_5g, channel=hostapd_constants.AP_DEFAULT_CHANNEL_5G, ssid=self.open_network_5g["SSID"], bss_settings=bss_settings_5g) # Start the networks self.access_point.start_ap(hostapd_config=self.ap_2g) self.access_point.start_ap(hostapd_config=self.ap_5g) # Save the SSIDs self.all_ssids = [ self.open_network_2g["SSID"], self.wpa2_network_2g["SSID"], self.open_network_5g["SSID"], self.wpa2_network_5g["SSID"], ]
def _generate_legacy_ap_config(self, network_list): bss_settings = [] ap_settings = network_list.pop(0) # TODO:(bmahadev) This is a bug. We should not have to pop the first # network in the list and treat it as a separate case. Instead, # create_ap_preset() should be able to take NULL ssid and security and # build config based on the bss_Settings alone. hostapd_config_settings = network_list.pop(0) for network in network_list: if "password" in network and "hiddenSSID" in network: bss_settings.append( hostapd_bss_settings.BssSettings( name=network["SSID"], ssid=network["SSID"], hidden=True, security=hostapd_security.Security( security_mode=network["security"], password=network["password"]))) elif "password" in network and not "hiddenSSID" in network: bss_settings.append( hostapd_bss_settings.BssSettings( name=network["SSID"], ssid=network["SSID"], security=hostapd_security.Security( security_mode=network["security"], password=network["password"]))) elif not "password" in network and "hiddenSSID" in network: bss_settings.append( hostapd_bss_settings.BssSettings(name=network["SSID"], ssid=network["SSID"], hidden=True)) elif not "password" in network and not "hiddenSSID" in network: bss_settings.append( hostapd_bss_settings.BssSettings(name=network["SSID"], ssid=network["SSID"])) if "password" in hostapd_config_settings: config = hostapd_ap_preset.create_ap_preset( channel=ap_settings["channel"], ssid=hostapd_config_settings["SSID"], security=hostapd_security.Security( security_mode=hostapd_config_settings["security"], password=hostapd_config_settings["password"]), bss_settings=bss_settings, profile_name='whirlwind') else: config = hostapd_ap_preset.create_ap_preset( channel=ap_settings["channel"], ssid=hostapd_config_settings["SSID"], bss_settings=bss_settings, profile_name='whirlwind') return config
def _generate_legacy_ap_config(self, network_list): bss_settings = [] wlan_2g = self.access_points[AP_1].wlan_2g wlan_5g = self.access_points[AP_1].wlan_5g ap_settings = network_list.pop(0) # TODO:(bmahadev) This is a bug. We should not have to pop the first # network in the list and treat it as a separate case. Instead, # create_ap_preset() should be able to take NULL ssid and security and # build config based on the bss_Settings alone. hostapd_config_settings = network_list.pop(0) for network in network_list: if "password" in network: bss_settings.append( hostapd_bss_settings.BssSettings( name=network["SSID"], ssid=network["SSID"], hidden=network["hiddenSSID"], security=hostapd_security.Security( security_mode=network["security"], password=network["password"]))) elif "wepKeys" in network: bss_settings.append( hostapd_bss_settings.BssSettings( name=network["SSID"], ssid=network["SSID"], hidden=network["hiddenSSID"], security=hostapd_security.Security( security_mode=network["security"], password=network["wepKeys"][0]))) elif network["security"] == hostapd_constants.ENT_STRING: bss_settings.append( hostapd_bss_settings.BssSettings( name=network["SSID"], ssid=network["SSID"], hidden=network["hiddenSSID"], security=hostapd_security.Security( security_mode=network["security"], radius_server_ip=network["radius_server_ip"], radius_server_port=network["radius_server_port"], radius_server_secret=network["radius_server_secret"]))) else: bss_settings.append( hostapd_bss_settings.BssSettings( name=network["SSID"], ssid=network["SSID"], hidden=network["hiddenSSID"])) if "password" in hostapd_config_settings: config = hostapd_ap_preset.create_ap_preset( iface_wlan_2g=wlan_2g, iface_wlan_5g=wlan_5g, channel=ap_settings["channel"], ssid=hostapd_config_settings["SSID"], hidden=hostapd_config_settings["hiddenSSID"], security=hostapd_security.Security( security_mode=hostapd_config_settings["security"], password=hostapd_config_settings["password"]), bss_settings=bss_settings) elif "wepKeys" in hostapd_config_settings: config = hostapd_ap_preset.create_ap_preset( iface_wlan_2g=wlan_2g, iface_wlan_5g=wlan_5g, channel=ap_settings["channel"], ssid=hostapd_config_settings["SSID"], hidden=hostapd_config_settings["hiddenSSID"], security=hostapd_security.Security( security_mode=hostapd_config_settings["security"], password=hostapd_config_settings["wepKeys"][0]), bss_settings=bss_settings) else: config = hostapd_ap_preset.create_ap_preset( iface_wlan_2g=wlan_2g, iface_wlan_5g=wlan_5g, channel=ap_settings["channel"], ssid=hostapd_config_settings["SSID"], hidden=hostapd_config_settings["hiddenSSID"], bss_settings=bss_settings) return config
def setup_class(self): self.log.info('Setup {cls}'.format(cls=type(self))) if not self.fuchsia_devices: self.log.error( "NetstackFuchsiaTest Init: Not enough fuchsia devices.") self.log.info("Running testbed setup with one fuchsia devices") self.fuchsia_dev = self.fuchsia_devices[0] # We want to bring up several 2GHz and 5GHz BSSes. wifi_bands = ['2g', '5g'] # Currently AP_DEFAULT_CHANNEL_2G is 6 # and AP_DEFAULT_CHANNEL_5G is 36. wifi_channels = [ hostapd_constants.AP_DEFAULT_CHANNEL_2G, hostapd_constants.AP_DEFAULT_CHANNEL_5G ] # Each band will start up an Open BSS (security_mode=None) # and a WPA2 BSS (security_mode=hostapd_constants.WPA2_STRING) security_modes = [None, hostapd_constants.WPA2_STRING] # All secure BSSes will use the same password. wifi_password = rand_ascii_str(10) self.log.info('Wi-Fi password for this test: {wifi_password}'.format( wifi_password=wifi_password)) hostapd_configs = [] wifi_interfaces = {} bss_settings = {} # Build a configuration for each sub-BSSID for band_index, wifi_band in enumerate(wifi_bands): ssid_name = 'Ixia_{wifi_band}_#{bss_number}_{security_mode}' bss_settings[wifi_band] = [] # Prepare the extra SSIDs. for mode_index, security_mode in enumerate(security_modes): # Skip the first SSID because we configure that separately. # due to the way the APIs work. This loop is only concerned # with the sub-BSSIDs. if mode_index == 0: continue bss_name = ssid_name.format(wifi_band=wifi_band, security_mode=security_mode, bss_number=mode_index + 1) bss_setting = hostapd_bss_settings.BssSettings( name=bss_name, ssid=bss_name, security=hostapd_security.Security( security_mode=security_mode, password=wifi_password)) bss_settings[wifi_band].append(bss_setting) # This is the configuration for the first SSID. ssid_name = ssid_name.format(wifi_band=wifi_band, security_mode=security_modes[0], bss_number=1) hostapd_configs.append( hostapd_ap_preset.create_ap_preset( profile_name='whirlwind', iface_wlan_2g='wlan0', iface_wlan_5g='wlan1', ssid=ssid_name, channel=wifi_channels[band_index], security=hostapd_security.Security( security_mode=security_modes[0], password=wifi_password), bss_settings=bss_settings[wifi_band])) access_point = self.access_points[band_index] # Now bring up the AP and track the interfaces we're using for # each BSSID. All BSSIDs are now beaconing. wifi_interfaces[wifi_band] = access_point.start_ap( hostapd_configs[band_index]) # Disable DHCP on this Wi-Fi band. # Note: This also disables DHCP on each sub-BSSID due to how # the APIs are built. # # We need to do this in order to enable IxANVL testing across # Wi-Fi, which needs to configure the IP addresses per-interface # on the client device. access_point.stop_dhcp() # Disable NAT. # NAT config in access_point.py is global at the moment, but # calling it twice (once per band) won't hurt anything. This is # easier than trying to conditionalize per band. # # Note that we could make this per-band, but it would require # refactoring the access_point.py code that turns on NAT, however # if that ever does happen then this code will work as expected # without modification. # # This is also required for IxANVL testing. NAT would interfere # with IxANVL because IxANVL needs to see the raw frames # sourcing/sinking from/to the DUT for protocols such as ARP and # DHCP, but it also needs the MAC/IP of the source and destination # frames and packets to be from the DUT, so we want the AP to act # like a bridge for these tests. access_point.stop_nat() # eth1 is the LAN port, which will always be a part of the bridge. bridge_interfaces = ['eth1'] # This adds each bssid interface to the bridge. for wifi_band in wifi_bands: for wifi_interface in wifi_interfaces[wifi_band]: bridge_interfaces.append(wifi_interface) # Each interface can only be a member of 1 bridge, so we're going to use # the last access_point object to set the bridge up for all interfaces. access_point.create_bridge(bridge_name='ixia_bridge0', interfaces=bridge_interfaces)
def setup_class(self): super().setup_class() self.start_access_point = False if "AccessPoint" in self.user_params: # This section sets up the config that could be sent to the AP if # the AP is needed. The reasoning is since ACTS already connects # to the AP if it is in the config, generating the config in memory # has no over head is used if need by the test if one of the ssids # needed for the test is not included in the config. The logic # here creates 2 ssids on each radio, 5ghz and 2.4ghz, with an # open, no security network and one that is wpa2, for a total of 4 # networks. However, if all of the ssids are specified in the # the config will never be written to the AP and the AP will not be # brought up. For more information about how to configure the # hostapd config info, see the hostapd libraries, which have more # documentation. bss_settings_2g = [] bss_settings_5g = [] open_network = self.get_open_network(False, []) self.open_network_2g = open_network['2g'] self.open_network_5g = open_network['5g'] wpa2_settings = self.get_psk_network(False, []) self.wpa2_network_2g = wpa2_settings['2g'] self.wpa2_network_5g = wpa2_settings['5g'] bss_settings_2g.append( hostapd_bss_settings.BssSettings( name=self.wpa2_network_2g['SSID'], ssid=self.wpa2_network_2g['SSID'], security=hostapd_security.Security( security_mode=self.wpa2_network_2g["security"], password=self.wpa2_network_2g["password"]))) bss_settings_5g.append( hostapd_bss_settings.BssSettings( name=self.wpa2_network_5g['SSID'], ssid=self.wpa2_network_5g['SSID'], security=hostapd_security.Security( security_mode=self.wpa2_network_5g["security"], password=self.wpa2_network_5g["password"]))) self.ap_2g = hostapd_ap_preset.create_ap_preset( iface_wlan_2g=self.access_points[0].wlan_2g, iface_wlan_5g=self.access_points[0].wlan_5g, channel=hostapd_constants.AP_DEFAULT_CHANNEL_2G, ssid=self.open_network_2g['SSID'], bss_settings=bss_settings_2g) self.ap_5g = hostapd_ap_preset.create_ap_preset( iface_wlan_2g=self.access_points[0].wlan_2g, iface_wlan_5g=self.access_points[0].wlan_5g, channel=hostapd_constants.AP_DEFAULT_CHANNEL_5G, ssid=self.open_network_5g['SSID'], bss_settings=bss_settings_5g) if "wlan_open_network_2g" in self.user_params: self.open_network_2g = self.user_params.get("wlan_open_network_2g") elif "AccessPoint" in self.user_params: self.start_access_point_2g = True else: raise Exception('Missing parameter in config ' '(wlan_open_network_2g)') if "wlan_open_network_5g" in self.user_params: self.open_network_5g = self.user_params.get("wlan_open_network_5g") elif "AccessPoint" in self.user_params: self.start_access_point_5g = True else: raise Exception('Missing parameter in config ' '(wlan_open_network_5g)') if "wlan_wpa2_network_2g" in self.user_params: self.wpa2_network_2g = self.user_params.get("wlan_wpa2_network_2g") elif "AccessPoint" in self.user_params: self.start_access_point_2g = True else: raise Exception('Missing parameter in config ' '(wlan_wpa2_network_2g)') if "wlan_wpa2_network_5g" in self.user_params: self.wpa2_network_5g = self.user_params.get("wlan_wpa2_network_5g") elif "AccessPoint" in self.user_params: self.start_access_point_5g = True else: raise Exception('Missing parameter in config ' '(wlan_wpa2_network_5g)') # Only bring up the APs that are needed for the test. Each ssid is # randomly generated so there is no chance of re associating to a # previously saved ssid on the device. if self.start_access_point_2g: self.start_access_point = True self.access_points[0].start_ap(hostapd_config=self.ap_2g) if self.start_access_point_5g: self.start_access_point = True self.access_points[0].start_ap(hostapd_config=self.ap_5g)