Beispiel #1
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)
Beispiel #2
0
def start_dfs_ap(ap):
    ifname = ap['ifname']
    logger.info("Reset regulatory setup")
    subprocess.call(['sudo', 'iw', 'reg', 'set', '00'])
    time.sleep(1)
    subprocess.call(['sudo', 'iw', 'reg', 'set', 'FI'])
    logger.info("Starting AP " + ifname + " on DFS channel")
    hapd_global = hostapd.HostapdGlobal()
    hapd_global.remove(ifname)
    hapd_global.add(ifname)
    hapd = hostapd.Hostapd(ifname)
    if not hapd.ping():
        raise Exception("Could not ping hostapd")
    hapd.set_defaults()
    hapd.set("ssid", "dfs")
    hapd.set("country_code", "FI")
    hapd.set("ieee80211d", "1")
    hapd.set("ieee80211h", "1")
    hapd.set("hw_mode", "a")
    hapd.set("channel", "52")
    hapd.enable()

    ev = wait_dfs_event(hapd, "DFS-CAC-START", 5)
    if "DFS-CAC-START" not in ev:
        raise Exception("Unexpected DFS event")

    state = hapd.get_status_field("state")
    if state != "DFS":
        raise Exception("Unexpected interface state")

    return hapd
def test_hapd_dup_network_global_wpa2(dev, apdev):
    """hostapd and DUP_NETWORK command (WPA2"""
    passphrase = "12345678"
    src_ssid = "hapd-ctrl-src"
    dst_ssid = "hapd-ctrl-dst"

    src_params = hostapd.wpa2_params(ssid=src_ssid, passphrase=passphrase)
    src_ifname = apdev[0]['ifname']
    src_hapd = hostapd.add_ap(apdev[0], src_params)

    dst_params = {"ssid": dst_ssid}
    dst_ifname = apdev[1]['ifname']
    dst_hapd = hostapd.add_ap(apdev[1], dst_params, no_enable=True)

    hapd_global = hostapd.HostapdGlobal()

    for param in ["wpa", "wpa_passphrase", "wpa_key_mgmt", "rsn_pairwise"]:
        dup_network(hapd_global, src_ifname, dst_ifname, param)

    dst_hapd.enable()

    dev[0].connect(dst_ssid,
                   psk=passphrase,
                   proto="RSN",
                   pairwise="CCMP",
                   scan_freq="2412")
    addr = dev[0].own_addr()
    if "FAIL" in dst_hapd.request("STA " + addr):
        raise Exception("Could not connect using duplicated wpa params")
Beispiel #4
0
def test_ap_enable_disable_reenable(dev, apdev):
    """Enable, disable, re-enable AP"""
    ifname = apdev[0]['ifname']
    hapd_global = hostapd.HostapdGlobal()
    hapd_global.add(ifname)
    hapd = hostapd.Hostapd(ifname)
    hapd.set_defaults()
    hapd.set("ssid", "dynamic")
    hapd.enable()
    ev = hapd.wait_event(["AP-ENABLED"], timeout=30)
    if ev is None:
        raise Exception("AP startup timed out")
    dev[0].connect("dynamic", key_mgmt="NONE", scan_freq="2412")
    hapd.disable()
    ev = hapd.wait_event(["AP-DISABLED"], timeout=30)
    if ev is None:
        raise Exception("AP disabling timed out")
    ev = dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"])
    if ev is None:
        raise Exception("STA disconnect event timed out")
    hapd.enable()
    ev = hapd.wait_event(["AP-ENABLED"], timeout=30)
    if ev is None:
        raise Exception("AP startup timed out")
    dev[1].connect("dynamic", key_mgmt="NONE", scan_freq="2412")
    ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"])
    if ev is None:
        raise Exception("STA connect event timed out")
