Пример #1
0
def run_owe_transition_mode_multi_bss(dev, apdev):
    if "OWE" not in dev[0].get_capability("key_mgmt"):
        raise HwsimSkip("OWE not supported")
    ifname1 = apdev[0]['ifname']
    ifname2 = apdev[0]['ifname'] + '-2'
    hapd1 = hostapd.add_bss(apdev[0], ifname1, 'owe-bss-1.conf')
    hapd2 = hostapd.add_bss(apdev[0], ifname2, 'owe-bss-2.conf')
    hapd2.bssidx = 1

    bssid = hapd1.own_addr()
    bssid2 = hapd2.own_addr()

    # Beaconing with the OWE Transition Mode element can start only once both
    # BSSs are enabled, so the very first Beacon frame may go out without this
    # element. Wait a bit to avoid getting incomplete scan results.
    time.sleep(0.1)

    dev[0].request("SCAN_INTERVAL 1")
    dev[0].scan_for_bss(bssid2, freq="2412")
    dev[0].scan_for_bss(bssid, freq="2412")
    dev[0].connect("transition-mode-open", key_mgmt="OWE")
    val = dev[0].get_status_field("bssid")
    if val != bssid2:
        raise Exception("Unexpected bssid: " + val)
    val = dev[0].get_status_field("key_mgmt")
    if val != "OWE":
        raise Exception("Unexpected key_mgmt: " + val)
    hwsim_utils.test_connectivity(dev[0], hapd2)
Пример #2
0
def _test_ap_bss_add_many(dev, apdev):
    ifname = apdev[0]['ifname']
    hostapd.add_bss(apdev[0], ifname, 'bss-1.conf')
    fname = '/tmp/hwsim-bss.conf'
    for i in range(16):
        ifname2 = ifname + '-' + str(i)
        with open(fname, 'w') as f:
            f.write("driver=nl80211\n")
            f.write("hw_mode=g\n")
            f.write("channel=1\n")
            f.write("ieee80211n=1\n")
            f.write("interface=%s\n" % ifname2)
            f.write("bssid=02:00:00:00:03:%02x\n" % (i + 1))
            f.write("ctrl_interface=/var/run/hostapd\n")
            f.write("ssid=test-%d\n" % i)
        hostapd.add_bss(apdev[0], ifname2, fname)
        os.remove(fname)

    dev[0].request("SCAN_INTERVAL 1")
    dev[0].connect("bss-1", key_mgmt="NONE", scan_freq="2412")
    dev[0].request("DISCONNECT")
    dev[0].wait_disconnected(timeout=5)
    for i in range(16):
        dev[0].connect("test-%d" % i, key_mgmt="NONE", scan_freq="2412")
        dev[0].request("DISCONNECT")
        dev[0].wait_disconnected(timeout=5)
        ifname2 = ifname + '-' + str(i)
        hostapd.remove_bss(apdev[0], ifname2)
Пример #3
0
def test_ap_duplicate_bssid(dev, apdev):
    """Duplicate BSSID"""
    params = {"ssid": "test"}
    hapd = hostapd.add_ap(apdev[0], params, no_enable=True)
    hapd.enable()
    ifname2 = apdev[0]['ifname'] + '-2'
    ifname3 = apdev[0]['ifname'] + '-3'
    # "BSS 'wlan3-2' may not have BSSID set to the MAC address of the radio"
    try:
        hostapd.add_bss(apdev[0], ifname2, 'bss-2-dup.conf')
        raise Exception("BSS add succeeded unexpectedly")
    except Exception as e:
        if "Could not add hostapd BSS" in str(e):
            pass
        else:
            raise

    hostapd.add_bss(apdev[0], ifname3, 'bss-3.conf')

    dev[0].connect("test", key_mgmt="NONE", scan_freq="2412")
    dev[0].request("DISCONNECT")
    dev[0].wait_disconnected()

    hapd.set("bssid", "02:00:00:00:03:02")
    hapd.disable()
    # "Duplicate BSSID 02:00:00:00:03:02 on interface 'wlan3-3' and 'wlan3'."
    if "FAIL" not in hapd.request("ENABLE"):
        raise Exception("ENABLE with duplicate BSSID succeeded unexpectedly")
def test_monitor_iface_multi_bss(dev, apdev):
    """AP mode mmonitor interface with hostapd multi-BSS setup"""
    params = { "ssid": "monitor-iface", "driver_params": "use_monitor=1" }
    hapd = hostapd.add_ap(apdev[0]['ifname'], params)
    hostapd.add_bss('phy3', apdev[0]['ifname'] + '-2', 'bss-2.conf')
    dev[0].connect("monitor-iface", key_mgmt="NONE", scan_freq="2412")
    dev[1].connect("bss-2", key_mgmt="NONE", scan_freq="2412")
Пример #5
0
def test_ap_duplicate_bssid(dev, apdev):
    """Duplicate BSSID"""
    params = {"ssid": "test"}
    hapd = hostapd.add_ap(apdev[0], params, no_enable=True)
    hapd.enable()
    ifname2 = apdev[0]['ifname'] + '-2'
    ifname3 = apdev[0]['ifname'] + '-3'
    # "BSS 'wlan3-2' may not have BSSID set to the MAC address of the radio"
    try:
        hostapd.add_bss(apdev[0], ifname2, 'bss-2-dup.conf')
        raise Exception("BSS add succeeded unexpectedly")
    except Exception as e:
        if "Could not add hostapd BSS" in str(e):
            pass
        else:
            raise

    hostapd.add_bss(apdev[0], ifname3, 'bss-3.conf')

    dev[0].connect("test", key_mgmt="NONE", scan_freq="2412")
    dev[0].request("DISCONNECT")
    dev[0].wait_disconnected()

    hapd.set("bssid", "02:00:00:00:03:02")
    hapd.disable()
    # "Duplicate BSSID 02:00:00:00:03:02 on interface 'wlan3-3' and 'wlan3'."
    if "FAIL" not in hapd.request("ENABLE"):
        raise Exception("ENABLE with duplicate BSSID succeeded unexpectedly")
