def test_ap_multi_bss_acs(dev, apdev): """hostapd start with a multi-BSS configuration file using ACS""" ifname = apdev[0]['ifname'] hostapd.add_iface(ifname, 'multi-bss-acs.conf') hapd = hostapd.Hostapd(ifname) hapd.enable() wait_acs(hapd) freq = hapd.get_status_field("freq") if int(freq) < 2400: raise Exception("Unexpected frequency") dev[0].connect("bss-1", key_mgmt="NONE", scan_freq=freq) dev[1].connect("bss-2", psk="12345678", scan_freq=freq) dev[2].connect("bss-3", psk="qwertyuiop", scan_freq=freq)
def test_ap_config_reload_before_enable(dev, apdev, params): """hostapd configuration reload before enable""" hapd = hostapd.add_iface(apdev[0], "bss-1.conf") with open(os.path.join(params['logdir'], 'hostapd-test.pid'), "r") as f: pid = int(f.read()) os.kill(pid, signal.SIGHUP) hapd.ping()
def test_ap_multi_bss_config(dev, apdev): """hostapd start with a multi-BSS configuration file""" ifname1 = apdev[0]['ifname'] ifname2 = apdev[0]['ifname'] + '-2' ifname3 = apdev[0]['ifname'] + '-3' logger.info("Set up three BSSes with one configuration file") hostapd.add_iface(ifname1, 'multi-bss.conf') hapd = hostapd.Hostapd(ifname1) hapd.enable() multi_check(dev, [True, True, True]) hostapd.remove_bss(ifname2) multi_check(dev, [True, False, True]) hostapd.remove_bss(ifname3) multi_check(dev, [True, False, False]) hostapd.remove_bss(ifname1) multi_check(dev, [False, False, False]) hostapd.add_iface(ifname1, 'multi-bss.conf') hapd = hostapd.Hostapd(ifname1) hapd.enable() hostapd.remove_bss(ifname1) multi_check(dev, [False, False, False])
def test_ap_multi_bss_config(dev, apdev): """hostapd start with a multi-BSS configuration file""" ifname1 = apdev[0]['ifname'] ifname2 = apdev[0]['ifname'] + '-2' ifname3 = apdev[0]['ifname'] + '-3' logger.info("Set up three BSSes with one configuration file") hostapd.add_iface(ifname1, 'multi-bss.conf') hapd = hostapd.Hostapd(ifname1) hapd.enable() multi_check(dev, [ True, True, True ]) hostapd.remove_bss(ifname2) multi_check(dev, [ True, False, True ]) hostapd.remove_bss(ifname3) multi_check(dev, [ True, False, False ]) hostapd.remove_bss(ifname1) multi_check(dev, [ False, False, False ]) hostapd.add_iface(ifname1, 'multi-bss.conf') hapd = hostapd.Hostapd(ifname1) hapd.enable() hostapd.remove_bss(ifname1) multi_check(dev, [ False, False, False ])
def test_ap_multi_bss_config(dev, apdev): """hostapd start with a multi-BSS configuration file""" for i in range(3): dev[i].flush_scan_cache() ifname1 = apdev[0]['ifname'] ifname2 = apdev[0]['ifname'] + '-2' ifname3 = apdev[0]['ifname'] + '-3' logger.info("Set up three BSSes with one configuration file") hapd = hostapd.add_iface(apdev[0], 'multi-bss.conf') hapd.enable() multi_check(dev, [True, True, True]) hostapd.remove_bss(apdev[0], ifname2) multi_check(dev, [True, False, True]) hostapd.remove_bss(apdev[0], ifname3) multi_check(dev, [True, False, False]) hostapd.remove_bss(apdev[0], ifname1) multi_check(dev, [False, False, False]) hapd = hostapd.add_iface(apdev[0], 'multi-bss.conf') hapd.enable() hostapd.remove_bss(apdev[0], ifname1) multi_check(dev, [False, False, False])
def test_ap_multi_bss_config(dev, apdev): """hostapd start with a multi-BSS configuration file""" for i in range(3): dev[i].flush_scan_cache() ifname1 = apdev[0]['ifname'] ifname2 = apdev[0]['ifname'] + '-2' ifname3 = apdev[0]['ifname'] + '-3' logger.info("Set up three BSSes with one configuration file") hapd = hostapd.add_iface(apdev[0], 'multi-bss.conf') hapd.enable() multi_check(dev, [ True, True, True ]) hostapd.remove_bss(apdev[0], ifname2) multi_check(dev, [ True, False, True ]) hostapd.remove_bss(apdev[0], ifname3) multi_check(dev, [ True, False, False ]) hostapd.remove_bss(apdev[0], ifname1) multi_check(dev, [ False, False, False ]) hapd = hostapd.add_iface(apdev[0], 'multi-bss.conf') hapd.enable() hostapd.remove_bss(apdev[0], ifname1) multi_check(dev, [ False, False, False ])
def test_ap_config_reload_file(dev, apdev, params): """hostapd configuration reload from file""" hapd = hostapd.add_iface(apdev[0], "bss-1.conf") hapd.enable() hapd.set("ssid", "foobar") with open(os.path.join(params['logdir'], 'hostapd-test.pid'), "r") as f: pid = int(f.read()) os.kill(pid, signal.SIGHUP) time.sleep(0.1) dev[0].connect("foobar", key_mgmt="NONE", scan_freq="2412") hapd.set("ssid", "foo") os.kill(pid, signal.SIGHUP) dev[0].wait_disconnected() dev[0].request("DISCONNECT")
def test_ap_multi_bss_acs(dev, apdev): """hostapd start with a multi-BSS configuration file using ACS""" ifname = apdev[0]['ifname'] # make sure the current channel is on 2.4 GHz band as a workaround for the # limited survey functionality in mac80211_hwsim hostapd.add_ap(ifname, {"ssid": "test"}) time.sleep(0.1) hapd_global = hostapd.HostapdGlobal() hapd_global.remove(ifname) # start the actual test hostapd.add_iface(ifname, 'multi-bss-acs.conf') hapd = hostapd.Hostapd(ifname) hapd.enable() wait_acs(hapd) freq = hapd.get_status_field("freq") if int(freq) < 2400: raise Exception("Unexpected frequency") dev[0].connect("bss-1", key_mgmt="NONE", scan_freq=freq) dev[1].connect("bss-2", psk="12345678", scan_freq=freq) dev[2].connect("bss-3", psk="qwertyuiop", scan_freq=freq)
def test_ap_multi_bss_acs(dev, apdev): """hostapd start with a multi-BSS configuration file using ACS""" ifname = apdev[0]['ifname'] # make sure the current channel is on 2.4 GHz band as a workaround for the # limited survey functionality in mac80211_hwsim hostapd.add_ap(ifname, { "ssid": "test" }) time.sleep(0.1) hapd_global = hostapd.HostapdGlobal() hapd_global.remove(ifname) # start the actual test hostapd.add_iface(ifname, 'multi-bss-acs.conf') hapd = hostapd.Hostapd(ifname) hapd.enable() wait_acs(hapd) freq = hapd.get_status_field("freq") if int(freq) < 2400: raise Exception("Unexpected frequency") dev[0].connect("bss-1", key_mgmt="NONE", scan_freq=freq) dev[1].connect("bss-2", psk="12345678", scan_freq=freq) dev[2].connect("bss-3", psk="qwertyuiop", scan_freq=freq)
def test_ap_multi_bss_acs(dev, apdev): """hostapd start with a multi-BSS configuration file using ACS""" skip_with_fips(dev[0]) force_prev_ap_on_24g(apdev[0]) # start the actual test hapd = hostapd.add_iface(apdev[0], 'multi-bss-acs.conf') hapd.enable() wait_acs(hapd) freq = hapd.get_status_field("freq") if int(freq) < 2400: raise Exception("Unexpected frequency") dev[0].connect("bss-1", key_mgmt="NONE", scan_freq=freq) dev[1].connect("bss-2", psk="12345678", scan_freq=freq) dev[2].connect("bss-3", psk="qwertyuiop", scan_freq=freq)
def test_ap_config_reload_file_while_disabled(dev, apdev, params): """hostapd configuration reload from file when disabled""" hapd = hostapd.add_iface(apdev[0], "bss-1.conf") hapd.enable() ev = hapd.wait_event(["AP-ENABLED"], timeout=3) if ev is None: raise Exception("AP-ENABLED event not reported") hapd.set("ssid", "foobar") with open(os.path.join(params['logdir'], 'hostapd-test.pid'), "r") as f: pid = int(f.read()) hapd.disable() ev = hapd.wait_event(["AP-DISABLED"], timeout=3) if ev is None: raise Exception("AP-DISABLED event not reported") hapd.dump_monitor() os.kill(pid, signal.SIGHUP) time.sleep(0.1) hapd.enable() dev[0].connect("foobar", key_mgmt="NONE", scan_freq="2412")
def ap_vlan_iface_cleanup_multibss(dev, apdev, cfgfile): # AP VLAN with WPA2-Enterprise and RADIUS attributes changing VLANID # check that multiple bss do not interfere with each other with respect # to deletion of bridge and tagged interface. if not netifaces_imported: raise HwsimSkip("python module netifaces not available") try: ap_vlan_iface_cleanup_multibss_cleanup() ap_vlan_iface_test_and_prepare_environ() as_params = { "ssid": "as", "beacon_int": "2000", "radius_server_clients": "auth_serv/radius_clients.conf", "radius_server_auth_port": '18128', "eap_server": "1", "eap_user_file": "auth_serv/eap_user.conf", "ca_cert": "auth_serv/ca.pem", "server_cert": "auth_serv/server.pem", "private_key": "auth_serv/server.key", "vlan_naming": "1" } authserv = hostapd.add_ap(apdev[1], as_params) # start the actual test hapd = hostapd.add_iface(apdev[0], cfgfile) hapd1 = hostapd.Hostapd("wlan3-2", 1) hapd1.enable() ifaces = netifaces.interfaces() if "brvlan1" in ifaces: raise Exception("bridge brvlan1 already exists before") if "brvlan2" in ifaces: raise Exception("bridge brvlan2 already exists before") dev[0].connect("bss-1", key_mgmt="WPA-EAP", eap="PAX", identity="vlan1", password_hex="0123456789abcdef0123456789abcdef", scan_freq="2412") ifaces = netifaces.interfaces() if not("brvlan1" in ifaces): raise Exception("bridge brvlan1 was not created") hwsim_utils.test_connectivity_iface(dev[0], hapd, "brvlan1") if not iface_is_in_bridge("brvlan1", "dummy0.1"): raise Exception("dummy0.1 not in brvlan1") dev[1].connect("bss-2", key_mgmt="WPA-EAP", eap="PAX", identity="vlan1", password_hex="0123456789abcdef0123456789abcdef", scan_freq="2412") hwsim_utils.test_connectivity_iface(dev[1], hapd1, "brvlan1") if not iface_is_in_bridge("brvlan1", "dummy0.1"): raise Exception("dummy0.1 not in brvlan1") authserv.disable() authserv.set('eap_user_file', "auth_serv/eap_user_vlan.conf") authserv.enable() logger.info("wlan0 -> VLAN 2") dev[0].dump_monitor() dev[0].request("REAUTHENTICATE") ev = dev[0].wait_event(["CTRL-EVENT-EAP-SUCCESS"], timeout=15) if ev is None: raise Exception("EAP reauthentication timed out") ev = dev[0].wait_event(["WPA: Key negotiation completed"], timeout=5) if ev is None: raise Exception("4-way handshake after reauthentication timed out") state = dev[0].get_status_field('wpa_state') if state != "COMPLETED": raise Exception("Unexpected state after reauth: " + state) ifaces = netifaces.interfaces() if not ("brvlan1" in ifaces): raise Exception("bridge brvlan1 has been removed too early") hwsim_utils.test_connectivity_iface(dev[0], hapd, "brvlan2", max_tries=5) if not iface_is_in_bridge("brvlan2", "dummy0.2"): raise Exception("dummy0.2 not in brvlan2") logger.info("test wlan1 == VLAN 1") hwsim_utils.test_connectivity_iface(dev[1], hapd1, "brvlan1") if not iface_is_in_bridge("brvlan1", "dummy0.1"): raise Exception("dummy0.1 not in brvlan1") logger.info("wlan1 -> VLAN 2") dev[1].dump_monitor() dev[1].request("REAUTHENTICATE") ev = dev[1].wait_event(["CTRL-EVENT-EAP-SUCCESS"], timeout=15) if ev is None: raise Exception("EAP reauthentication timed out") ev = dev[1].wait_event(["WPA: Key negotiation completed"], timeout=5) if ev is None: raise Exception("4-way handshake after reauthentication timed out") state = dev[1].get_status_field('wpa_state') if state != "COMPLETED": raise Exception("Unexpected state after reauth: " + state) # it can take some time for data connectivity to be updated hwsim_utils.test_connectivity_iface(dev[1], hapd1, "brvlan2", max_tries=5) logger.info("test wlan0 == VLAN 2") hwsim_utils.test_connectivity_iface(dev[0], hapd, "brvlan2") if not iface_is_in_bridge("brvlan2", "dummy0.2"): raise Exception("dummy0.2 not in brvlan2") ifaces = netifaces.interfaces() if "brvlan1" in ifaces: raise Exception("bridge brvlan1 has not been cleaned up") # disconnect dev0 first to test a corner case dev[0].request("DISCONNECT") dev[0].wait_disconnected() dev[1].request("DISCONNECT") dev[1].wait_disconnected() # station removal needs some time for i in range(5): time.sleep(1) ifaces = netifaces.interfaces() if "brvlan2" not in ifaces: break ifaces = netifaces.interfaces() if "brvlan2" in ifaces: raise Exception("bridge brvlan2 has not been cleaned up") hapd.request("DISABLE") finally: ap_vlan_iface_cleanup_multibss_cleanup()