def test_hapd_dup_network_global_wpa(dev, apdev):
    """hostapd and DUP_NETWORK command (WPA)"""
    skip_with_fips(dev[0])
    psk = '602e323e077bc63bd80307ef4745b754b0ae0a925c2638ecd13a794b9527b9e6'
    src_ssid = "hapd-ctrl-src"
    dst_ssid = "hapd-ctrl-dst"

    src_params = hostapd.wpa_params(ssid=src_ssid)
    src_params['wpa_psk'] = psk
    src_ifname = apdev[0]['ifname']
    src_hapd = hostapd.add_ap(apdev[0], src_params)

    dst_params = {"ssid": dst_ssid}
    dst_ifname = apdev[1]['ifname']
    dst_hapd = hostapd.add_ap(apdev[1], dst_params, no_enable=True)

    hapd_global = hostapd.HostapdGlobal()

    for param in ["wpa", "wpa_psk", "wpa_key_mgmt", "wpa_pairwise"]:
        dup_network(hapd_global, src_ifname, dst_ifname, param)

    dst_hapd.enable()

    dev[0].connect(dst_ssid,
                   raw_psk=psk,
                   proto="WPA",
                   pairwise="TKIP",
                   scan_freq="2412")
    addr = dev[0].own_addr()
    if "FAIL" in dst_hapd.request("STA " + addr):
        raise Exception("Could not connect using duplicated wpa params")
Beispiel #6
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])
Beispiel #7
0
def hapd_bss_out_of_mem(hapd, phy, confname, count, func):
    with alloc_fail(hapd, count, func):
        hapd_global = hostapd.HostapdGlobal()
        res = hapd_global.ctrl.request("ADD bss_config=" + phy + ":" +
                                       confname)
        if "OK" in res:
            raise Exception("add_bss succeeded")
Beispiel #8
0
def test_ap_wps_twice(dev, apdev):
    """WPS provisioning with twice to change passphrase"""
    ssid = "test-wps-twice"
    params = { "ssid": ssid, "eap_server": "1", "wps_state": "2",
               "wpa_passphrase": "12345678", "wpa": "2",
               "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP" }
    hostapd.add_ap(apdev[0]['ifname'], params)
    hapd = hostapd.Hostapd(apdev[0]['ifname'])
    logger.info("WPS provisioning step")
    hapd.request("WPS_PBC")
    dev[0].dump_monitor()
    dev[0].request("WPS_PBC")
    ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=30)
    if ev is None:
        raise Exception("Association with the AP timed out")
    dev[0].request("DISCONNECT")

    logger.info("Restart AP with different passphrase and re-run WPS")
    hapd_global = hostapd.HostapdGlobal()
    hapd_global.remove(apdev[0]['ifname'])
    params['wpa_passphrase'] = 'another passphrase'
    hostapd.add_ap(apdev[0]['ifname'], params)
    hapd = hostapd.Hostapd(apdev[0]['ifname'])
    logger.info("WPS provisioning step")
    hapd.request("WPS_PBC")
    dev[0].dump_monitor()
    dev[0].request("WPS_PBC")
    ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=30)
    if ev is None:
        raise Exception("Association with the AP timed out")
    networks = dev[0].list_networks()
    if len(networks) > 1:
        raise Exception("Unexpected duplicated network block present")
def hostapd_oom_loop(apdev, params, start_func="main"):
    hapd = hostapd.add_ap(apdev[0], {"ssid": "ctrl"})
    hapd_global = hostapd.HostapdGlobal()

    count = 0
    for i in range(1, 1000):
        if "OK" not in hapd.request("TEST_ALLOC_FAIL %d:%s" % (i, start_func)):
            raise HwsimSkip("TEST_ALLOC_FAIL not supported")
        try:
            hostapd.add_ap(apdev[1], params, timeout=2.5)
            logger.info("Iteration %d - success" % i)
            hapd_global.remove(apdev[1]['ifname'])

            state = hapd.request('GET_ALLOC_FAIL')
            logger.info("GET_ALLOC_FAIL: " + state)
            hapd.request("TEST_ALLOC_FAIL 0:")
            if i < 3:
                raise Exception("AP setup succeeded during out-of-memory")
            if state.startswith('0:'):
                count = 0
            else:
                count += 1
                if count == 5:
                    break
        except Exception, e:
            logger.info("Iteration %d - %s" % (i, str(e)))
Beispiel #10
0
def start_dfs_ap(ap, allow_failure=False):
    ifname = ap['ifname']
    logger.info("Starting AP " + ifname + " on DFS channel")
    hapd_global = hostapd.HostapdGlobal()
    hapd_global.remove(ifname)
    hapd_global.add(ifname)
    hapd = hostapd.Hostapd(ifname)
    if not hapd.ping():
        raise Exception("Could not ping hostapd")
    hapd.set_defaults()
    hapd.set("ssid", "dfs")
    hapd.set("country_code", "FI")
    hapd.set("ieee80211d", "1")
    hapd.set("ieee80211h", "1")
    hapd.set("hw_mode", "a")
    hapd.set("channel", "52")
    hapd.enable()

    ev = wait_dfs_event(hapd, "DFS-CAC-START", 5)
    if "DFS-CAC-START" not in ev:
        raise Exception("Unexpected DFS event")

    state = hapd.get_status_field("state")
    if state != "DFS":
        if allow_failure:
            logger.info("Interface state not DFS: " + state)
            return None
        raise Exception("Unexpected interface state: " + state)

    return hapd