Пример #6
0
def test_ap_bss_add_out_of_memory(dev, apdev):
    """Running out of memory while adding a BSS"""
    hapd2 = hostapd.add_ap(apdev[1], {"ssid": "open"})

    ifname1 = apdev[0]['ifname']
    ifname2 = apdev[0]['ifname'] + '-2'

    confname1 = hostapd.cfg_file(apdev[0], "bss-1.conf")
    confname2 = hostapd.cfg_file(apdev[0], "bss-2.conf")
    hapd_bss_out_of_mem(hapd2, 'phy3', confname1, 1, 'hostapd_add_iface')
    for i in range(1, 3):
        hapd_bss_out_of_mem(hapd2, 'phy3', confname1, i,
                            'hostapd_interface_init_bss')
    hapd_bss_out_of_mem(hapd2, 'phy3', confname1, 1,
                        'ieee802_11_build_ap_params')

    hostapd.add_bss(apdev[0], ifname1, confname1)

    hapd_bss_out_of_mem(hapd2, 'phy3', confname2, 1,
                        'hostapd_interface_init_bss')
    hapd_bss_out_of_mem(hapd2, 'phy3', confname2, 1,
                        'ieee802_11_build_ap_params')

    hostapd.add_bss(apdev[0], ifname2, confname2)
    hostapd.remove_bss(apdev[0], ifname2)
    hostapd.remove_bss(apdev[0], ifname1)
Пример #7
0
def _test_ap_bss_add_many(dev, apdev):
    ifname = apdev[0]["ifname"]
    phy = "phy3"
    hostapd.add_bss(phy, ifname, "bss-1.conf")
    hapd = hostapd.HostapdGlobal()
    fname = "/tmp/hwsim-bss.conf"
    for i in range(16):
        ifname2 = ifname + "-" + str(i)
        with open(fname, "w") as f:
            f.write("driver=nl80211\n")
            f.write("hw_mode=g\n")
            f.write("channel=1\n")
            f.write("ieee80211n=1\n")
            f.write("interface=%s\n" % ifname2)
            f.write("bssid=02:00:00:00:03:%02x\n" % (i + 1))
            f.write("ctrl_interface=/var/run/hostapd\n")
            f.write("ssid=test-%d\n" % i)
        hostapd.add_bss(phy, ifname2, fname)
        os.remove(fname)

    dev[0].request("SCAN_INTERVAL 1")
    dev[0].connect("bss-1", key_mgmt="NONE", scan_freq="2412")
    dev[0].request("DISCONNECT")
    dev[0].wait_disconnected(timeout=5)
    for i in range(16):
        dev[0].connect("test-%d" % i, key_mgmt="NONE", scan_freq="2412")
        dev[0].request("DISCONNECT")
        dev[0].wait_disconnected(timeout=5)
        ifname2 = ifname + "-" + str(i)
        hapd.remove(ifname2)
def test_monitor_iface_multi_bss(dev, apdev):
    """AP mode mmonitor interface with hostapd multi-BSS setup"""
    params = {"ssid": "monitor-iface", "driver_params": "use_monitor=1"}
    hapd = hostapd.add_ap(apdev[0], params)
    hostapd.add_bss('phy3', apdev[0]['ifname'] + '-2', 'bss-2.conf')
    dev[0].connect("monitor-iface", key_mgmt="NONE", scan_freq="2412")
    dev[1].connect("bss-2", key_mgmt="NONE", scan_freq="2412")
Пример #9
0
def test_ap_bss_add_reuse_existing(dev, apdev):
    """Dynamic BSS add operation reusing existing interface"""
    ifname1 = apdev[0]["ifname"]
    ifname2 = apdev[0]["ifname"] + "-2"
    hostapd.add_bss("phy3", ifname1, "bss-1.conf")
    subprocess.check_call(["iw", "dev", ifname1, "interface", "add", ifname2, "type", "__ap"])
    hostapd.add_bss("phy3", ifname2, "bss-2.conf")
    hostapd.remove_bss(ifname2)
    subprocess.check_call(["iw", "dev", ifname2, "del"])
Пример #10
0
def test_ap_bss_add_reuse_existing(dev, apdev):
    """Dynamic BSS add operation reusing existing interface"""
    ifname1 = apdev[0]['ifname']
    ifname2 = apdev[0]['ifname'] + '-2'
    hostapd.add_bss(apdev[0], ifname1, 'bss-1.conf')
    subprocess.check_call(
        ["iw", "dev", ifname1, "interface", "add", ifname2, "type", "__ap"])
    hostapd.add_bss(apdev[0], ifname2, 'bss-2.conf')
    hostapd.remove_bss(apdev[0], ifname2)
    subprocess.check_call(["iw", "dev", ifname2, "del"])
Пример #11
0
def test_ap_bss_add_reuse_existing(dev, apdev):
    """Dynamic BSS add operation reusing existing interface"""
    ifname1 = apdev[0]['ifname']
    ifname2 = apdev[0]['ifname'] + '-2'
    hostapd.add_bss('phy3', ifname1, 'bss-1.conf')
    subprocess.check_call(["iw", "dev", ifname1, "interface", "add", ifname2,
                           "type", "__ap"])
    hostapd.add_bss('phy3', ifname2, 'bss-2.conf')
    hostapd.remove_bss(ifname2)
    subprocess.check_call(["iw", "dev", ifname2, "del"])
Пример #12
0
def test_ap_double_disable(dev, apdev):
    """Double DISABLE regression test"""
    hapd = hostapd.add_bss(apdev[0], apdev[0]['ifname'], 'bss-1.conf')
    hostapd.add_bss(apdev[0], apdev[0]['ifname'] + '-2', 'bss-2.conf')
    hapd.disable()
    if "FAIL" not in hapd.request("DISABLE"):
        raise Exception("Second DISABLE accepted unexpectedly")
    hapd.enable()
    hapd.disable()
    if "FAIL" not in hapd.request("DISABLE"):
        raise Exception("Second DISABLE accepted unexpectedly")
Пример #13
0
def test_ap_double_disable(dev, apdev):
    """Double DISABLE regression test"""
    hapd = hostapd.add_bss(apdev[0], apdev[0]['ifname'], 'bss-1.conf')
    hostapd.add_bss(apdev[0], apdev[0]['ifname'] + '-2', 'bss-2.conf')
    hapd.disable()
    if "FAIL" not in hapd.request("DISABLE"):
        raise Exception("Second DISABLE accepted unexpectedly")
    hapd.enable()
    hapd.disable()
    if "FAIL" not in hapd.request("DISABLE"):
        raise Exception("Second DISABLE accepted unexpectedly")
Пример #14
0
def test_ap_double_disable(dev, apdev):
    """Double DISABLE regression test"""
    hostapd.add_bss("phy3", apdev[0]["ifname"], "bss-1.conf")
    hostapd.add_bss("phy3", apdev[0]["ifname"] + "-2", "bss-2.conf")
    hapd = hostapd.Hostapd(apdev[0]["ifname"])
    hapd.disable()
    if "FAIL" not in hapd.request("DISABLE"):
        raise Exception("Second DISABLE accepted unexpectedly")
    hapd.enable()
    hapd.disable()
    if "FAIL" not in hapd.request("DISABLE"):
        raise Exception("Second DISABLE accepted unexpectedly")
Пример #15
0
def test_ap_duplicate_bssid(dev, apdev):
    """Duplicate BSSID"""
    params = { "ssid": "test" }
    hapd = hostapd.add_ap(apdev[0], params, no_enable=True)
    hapd.enable()
    ifname2 = apdev[0]['ifname'] + '-2'
    ifname3 = apdev[0]['ifname'] + '-3'
    # "BSS 'wlan3-2' may not have BSSID set to the MAC address of the radio"
    try:
        hostapd.add_bss(apdev[0], ifname2, 'bss-2-dup.conf')
        raise Exception("BSS add succeeded unexpectedly")
    except Exception, e:
        if "Could not add hostapd BSS" in str(e):
            pass
        else:
            raise
Пример #16
0
def test_ap_duplicate_bssid(dev, apdev):
    """Duplicate BSSID"""
    params = {"ssid": "test"}
    hapd = hostapd.add_ap(apdev[0], params, no_enable=True)
    hapd.enable()
    ifname2 = apdev[0]['ifname'] + '-2'
    ifname3 = apdev[0]['ifname'] + '-3'
    # "BSS 'wlan3-2' may not have BSSID set to the MAC address of the radio"
    try:
        hostapd.add_bss(apdev[0], ifname2, 'bss-2-dup.conf')
        raise Exception("BSS add succeeded unexpectedly")
    except Exception, e:
        if "Could not add hostapd BSS" in str(e):
            pass
        else:
            raise
Пример #17
0
def test_ap_multi_bss(dev, apdev):
    """Multiple BSSes with hostapd"""
    ifname1 = apdev[0]['ifname']
    ifname2 = apdev[0]['ifname'] + '-2'
    hapd1 = hostapd.add_bss(apdev[0], ifname1, 'bss-1.conf')
    hapd2 = hostapd.add_bss(apdev[0], ifname2, 'bss-2.conf')
    dev[0].connect("bss-1", key_mgmt="NONE", scan_freq="2412")
    dev[1].connect("bss-2", key_mgmt="NONE", scan_freq="2412")

    hwsim_utils.test_connectivity(dev[0], hapd1)
    hwsim_utils.test_connectivity(dev[1], hapd2)

    sta0 = hapd1.get_sta(dev[0].own_addr())
    sta1 = hapd2.get_sta(dev[1].own_addr())
    if 'rx_packets' not in sta0 or int(sta0['rx_packets']) < 1:
        raise Exception("sta0 did not report receiving packets")
    if 'rx_packets' not in sta1 or int(sta1['rx_packets']) < 1:
        raise Exception("sta1 did not report receiving packets")
Пример #18
0
def test_ap_multi_bss(dev, apdev):
    """Multiple BSSes with hostapd"""
    ifname1 = apdev[0]['ifname']
    ifname2 = apdev[0]['ifname'] + '-2'
    hapd1 = hostapd.add_bss(apdev[0], ifname1, 'bss-1.conf')
    hapd2 = hostapd.add_bss(apdev[0], ifname2, 'bss-2.conf')
    dev[0].connect("bss-1", key_mgmt="NONE", scan_freq="2412")
    dev[1].connect("bss-2", key_mgmt="NONE", scan_freq="2412")

    hwsim_utils.test_connectivity(dev[0], hapd1)
    hwsim_utils.test_connectivity(dev[1], hapd2)

    sta0 = hapd1.get_sta(dev[0].own_addr())
    sta1 = hapd2.get_sta(dev[1].own_addr())
    if 'rx_packets' not in sta0 or int(sta0['rx_packets']) < 1:
        raise Exception("sta0 did not report receiving packets")
    if 'rx_packets' not in sta1 or int(sta1['rx_packets']) < 1:
        raise Exception("sta1 did not report receiving packets")
Пример #19
0
def test_ap_bss_add_out_of_memory(dev, apdev):
    """Running out of memory while adding a BSS"""
    hapd2 = hostapd.add_ap(apdev[1]["ifname"], {"ssid": "open"})

    ifname1 = apdev[0]["ifname"]
    ifname2 = apdev[0]["ifname"] + "-2"

    hapd_bss_out_of_mem(hapd2, "phy3", "bss-1.conf", 1, "hostapd_add_iface")
    for i in range(1, 3):
        hapd_bss_out_of_mem(hapd2, "phy3", "bss-1.conf", i, "hostapd_interface_init_bss")
    hapd_bss_out_of_mem(hapd2, "phy3", "bss-1.conf", 1, "ieee802_11_build_ap_params")

    hostapd.add_bss("phy3", ifname1, "bss-1.conf")

    hapd_bss_out_of_mem(hapd2, "phy3", "bss-2.conf", 1, "hostapd_interface_init_bss")
    hapd_bss_out_of_mem(hapd2, "phy3", "bss-2.conf", 1, "ieee802_11_build_ap_params")

    hostapd.add_bss("phy3", ifname2, "bss-2.conf")
    hostapd.remove_bss(ifname2)
    hostapd.remove_bss(ifname1)