Beispiel #11
0
def force_prev_ap_on_24g(ap):
    # For now, make sure the last operating channel was on 2.4 GHz band to get
    # sufficient survey data from mac80211_hwsim.
    hostapd.add_ap(ap['ifname'], { "ssid": "open" })
    time.sleep(0.1)
    hapd_global = hostapd.HostapdGlobal()
    hapd_global.remove(ap['ifname'])
Beispiel #12
0
def test_ap_invalid_config2(dev, apdev):
    """Try to start AP with invalid configuration and remove interface"""
    hapd_global = hostapd.HostapdGlobal()
    ifname = apdev[0]['ifname']
    hapd = invalid_ap(hapd_global, ifname)
    logger.info("Remove interface with failed configuration")
    hapd_global.remove(ifname)
Beispiel #13
0
def start_dfs_ap(ap,
                 allow_failure=False,
                 ssid="dfs",
                 ht=True,
                 ht40=False,
                 ht40minus=False,
                 vht80=False,
                 vht20=False,
                 chanlist=None,
                 channel=None):
    ifname = ap['ifname']
    logger.info("Starting AP " + ifname + " on DFS channel")
    hapd_global = hostapd.HostapdGlobal()
    hapd_global.remove(ifname)
    hapd_global.add(ifname)
    hapd = hostapd.Hostapd(ifname)
    if not hapd.ping():
        raise Exception("Could not ping hostapd")
    hapd.set_defaults()
    hapd.set("ssid", ssid)
    hapd.set("country_code", "FI")
    hapd.set("ieee80211d", "1")
    hapd.set("ieee80211h", "1")
    hapd.set("hw_mode", "a")
    hapd.set("channel", "52")
    if not ht:
        hapd.set("ieee80211n", "0")
    if ht40:
        hapd.set("ht_capab", "[HT40+]")
    elif ht40minus:
        hapd.set("ht_capab", "[HT40-]")
        hapd.set("channel", "56")
    if vht80:
        hapd.set("ieee80211ac", "1")
        hapd.set("vht_oper_chwidth", "1")
        hapd.set("vht_oper_centr_freq_seg0_idx", "58")
    if vht20:
        hapd.set("ieee80211ac", "1")
        hapd.set("vht_oper_chwidth", "0")
        hapd.set("vht_oper_centr_freq_seg0_idx", "0")
    if chanlist:
        hapd.set("chanlist", chanlist)
    if channel:
        hapd.set("channel", str(channel))
    hapd.enable()

    ev = wait_dfs_event(hapd, "DFS-CAC-START", 5)
    if "DFS-CAC-START" not in ev:
        raise Exception("Unexpected DFS event")

    state = hapd.get_status_field("state")
    if state != "DFS":
        if allow_failure:
            logger.info("Interface state not DFS: " + state)
            if not os.path.exists("dfs"):
                raise HwsimSkip("Assume DFS testing not supported")
            raise Exception("Failed to start DFS AP")
        raise Exception("Unexpected interface state: " + state)

    return hapd
def _test_pmksa_cache_size_limit(dev, apdev):
    params = hostapd.wpa2_eap_params(ssid="test-pmksa-cache")
    id = dev[0].connect("test-pmksa-cache",
                        proto="RSN",
                        key_mgmt="WPA-EAP",
                        eap="GPSK",
                        identity="gpsk user",
                        password="******",
                        scan_freq="2412",
                        only_add_network=True)
    for i in range(33):
        bssid = apdev[0]['bssid'][0:15] + "%02x" % i
        logger.info("Iteration with BSSID " + bssid)
        params['bssid'] = bssid
        hostapd.add_ap(apdev[0], params)
        dev[0].request("BSS_FLUSH 0")
        dev[0].scan_for_bss(bssid, freq=2412, only_new=True)
        dev[0].select_network(id)
        dev[0].wait_connected()
        dev[0].request("DISCONNECT")
        dev[0].wait_disconnected()
        dev[0].dump_monitor()
        entries = len(dev[0].request("PMKSA").splitlines()) - 1
        if i == 32:
            if entries != 32:
                raise Exception(
                    "Unexpected number of PMKSA entries after expected removal of the oldest entry"
                )
        elif i + 1 != entries:
            raise Exception("Unexpected number of PMKSA entries")

        hapd = hostapd.HostapdGlobal(apdev[0])
        hapd.flush()
        hapd.remove(apdev[0]['ifname'])
Beispiel #15
0
def test_hapd_ctrl_global(dev, apdev):
    """hostapd and GET ctrl_iface command"""
    ssid = "hapd-ctrl"
    params = {"ssid": ssid}
    ifname = apdev[0]['ifname']
    hapd = hostapd.add_ap(apdev[0], params)
    hapd_global = hostapd.HostapdGlobal(apdev[0])
    res = hapd_global.request("IFNAME=" + ifname + " PING")
    if "PONG" not in res:
        raise Exception("Could not ping hostapd interface " + ifname +
                        " via global control interface")
    res = hapd_global.request("IFNAME=" + ifname + " GET version")
    if "FAIL" in res:
        raise Exception("Could not get hostapd version for " + ifname +
                        " via global control interface")
    res = hapd_global.request("IFNAME=no-such-ifname GET version")
    if "FAIL-NO-IFNAME-MATCH" not in res:
        raise Exception("Invalid ifname not reported")
    res = hapd_global.request("INTERFACES")
    if "FAIL" in res:
        raise Exception("INTERFACES command failed")
    if apdev[0]['ifname'] not in res.splitlines():
        raise Exception("AP interface missing from INTERFACES")
    res = hapd_global.request("INTERFACES ctrl")
    if "FAIL" in res:
        raise Exception("INTERFACES ctrl command failed")
    if apdev[0]['ifname'] + " ctrl_iface=" not in res:
        raise Exception("AP interface missing from INTERFACES ctrl")

    if "FAIL" not in hapd_global.request("DETACH"):
        raise Exception("DETACH succeeded unexpectedly")
def test_olbc(dev, apdev):
    """OLBC detection"""
    params = { "ssid": "test-olbc",
               "channel": "6",
               "ht_capab": "[HT40-]",
               "ap_table_expiration_time": "2" }
    hapd = hostapd.add_ap(apdev[0]['ifname'], params)
    status = hapd.get_status()
    if status['olbc'] != '0' or status['olbc_ht'] != '0':
        raise Exception("Unexpected OLBC information")

    params = { "ssid": "olbc-ap",
               "hw_mode": "b",
               "channel": "6",
               "wmm_enabled": "0" }
    hostapd.add_ap(apdev[1]['ifname'], params)
    time.sleep(0.5)
    status = hapd.get_status()
    if status['olbc'] != '1' or status['olbc_ht'] != '1':
        raise Exception("Missing OLBC information")

    hapd_global = hostapd.HostapdGlobal()
    hapd_global.remove(apdev[1]['ifname'])

    logger.info("Waiting for OLBC state to time out")
    cleared = False
    for i in range(0, 15):
        time.sleep(1)
        status = hapd.get_status()
        if status['olbc'] == '0' and status['olbc_ht'] == '0':
            cleared = True
            break
    if not cleared:
        raise Exception("OLBC state did nto time out")
Beispiel #17
0
def test_ap_remove_during_acs(dev, apdev):
    """Remove interface during ACS"""
    params = hostapd.wpa2_params(ssid="test-acs-remove", passphrase="12345678")
    params['channel'] = '0'
    ifname = apdev[0]['ifname']
    hapd = hostapd.HostapdGlobal()
    hostapd.add_ap(ifname, params)
    hapd.remove(ifname)
Beispiel #18
0
def force_prev_ap_on_5g(ap):
    # For now, make sure the last operating channel was on 5 GHz band to get
    # sufficient survey data from mac80211_hwsim.
    hostapd.add_ap(ap['ifname'], { "ssid": "open", "hw_mode": "a",
                                   "channel": "36", "country_code": "US" })
    time.sleep(0.1)
    hapd_global = hostapd.HostapdGlobal()
    hapd_global.remove(ap['ifname'])
Beispiel #19
0
 def test_is_supported():
     h = hostapd.HostapdGlobal()
     resp = h.request("FST-MANAGER TEST_REQUEST IS_SUPPORTED")
     if not resp.startswith("OK"):
         raise utils.HwsimSkip("FST not supported")
     w = wpasupplicant.WpaSupplicant(global_iface='/tmp/wpas-wlan5')
     resp = w.global_request("FST-MANAGER TEST_REQUEST IS_SUPPORTED")
     if not resp.startswith("OK"):
         raise utils.HwsimSkip("FST not supported")