Пример #20
0
def test_ap_multi_bss(dev, apdev):
    """Multiple BSSes with hostapd"""
    ifname1 = apdev[0]["ifname"]
    ifname2 = apdev[0]["ifname"] + "-2"
    hostapd.add_bss("phy3", ifname1, "bss-1.conf")
    hostapd.add_bss("phy3", ifname2, "bss-2.conf")
    dev[0].connect("bss-1", key_mgmt="NONE", scan_freq="2412")
    dev[1].connect("bss-2", key_mgmt="NONE", scan_freq="2412")

    hapd1 = hostapd.Hostapd(ifname1)
    hapd2 = hostapd.Hostapd(ifname2)

    hwsim_utils.test_connectivity(dev[0], hapd1)
    hwsim_utils.test_connectivity(dev[1], hapd2)

    sta0 = hapd1.get_sta(dev[0].own_addr())
    sta1 = hapd2.get_sta(dev[1].own_addr())
    if "rx_packets" not in sta0 or int(sta0["rx_packets"]) < 1:
        raise Exception("sta0 did not report receiving packets")
    if "rx_packets" not in sta1 or int(sta1["rx_packets"]) < 1:
        raise Exception("sta1 did not report receiving packets")
Пример #21
0
def run_owe_transition_mode_multi_bss(dev, apdev):
    if "OWE" not in dev[0].get_capability("key_mgmt"):
        raise HwsimSkip("OWE not supported")
    ifname1 = apdev[0]['ifname']
    ifname2 = apdev[0]['ifname'] + '-2'
    hapd1 = hostapd.add_bss(apdev[0], ifname1, 'owe-bss-1.conf')
    hapd2 = hostapd.add_bss(apdev[0], ifname2, 'owe-bss-2.conf')

    bssid = hapd1.own_addr()
    bssid2 = hapd2.own_addr()

    # Beaconing with the OWE Transition Mode element can start only once both
    # BSSs are enabled, so the very first Beacon frame may go out without this
    # element. Wait a bit to avoid getting incomplete scan results.
    time.sleep(0.1)

    dev[0].request("SCAN_INTERVAL 1")
    dev[0].scan_for_bss(bssid2, freq="2412")
    dev[0].scan_for_bss(bssid, freq="2412")
    dev[0].connect("transition-mode-open", key_mgmt="OWE")
    hwsim_utils.test_connectivity(dev[0], hapd2)
    val = dev[0].get_status_field("key_mgmt")
    if val != "OWE":
        raise Exception("Unexpected key_mgmt: " + val)
Пример #22
0
def test_ap_bss_add_out_of_memory(dev, apdev):
    """Running out of memory while adding a BSS"""
    hapd2 = hostapd.add_ap(apdev[1]['ifname'], { "ssid": "open" })

    ifname1 = apdev[0]['ifname']
    ifname2 = apdev[0]['ifname'] + '-2'

    hapd_bss_out_of_mem(hapd2, 'phy3', 'bss-1.conf', 1, 'hostapd_add_iface')
    for i in range(1, 3):
        hapd_bss_out_of_mem(hapd2, 'phy3', 'bss-1.conf',
                            i, 'hostapd_interface_init_bss')
    hapd_bss_out_of_mem(hapd2, 'phy3', 'bss-1.conf',
                        1, 'ieee802_11_build_ap_params')

    hostapd.add_bss('phy3', ifname1, 'bss-1.conf')

    hapd_bss_out_of_mem(hapd2, 'phy3', 'bss-2.conf',
                        1, 'hostapd_interface_init_bss')
    hapd_bss_out_of_mem(hapd2, 'phy3', 'bss-2.conf',
                        1, 'ieee802_11_build_ap_params')

    hostapd.add_bss('phy3', ifname2, 'bss-2.conf')
    hostapd.remove_bss(ifname2)
    hostapd.remove_bss(ifname1)
Пример #23
0
def test_olbc_table_limit(dev, apdev):
    """OLBC AP table size limit"""
    ifname1 = apdev[0]['ifname']
    ifname2 = apdev[0]['ifname'] + '-2'
    ifname3 = apdev[0]['ifname'] + '-3'
    hostapd.add_bss('phy3', ifname1, 'bss-1.conf')
    hostapd.add_bss('phy3', ifname2, 'bss-2.conf')
    hostapd.add_bss('phy3', ifname3, 'bss-3.conf')

    params = {"ssid": "test-olbc", "channel": "1", "ap_table_max_size": "2"}
    hapd = hostapd.add_ap(apdev[1]['ifname'], params)

    time.sleep(0.3)
    with alloc_fail(hapd, 1, "ap_list_process_beacon"):
        time.sleep(0.3)
    hapd.set("ap_table_max_size", "1")
    time.sleep(0.3)
    hapd.set("ap_table_max_size", "0")
    time.sleep(0.3)
Пример #24
0
def test_olbc_table_limit(dev, apdev):
    """OLBC AP table size limit"""
    ifname1 = apdev[0]['ifname']
    ifname2 = apdev[0]['ifname'] + '-2'
    ifname3 = apdev[0]['ifname'] + '-3'
    hostapd.add_bss('phy3', ifname1, 'bss-1.conf')
    hostapd.add_bss('phy3', ifname2, 'bss-2.conf')
    hostapd.add_bss('phy3', ifname3, 'bss-3.conf')

    params = { "ssid": "test-olbc",
               "channel": "1",
               "ap_table_max_size": "2" }
    hapd = hostapd.add_ap(apdev[1]['ifname'], params)

    time.sleep(0.3)
    with alloc_fail(hapd, 1, "ap_list_process_beacon"):
        time.sleep(0.3)
    hapd.set("ap_table_max_size", "1")
    time.sleep(0.3)
    hapd.set("ap_table_max_size", "0")
    time.sleep(0.3)
Пример #25
0
def test_ap_bss_add_remove(dev, apdev):
    """Dynamic BSS add/remove operations with hostapd"""
    ifname1 = apdev[0]['ifname']
    ifname2 = apdev[0]['ifname'] + '-2'
    ifname3 = apdev[0]['ifname'] + '-3'
    logger.info("Set up three BSSes one by one")
    hostapd.add_bss('phy3', ifname1, 'bss-1.conf')
    multi_check(dev, [True, False, False])
    hostapd.add_bss('phy3', ifname2, 'bss-2.conf')
    multi_check(dev, [True, True, False])
    hostapd.add_bss('phy3', ifname3, 'bss-3.conf')
    multi_check(dev, [True, True, True])

    logger.info("Remove the last BSS and re-add it")
    hostapd.remove_bss(ifname3)
    multi_check(dev, [True, True, False])
    hostapd.add_bss('phy3', ifname3, 'bss-3.conf')
    multi_check(dev, [True, True, True])

    logger.info("Remove the middle BSS and re-add it")
    hostapd.remove_bss(ifname2)
    multi_check(dev, [True, False, True])
    hostapd.add_bss('phy3', ifname2, 'bss-2.conf')
    multi_check(dev, [True, True, True])

    logger.info("Remove the first BSS and re-add it and other BSSs")
    hostapd.remove_bss(ifname1)
    multi_check(dev, [False, False, False])
    hostapd.add_bss('phy3', ifname1, 'bss-1.conf')
    hostapd.add_bss('phy3', ifname2, 'bss-2.conf')
    hostapd.add_bss('phy3', ifname3, 'bss-3.conf')
    multi_check(dev, [True, True, True])

    logger.info("Remove two BSSes and re-add them")
    hostapd.remove_bss(ifname2)
    multi_check(dev, [True, False, True])
    hostapd.remove_bss(ifname3)
    multi_check(dev, [True, False, False])
    hostapd.add_bss('phy3', ifname2, 'bss-2.conf')
    multi_check(dev, [True, True, False])
    hostapd.add_bss('phy3', ifname3, 'bss-3.conf')
    multi_check(dev, [True, True, True])

    logger.info("Remove three BSSes in and re-add them")
    hostapd.remove_bss(ifname3)
    multi_check(dev, [True, True, False])
    hostapd.remove_bss(ifname2)
    multi_check(dev, [True, False, False])
    hostapd.remove_bss(ifname1)
    multi_check(dev, [False, False, False])
    hostapd.add_bss('phy3', ifname1, 'bss-1.conf')
    multi_check(dev, [True, False, False])
    hostapd.add_bss('phy3', ifname2, 'bss-2.conf')
    multi_check(dev, [True, True, False])
    hostapd.add_bss('phy3', ifname3, 'bss-3.conf')
    multi_check(dev, [True, True, True])

    logger.info("Test error handling if a duplicate ifname is tried")
    hostapd.add_bss('phy3', ifname3, 'bss-3.conf', ignore_error=True)
    multi_check(dev, [True, True, True])
Пример #26
0
    params = {"ssid": "test"}
    hapd = hostapd.add_ap(apdev[0], params, no_enable=True)
    hapd.enable()
    ifname2 = apdev[0]['ifname'] + '-2'
    ifname3 = apdev[0]['ifname'] + '-3'
    # "BSS 'wlan3-2' may not have BSSID set to the MAC address of the radio"
    try:
        hostapd.add_bss(apdev[0], ifname2, 'bss-2-dup.conf')
        raise Exception("BSS add succeeded unexpectedly")
    except Exception, e:
        if "Could not add hostapd BSS" in str(e):
            pass
        else:
            raise

    hostapd.add_bss(apdev[0], ifname3, 'bss-3.conf')

    dev[0].connect("test", key_mgmt="NONE", scan_freq="2412")
    dev[0].request("DISCONNECT")
    dev[0].wait_disconnected()

    hapd.set("bssid", "02:00:00:00:03:02")
    hapd.disable()
    # "Duplicate BSSID 02:00:00:00:03:02 on interface 'wlan3-3' and 'wlan3'."
    if "FAIL" not in hapd.request("ENABLE"):
        raise Exception("ENABLE with duplicate BSSID succeeded unexpectedly")


def test_ap_bss_config_file(dev, apdev, params):
    """hostapd BSS config file"""
    pidfile = os.path.join(params['logdir'], "ap_bss_config_file-hostapd.pid")
Пример #27
0
    params = { "ssid": "test" }
    hapd = hostapd.add_ap(apdev[0], params, no_enable=True)
    hapd.enable()
    ifname2 = apdev[0]['ifname'] + '-2'
    ifname3 = apdev[0]['ifname'] + '-3'
    # "BSS 'wlan3-2' may not have BSSID set to the MAC address of the radio"
    try:
        hostapd.add_bss(apdev[0], ifname2, 'bss-2-dup.conf')
        raise Exception("BSS add succeeded unexpectedly")
    except Exception, e:
        if "Could not add hostapd BSS" in str(e):
            pass
        else:
            raise

    hostapd.add_bss(apdev[0], ifname3, 'bss-3.conf')

    dev[0].connect("test", key_mgmt="NONE", scan_freq="2412")
    dev[0].request("DISCONNECT")
    dev[0].wait_disconnected()

    hapd.set("bssid", "02:00:00:00:03:02")
    hapd.disable()
    # "Duplicate BSSID 02:00:00:00:03:02 on interface 'wlan3-3' and 'wlan3'."
    if "FAIL" not in hapd.request("ENABLE"):
        raise Exception("ENABLE with duplicate BSSID succeeded unexpectedly")

def test_ap_bss_config_file(dev, apdev, params):
    """hostapd BSS config file"""
    pidfile = os.path.join(params['logdir'], "ap_bss_config_file-hostapd.pid")
    logfile = os.path.join(params['logdir'], "ap_bss_config_file-hostapd-log")
Пример #28
0
def test_ap_bss_add_remove_during_ht_scan(dev, apdev):
    """Dynamic BSS add during HT40 co-ex scan"""
    ifname1 = apdev[0]['ifname']
    ifname2 = apdev[0]['ifname'] + '-2'
    hostapd.add_bss('phy3', ifname1, 'bss-ht40-1.conf')
    hostapd.add_bss('phy3', ifname2, 'bss-ht40-2.conf')
    multi_check(dev, [True, True])
    hostapd.remove_bss(ifname2)
    hostapd.remove_bss(ifname1)

    hostapd.add_bss('phy3', ifname1, 'bss-ht40-1.conf')
    hostapd.add_bss('phy3', ifname2, 'bss-ht40-2.conf')
    hostapd.remove_bss(ifname2)
    multi_check(dev, [True, False])
    hostapd.remove_bss(ifname1)

    hostapd.add_bss('phy3', ifname1, 'bss-ht40-1.conf')
    hostapd.add_bss('phy3', ifname2, 'bss-ht40-2.conf')
    hostapd.remove_bss(ifname1)
    multi_check(dev, [False, False])