Beispiel #20
0
def cleanup_macsec_hostapd():
    wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5', monitor=False)
    wpas.interface_remove("veth0")
    del wpas
    hapd = hostapd.HostapdGlobal()
    hapd.remove('veth1')
    subprocess.call(["ip", "link", "del", "veth0"],
                    stderr=open('/dev/null', 'w'))
    log_ip_link()
Beispiel #21
0
def test_ap_remove_during_ht_coex_scan(dev, apdev):
    """Remove interface during HT co-ex scan"""
    params = hostapd.wpa2_params(ssid="test-ht-remove", passphrase="12345678")
    params['channel'] = '1'
    params['ht_capab'] = "[HT40+]"
    ifname = apdev[0]['ifname']
    hapd = hostapd.HostapdGlobal()
    hostapd.add_ap(ifname, params)
    hapd.remove(ifname)
Beispiel #22
0
def test_ap_invalid_config(dev, apdev):
    """Try to start AP with invalid configuration and fix configuration"""
    hapd_global = hostapd.HostapdGlobal()
    ifname = apdev[0]['ifname']
    hapd = invalid_ap(hapd_global, ifname)

    logger.info("Fix configuration and start AP again")
    hapd.set("channel", "1")
    hapd.enable()
    dev[0].connect("invalid-config", key_mgmt="NONE", scan_freq="2412")
Beispiel #23
0
def test_hapd_ctrl_attach_errors(dev, apdev):
    """hostapd ATTACH errors"""
    params = {"ssid": "hapd-ctrl"}
    hapd = hostapd.add_ap(apdev[0], params)
    hglobal = hostapd.HostapdGlobal(apdev[0])
    with alloc_fail(hapd, 1, "ctrl_iface_attach"):
        if "FAIL" not in hapd.request("ATTACH foo"):
            raise Exception("Invalid ATTACH accepted")
    with alloc_fail(hapd, 1, "ctrl_iface_attach"):
        if "FAIL" not in hglobal.request("ATTACH foo"):
            raise Exception("Invalid ATTACH accepted")
Beispiel #24
0
 def __init__(self, iface, ssid, mode, chan, fst_group, fst_pri,
              fst_llt=None, rsn=False):
     """If fst_group is empty, then FST parameters will not be set
     If fst_llt is empty, the parameter will not be set and the default value
     is expected to be configured."""
     self.ssid = ssid
     self.mode = mode
     self.chan = chan
     self.reg_ctrl = fst_test_common.HapdRegCtrl()
     self.reg_ctrl.add_ap(iface, self.chan)
     self.global_instance = hostapd.HostapdGlobal()
     FstDevice.__init__(self, iface, fst_group, fst_pri, fst_llt, rsn)
Beispiel #25
0
def clear_pbc_overlap(dev, ifname):
    hapd_global = hostapd.HostapdGlobal()
    hapd_global.remove(ifname)
    dev[0].request("P2P_CANCEL")
    dev[1].request("P2P_CANCEL")
    dev[0].p2p_stop_find()
    dev[1].p2p_stop_find()
    dev[0].dump_monitor()
    dev[1].dump_monitor()
    time.sleep(0.1)
    dev[0].flush_scan_cache()
    dev[1].flush_scan_cache()
    time.sleep(0.1)
def clear_pbc_overlap(dev, ifname):
    hapd_global = hostapd.HostapdGlobal()
    hapd_global.remove(ifname)
    dev[0].p2p_stop_find()
    dev[1].p2p_stop_find()
    dev[0].dump_monitor()
    dev[1].dump_monitor()
    time.sleep(0.1)
    dev[0].request("BSS_FLUSH 0")
    dev[0].request("SCAN freq=2412 only_new=1")
    dev[1].request("BSS_FLUSH 0")
    dev[1].request("SCAN freq=2412 only_new=1")
    time.sleep(1)
Beispiel #27
0
def test_ap_remove_during_acs3(dev, apdev):
    """Remove second BSS during ACS in multi-BSS configuration"""
    ifname = apdev[0]['ifname']
    ifname2 = ifname + "-2"
    hapd_global = hostapd.HostapdGlobal()
    hapd_global.add(ifname)
    hapd = hostapd.Hostapd(ifname)
    hapd.set_defaults()
    hapd.set("ssid", "test-acs-remove")
    hapd.set("channel", "0")
    hapd.set("bss", ifname2)
    hapd.set("ssid", "test-acs-remove2")
    hapd.enable()
    hapd_global.remove(ifname2)