Пример #29
0
def test_ap_bss_add_remove_during_ht_scan(dev, apdev):
    """Dynamic BSS add during HT40 co-ex scan"""
    ifname1 = apdev[0]['ifname']
    ifname2 = apdev[0]['ifname'] + '-2'
    hostapd.add_bss('phy3', ifname1, 'bss-ht40-1.conf')
    hostapd.add_bss('phy3', ifname2, 'bss-ht40-2.conf')
    multi_check(dev, [ True, True ])
    hostapd.remove_bss(ifname2)
    hostapd.remove_bss(ifname1)

    hostapd.add_bss('phy3', ifname1, 'bss-ht40-1.conf')
    hostapd.add_bss('phy3', ifname2, 'bss-ht40-2.conf')
    hostapd.remove_bss(ifname2)
    multi_check(dev, [ True, False ])
    hostapd.remove_bss(ifname1)

    hostapd.add_bss('phy3', ifname1, 'bss-ht40-1.conf')
    hostapd.add_bss('phy3', ifname2, 'bss-ht40-2.conf')
    hostapd.remove_bss(ifname1)
    multi_check(dev, [ False, False ])
Пример #30
0
def test_ap_bss_add_remove(dev, apdev):
    """Dynamic BSS add/remove operations with hostapd"""
    ifname1 = apdev[0]['ifname']
    ifname2 = apdev[0]['ifname'] + '-2'
    ifname3 = apdev[0]['ifname'] + '-3'
    logger.info("Set up three BSSes one by one")
    hostapd.add_bss('phy3', ifname1, 'bss-1.conf')
    multi_check(dev, [ True, False, False ])
    hostapd.add_bss('phy3', ifname2, 'bss-2.conf')
    multi_check(dev, [ True, True, False ])
    hostapd.add_bss('phy3', ifname3, 'bss-3.conf')
    multi_check(dev, [ True, True, True ])

    logger.info("Remove the last BSS and re-add it")
    hostapd.remove_bss(ifname3)
    multi_check(dev, [ True, True, False ])
    hostapd.add_bss('phy3', ifname3, 'bss-3.conf')
    multi_check(dev, [ True, True, True ])

    logger.info("Remove the middle BSS and re-add it")
    hostapd.remove_bss(ifname2)
    multi_check(dev, [ True, False, True ])
    hostapd.add_bss('phy3', ifname2, 'bss-2.conf')
    multi_check(dev, [ True, True, True ])

    logger.info("Remove the first BSS and re-add it and other BSSs")
    hostapd.remove_bss(ifname1)
    multi_check(dev, [ False, False, False ])
    hostapd.add_bss('phy3', ifname1, 'bss-1.conf')
    hostapd.add_bss('phy3', ifname2, 'bss-2.conf')
    hostapd.add_bss('phy3', ifname3, 'bss-3.conf')
    multi_check(dev, [ True, True, True ])

    logger.info("Remove two BSSes and re-add them")
    hostapd.remove_bss(ifname2)
    multi_check(dev, [ True, False, True ])
    hostapd.remove_bss(ifname3)
    multi_check(dev, [ True, False, False ])
    hostapd.add_bss('phy3', ifname2, 'bss-2.conf')
    multi_check(dev, [ True, True, False ])
    hostapd.add_bss('phy3', ifname3, 'bss-3.conf')
    multi_check(dev, [ True, True, True ])

    logger.info("Remove three BSSes in and re-add them")
    hostapd.remove_bss(ifname3)
    multi_check(dev, [ True, True, False ])
    hostapd.remove_bss(ifname2)
    multi_check(dev, [ True, False, False ])
    hostapd.remove_bss(ifname1)
    multi_check(dev, [ False, False, False ])
    hostapd.add_bss('phy3', ifname1, 'bss-1.conf')
    multi_check(dev, [ True, False, False ])
    hostapd.add_bss('phy3', ifname2, 'bss-2.conf')
    multi_check(dev, [ True, True, False ])
    hostapd.add_bss('phy3', ifname3, 'bss-3.conf')
    multi_check(dev, [ True, True, True ])

    logger.info("Test error handling if a duplicate ifname is tried")
    hostapd.add_bss('phy3', ifname3, 'bss-3.conf', ignore_error=True)
    multi_check(dev, [ True, True, True ])
Пример #31
0
def test_ap_bss_add_remove_during_ht_scan(dev, apdev):
    """Dynamic BSS add during HT40 co-ex scan"""
    ifname1 = apdev[0]["ifname"]
    ifname2 = apdev[0]["ifname"] + "-2"
    hostapd.add_bss("phy3", ifname1, "bss-ht40-1.conf")
    hostapd.add_bss("phy3", ifname2, "bss-ht40-2.conf")
    multi_check(dev, [True, True], scan_opt=False)
    hostapd.remove_bss(ifname2)
    hostapd.remove_bss(ifname1)

    hostapd.add_bss("phy3", ifname1, "bss-ht40-1.conf")
    hostapd.add_bss("phy3", ifname2, "bss-ht40-2.conf")
    hostapd.remove_bss(ifname2)
    multi_check(dev, [True, False], scan_opt=False)
    hostapd.remove_bss(ifname1)

    hostapd.add_bss("phy3", ifname1, "bss-ht40-1.conf")
    hostapd.add_bss("phy3", ifname2, "bss-ht40-2.conf")
    hostapd.remove_bss(ifname1)
    multi_check(dev, [False, False])
Пример #32
0
def _test_ap_bss_add_remove(dev, apdev):
    for i in range(3):
        dev[i].flush_scan_cache()
        dev[i].request("SCAN_INTERVAL 1")
    ifname1 = apdev[0]['ifname']
    ifname2 = apdev[0]['ifname'] + '-2'
    ifname3 = apdev[0]['ifname'] + '-3'
    logger.info("Set up three BSSes one by one")
    hostapd.add_bss('phy3', ifname1, 'bss-1.conf')
    multi_check(dev, [ True, False, False ])
    hostapd.add_bss('phy3', ifname2, 'bss-2.conf')
    multi_check(dev, [ True, True, False ])
    hostapd.add_bss('phy3', ifname3, 'bss-3.conf')
    multi_check(dev, [ True, True, True ])

    logger.info("Remove the last BSS and re-add it")
    hostapd.remove_bss(ifname3)
    multi_check(dev, [ True, True, False ])
    hostapd.add_bss('phy3', ifname3, 'bss-3.conf')
    multi_check(dev, [ True, True, True ])

    logger.info("Remove the middle BSS and re-add it")
    hostapd.remove_bss(ifname2)
    multi_check(dev, [ True, False, True ])
    hostapd.add_bss('phy3', ifname2, 'bss-2.conf')
    multi_check(dev, [ True, True, True ])

    logger.info("Remove the first BSS and re-add it and other BSSs")
    hostapd.remove_bss(ifname1)
    multi_check(dev, [ False, False, False ])
    hostapd.add_bss('phy3', ifname1, 'bss-1.conf')
    hostapd.add_bss('phy3', ifname2, 'bss-2.conf')
    hostapd.add_bss('phy3', ifname3, 'bss-3.conf')
    multi_check(dev, [ True, True, True ])

    logger.info("Remove two BSSes and re-add them")
    hostapd.remove_bss(ifname2)
    multi_check(dev, [ True, False, True ])
    hostapd.remove_bss(ifname3)
    multi_check(dev, [ True, False, False ])
    hostapd.add_bss('phy3', ifname2, 'bss-2.conf')
    multi_check(dev, [ True, True, False ])
    hostapd.add_bss('phy3', ifname3, 'bss-3.conf')
    multi_check(dev, [ True, True, True ])

    logger.info("Remove three BSSes in and re-add them")
    hostapd.remove_bss(ifname3)
    multi_check(dev, [ True, True, False ])
    hostapd.remove_bss(ifname2)
    multi_check(dev, [ True, False, False ])
    hostapd.remove_bss(ifname1)
    multi_check(dev, [ False, False, False ])
    hostapd.add_bss('phy3', ifname1, 'bss-1.conf')
    multi_check(dev, [ True, False, False ])
    hostapd.add_bss('phy3', ifname2, 'bss-2.conf')
    multi_check(dev, [ True, True, False ])
    hostapd.add_bss('phy3', ifname3, 'bss-3.conf')
    multi_check(dev, [ True, True, True ])

    logger.info("Test error handling if a duplicate ifname is tried")
    hostapd.add_bss('phy3', ifname3, 'bss-3.conf', ignore_error=True)
    multi_check(dev, [ True, True, True ])
Пример #33
0
def _test_ap_bss_add_remove(dev, apdev):
    for i in range(3):
        dev[i].request("SCAN_INTERVAL 1")
    ifname1 = apdev[0]["ifname"]
    ifname2 = apdev[0]["ifname"] + "-2"
    ifname3 = apdev[0]["ifname"] + "-3"
    logger.info("Set up three BSSes one by one")
    hostapd.add_bss("phy3", ifname1, "bss-1.conf")
    multi_check(dev, [True, False, False])
    hostapd.add_bss("phy3", ifname2, "bss-2.conf")
    multi_check(dev, [True, True, False])
    hostapd.add_bss("phy3", ifname3, "bss-3.conf")
    multi_check(dev, [True, True, True])

    logger.info("Remove the last BSS and re-add it")
    hostapd.remove_bss(ifname3)
    multi_check(dev, [True, True, False])
    hostapd.add_bss("phy3", ifname3, "bss-3.conf")
    multi_check(dev, [True, True, True])

    logger.info("Remove the middle BSS and re-add it")
    hostapd.remove_bss(ifname2)
    multi_check(dev, [True, False, True])
    hostapd.add_bss("phy3", ifname2, "bss-2.conf")
    multi_check(dev, [True, True, True])

    logger.info("Remove the first BSS and re-add it and other BSSs")
    hostapd.remove_bss(ifname1)
    multi_check(dev, [False, False, False])
    hostapd.add_bss("phy3", ifname1, "bss-1.conf")
    hostapd.add_bss("phy3", ifname2, "bss-2.conf")
    hostapd.add_bss("phy3", ifname3, "bss-3.conf")
    multi_check(dev, [True, True, True])

    logger.info("Remove two BSSes and re-add them")
    hostapd.remove_bss(ifname2)
    multi_check(dev, [True, False, True])
    hostapd.remove_bss(ifname3)
    multi_check(dev, [True, False, False])
    hostapd.add_bss("phy3", ifname2, "bss-2.conf")
    multi_check(dev, [True, True, False])
    hostapd.add_bss("phy3", ifname3, "bss-3.conf")
    multi_check(dev, [True, True, True])

    logger.info("Remove three BSSes in and re-add them")
    hostapd.remove_bss(ifname3)
    multi_check(dev, [True, True, False])
    hostapd.remove_bss(ifname2)
    multi_check(dev, [True, False, False])
    hostapd.remove_bss(ifname1)
    multi_check(dev, [False, False, False])
    hostapd.add_bss("phy3", ifname1, "bss-1.conf")
    multi_check(dev, [True, False, False])
    hostapd.add_bss("phy3", ifname2, "bss-2.conf")
    multi_check(dev, [True, True, False])
    hostapd.add_bss("phy3", ifname3, "bss-3.conf")
    multi_check(dev, [True, True, True])

    logger.info("Test error handling if a duplicate ifname is tried")
    hostapd.add_bss("phy3", ifname3, "bss-3.conf", ignore_error=True)
    multi_check(dev, [True, True, True])
Пример #34
0
def test_ap_bss_add_remove_during_ht_scan(dev, apdev):
    """Dynamic BSS add during HT40 co-ex scan"""
    for i in range(3):
        dev[i].flush_scan_cache()
    ifname1 = apdev[0]['ifname']
    ifname2 = apdev[0]['ifname'] + '-2'
    confname1 = hostapd.cfg_file(apdev[0], "bss-ht40-1.conf")
    confname2 = hostapd.cfg_file(apdev[0], "bss-ht40-2.conf")
    hapd_global = hostapd.HostapdGlobal(apdev)
    hapd_global.send_file(confname1, confname1)
    hapd_global.send_file(confname2, confname2)
    hostapd.add_bss(apdev[0], ifname1, confname1)
    hostapd.add_bss(apdev[0], ifname2, confname2)
    multi_check(apdev[0], dev, [True, True], scan_opt=False)
    hostapd.remove_bss(apdev[0], ifname2)
    hostapd.remove_bss(apdev[0], ifname1)

    hostapd.add_bss(apdev[0], ifname1, confname1)
    hostapd.add_bss(apdev[0], ifname2, confname2)
    hostapd.remove_bss(apdev[0], ifname2)
    multi_check(apdev[0], dev, [True, False], scan_opt=False)
    hostapd.remove_bss(apdev[0], ifname1)

    hostapd.add_bss(apdev[0], ifname1, confname1)
    hostapd.add_bss(apdev[0], ifname2, confname2)
    hostapd.remove_bss(apdev[0], ifname1)
    multi_check(apdev[0], dev, [False, False])