Beispiel #28
0
def run_hapd_ctrl_sta(dev, apdev):
    ssid = "hapd-ctrl-sta"
    passphrase = "12345678"
    params = hostapd.wpa2_params(ssid=ssid, passphrase=passphrase)
    hapd = hostapd.add_ap(apdev[0], params)
    hglobal = hostapd.HostapdGlobal(apdev[0])
    dev[0].request("VENDOR_ELEM_ADD 13 2102ff02")
    dev[0].connect(ssid, psk=passphrase, scan_freq="2412")
    addr = dev[0].own_addr()
    ev = hapd.wait_event(["AP-STA-CONNECTED"], timeout=2)
    if ev is None:
        raise Exception("No hostapd per-interface event reported")
    ev2 = hglobal.wait_event(["AP-STA-CONNECTED"], timeout=2)
    if ev2 is None:
        raise Exception("No hostapd global event reported")
    if not ev2.startswith("IFNAME=" + apdev[0]['ifname'] + " <"):
        raise Exception("Unexpected global event prefix: " + ev2)
    if ev not in ev2:
        raise Exception("Event mismatch (%s,%s)" % (ev, ev2))
    if "FAIL" in hapd.request("STA " + addr):
        raise Exception("Unexpected STA failure")
    if "FAIL" not in hapd.request("STA " + addr + " eapol"):
        raise Exception("Unexpected STA-eapol success")
    if "FAIL" not in hapd.request("STA " + addr + " foo"):
        raise Exception("Unexpected STA-foo success")
    if "FAIL" not in hapd.request("STA 00:11:22:33:44"):
        raise Exception("Unexpected STA success")
    if "FAIL" not in hapd.request("STA 00:11:22:33:44:55"):
        raise Exception("Unexpected STA success")

    if len(hapd.request("STA-NEXT " + addr).splitlines()) > 0:
        raise Exception("Unexpected STA-NEXT result")
    if "FAIL" not in hapd.request("STA-NEXT 00:11:22:33:44"):
        raise Exception("Unexpected STA-NEXT success")

    sta = hapd.get_sta(addr)
    logger.info("STA: " + str(sta))
    if "ext_capab" not in sta:
        raise Exception("Missing ext_capab in STA output")
    if 'ht_caps_info' not in sta:
        raise Exception("Missing ht_caps_info in STA output")
    if 'min_txpower' not in sta:
        raise Exception("Missing min_txpower in STA output")
    if 'max_txpower' not in sta:
        raise Exception("Missing min_txpower in STA output")
    if sta['min_txpower'] != '-1':
        raise Exception("Unxpected min_txpower value: " + sta['min_txpower'])
    if sta['max_txpower'] != '2':
        raise Exception("Unxpected max_txpower value: " + sta['max_txpower'])
def test_hapd_ctrl_global(dev, apdev):
    """hostapd and GET ctrl_iface command"""
    ssid = "hapd-ctrl"
    params = {"ssid": ssid}
    ifname = apdev[0]['ifname']
    hapd = hostapd.add_ap(apdev[0], params)
    hapd_global = hostapd.HostapdGlobal(apdev[0])
    res = hapd_global.request("IFNAME=" + ifname + " PING")
    if "PONG" not in res:
        raise Exception("Could not ping hostapd interface " + ifname +
                        " via global control interface")
    res = hapd_global.request("IFNAME=" + ifname + " GET version")
    if "FAIL" in res:
        raise Exception("Could not get hostapd version for " + ifname +
                        " via global control interface")
Beispiel #30
0
def test_ap_remove_during_ht_coex_scan3(dev, apdev):
    """Remove second BSS during HT co-ex scan in multi-BSS configuration"""
    ifname = apdev[0]['ifname']
    ifname2 = ifname + "-2"
    hapd_global = hostapd.HostapdGlobal()
    hapd_global.add(ifname)
    hapd = hostapd.Hostapd(ifname)
    hapd.set_defaults()
    hapd.set("ssid", "test-ht-remove")
    hapd.set("channel", "1")
    hapd.set("ht_capab", "[HT40+]")
    hapd.set("bss", ifname2)
    hapd.set("ssid", "test-ht-remove2")
    hapd.enable()
    hapd_global.remove(ifname2)