Пример #35
0
def test_ap_bss_add_remove_during_ht_scan(dev, apdev):
    """Dynamic BSS add during HT40 co-ex scan"""
    for i in range(3):
        dev[i].flush_scan_cache()
    ifname1 = apdev[0]['ifname']
    ifname2 = apdev[0]['ifname'] + '-2'
    hostapd.add_bss('phy3', ifname1, 'bss-ht40-1.conf')
    hostapd.add_bss('phy3', ifname2, 'bss-ht40-2.conf')
    multi_check(dev, [ True, True ], scan_opt=False)
    hostapd.remove_bss(ifname2)
    hostapd.remove_bss(ifname1)

    hostapd.add_bss('phy3', ifname1, 'bss-ht40-1.conf')
    hostapd.add_bss('phy3', ifname2, 'bss-ht40-2.conf')
    hostapd.remove_bss(ifname2)
    multi_check(dev, [ True, False ], scan_opt=False)
    hostapd.remove_bss(ifname1)

    hostapd.add_bss('phy3', ifname1, 'bss-ht40-1.conf')
    hostapd.add_bss('phy3', ifname2, 'bss-ht40-2.conf')
    hostapd.remove_bss(ifname1)
    multi_check(dev, [ False, False ])
Пример #36
0
def test_ap_bss_add_remove_during_ht_scan(dev, apdev):
    """Dynamic BSS add during HT40 co-ex scan"""
    for i in range(3):
        dev[i].flush_scan_cache()
    ifname1 = apdev[0]['ifname']
    ifname2 = apdev[0]['ifname'] + '-2'
    hostapd.add_bss(apdev[0], ifname1, 'bss-ht40-1.conf')
    hostapd.add_bss(apdev[0], ifname2, 'bss-ht40-2.conf')
    multi_check(dev, [True, True], scan_opt=False)
    hostapd.remove_bss(apdev[0], ifname2)
    hostapd.remove_bss(apdev[0], ifname1)

    hostapd.add_bss(apdev[0], ifname1, 'bss-ht40-1.conf')
    hostapd.add_bss(apdev[0], ifname2, 'bss-ht40-2.conf')
    hostapd.remove_bss(apdev[0], ifname2)
    multi_check(dev, [True, False], scan_opt=False)
    hostapd.remove_bss(apdev[0], ifname1)

    hostapd.add_bss(apdev[0], ifname1, 'bss-ht40-1.conf')
    hostapd.add_bss(apdev[0], ifname2, 'bss-ht40-2.conf')
    hostapd.remove_bss(apdev[0], ifname1)
    multi_check(dev, [False, False])
Пример #37
0
def _test_ap_bss_add_remove(dev, apdev):
    for i in range(3):
        dev[i].flush_scan_cache()
        dev[i].request("SCAN_INTERVAL 1")
    ifname1 = apdev[0]['ifname']
    ifname2 = apdev[0]['ifname'] + '-2'
    ifname3 = apdev[0]['ifname'] + '-3'
    logger.info("Set up three BSSes one by one")
    hostapd.add_bss(apdev[0], ifname1, 'bss-1.conf')
    multi_check(dev, [True, False, False])
    hostapd.add_bss(apdev[0], ifname2, 'bss-2.conf')
    multi_check(dev, [True, True, False])
    hostapd.add_bss(apdev[0], ifname3, 'bss-3.conf')
    multi_check(dev, [True, True, True])

    logger.info("Remove the last BSS and re-add it")
    hostapd.remove_bss(apdev[0], ifname3)
    multi_check(dev, [True, True, False])
    hostapd.add_bss(apdev[0], ifname3, 'bss-3.conf')
    multi_check(dev, [True, True, True])

    logger.info("Remove the middle BSS and re-add it")
    hostapd.remove_bss(apdev[0], ifname2)
    multi_check(dev, [True, False, True])
    hostapd.add_bss(apdev[0], ifname2, 'bss-2.conf')
    multi_check(dev, [True, True, True])

    logger.info("Remove the first BSS and re-add it and other BSSs")
    hostapd.remove_bss(apdev[0], ifname1)
    multi_check(dev, [False, False, False])
    hostapd.add_bss(apdev[0], ifname1, 'bss-1.conf')
    hostapd.add_bss(apdev[0], ifname2, 'bss-2.conf')
    hostapd.add_bss(apdev[0], ifname3, 'bss-3.conf')
    multi_check(dev, [True, True, True])

    logger.info("Remove two BSSes and re-add them")
    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.add_bss(apdev[0], ifname2, 'bss-2.conf')
    multi_check(dev, [True, True, False])
    hostapd.add_bss(apdev[0], ifname3, 'bss-3.conf')
    multi_check(dev, [True, True, True])

    logger.info("Remove three BSSes in and re-add them")
    hostapd.remove_bss(apdev[0], ifname3)
    multi_check(dev, [True, True, False])
    hostapd.remove_bss(apdev[0], ifname2)
    multi_check(dev, [True, False, False])
    hostapd.remove_bss(apdev[0], ifname1)
    multi_check(dev, [False, False, False])
    hostapd.add_bss(apdev[0], ifname1, 'bss-1.conf')
    multi_check(dev, [True, False, False])
    hostapd.add_bss(apdev[0], ifname2, 'bss-2.conf')
    multi_check(dev, [True, True, False])
    hostapd.add_bss(apdev[0], ifname3, 'bss-3.conf')
    multi_check(dev, [True, True, True])

    logger.info("Test error handling if a duplicate ifname is tried")
    hostapd.add_bss(apdev[0], ifname3, 'bss-3.conf', ignore_error=True)
    multi_check(dev, [True, True, True])