def test_gas_fragment_with_comeback_delay_mcc(dev, apdev): """GAS fragmentation and comeback delay with mac80211_hwsim MCC enabled""" with HWSimRadio(n_channels=2) as (radio, iface): wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5') wpas.interface_add(iface) gas_fragment_and_comeback(wpas, apdev[0], frag_limit=50, comeback_delay=500)
def test_p2p_config_methods(dev): """P2P and WPS config method update""" addr0 = dev[0].p2p_dev_addr() wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5') wpas.interface_add("wlan5") addr1 = wpas.p2p_dev_addr() if "OK" not in wpas.request("SET config_methods keypad virtual_push_button"): raise Exception("Failed to set config_methods") wpas.p2p_listen() if not dev[0].discover_peer(addr1): raise Exception("Device discovery timed out") dev[0].p2p_stop_find() peer = dev[0].get_peer(addr1) if peer['config_methods'] != '0x180': raise Exception("Unexpected peer config methods(1): " + peer['config_methods']) dev[0].global_request("P2P_FLUSH") if "OK" not in wpas.request("SET config_methods virtual_display"): raise Exception("Failed to set config_methods") if not dev[0].discover_peer(addr1): raise Exception("Device discovery timed out") dev[0].p2p_stop_find() peer = dev[0].get_peer(addr1) if peer['config_methods'] != '0x8': raise Exception("Unexpected peer config methods(2): " + peer['config_methods']) wpas.p2p_stop_find()
def cleanup_macsec(): wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5', monitor=False) wpas.interface_remove("veth0") wpas.interface_remove("veth1") del wpas subprocess.call(["ip", "link", "del", "veth0"], stderr=open('/dev/null', 'w'))
def test_rfkill_p2p_discovery_p2p_dev(dev, apdev): """rfkill block/unblock P2P Discovery with P2P Device""" with HWSimRadio(use_p2p_device=True) as (radio, iface): wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5') wpas.interface_add(iface) _test_rfkill_p2p_discovery(dev[0], wpas) _test_rfkill_p2p_discovery(wpas, dev[1])
def test_ap_roam_with_reassoc_auth_timeout(dev, apdev, params): """Roam using reassoc between two APs and authentication times out""" wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5') wpas.interface_add("wlan5", drv_params="force_connect_cmd=1,force_bss_selection=1") params = hostapd.wpa2_params(ssid="test-wpa2-psk", passphrase="12345678") hapd0 = hostapd.add_ap(apdev[0], params) bssid0 = hapd0.own_addr() id = wpas.connect("test-wpa2-psk", psk="12345678", scan_freq="2412") hwsim_utils.test_connectivity(wpas, hapd0) hapd1 = hostapd.add_ap(apdev[1], params) bssid1 = hapd1.own_addr() wpas.scan_for_bss(bssid1, freq=2412) if "OK" not in wpas.request("SET_NETWORK " + str(id) + " bssid " + bssid1): raise Exception("SET_NETWORK failed") if "OK" not in wpas.request("SET ignore_auth_resp 1"): raise Exception("SET ignore_auth_resp failed") if "OK" not in wpas.request("REASSOCIATE"): raise Exception("REASSOCIATE failed") logger.info("Wait ~10s for auth timeout...") time.sleep(10) ev = wpas.wait_event(["CTRL-EVENT-SCAN-STARTED"], 12) if not ev: raise Exception("CTRL-EVENT-SCAN-STARTED not seen") b = get_blacklist(wpas) if bssid0 in b: raise Exception("Unexpected blacklist contents: " + str(b))
def test_cfg80211_tx_frame(dev, apdev, params): """cfg80211 offchannel TX frame command""" dev[0].p2p_start_go(freq='2412') go = WpaSupplicant(dev[0].group_ifname) frame = binascii.unhexlify("d0000000020000000100" + go.own_addr().replace(':', '') + "02000000010000000409506f9a090001dd5e506f9a0902020025080401001f0502006414060500585804510b0906000200000000000b1000585804510b0102030405060708090a0b0d1d000200000000000108000000000000000000101100084465766963652041110500585804510bdd190050f204104a0001101012000200011049000600372a000120") ifindex = int(go.get_driver_status_field("ifindex")) res = nl80211_frame(go, ifindex, frame, freq=2422, duration=500, offchannel_tx_ok=True) time.sleep(0.1) # note: Uncommenting this seems to remove the incorrect channel issue #nl80211_frame_wait_cancel(dev[0], ifindex, res[nl80211_attr['COOKIE']]) # note: this Action frame ends up getting sent incorrectly on 2422 MHz nl80211_frame(go, ifindex, frame, freq=2412) time.sleep(1.5) # note: also the Deauthenticate frame sent by the GO going down ends up # being transmitted incorrectly on 2422 MHz. del go out = run_tshark(os.path.join(params['logdir'], "hwsim0.pcapng"), "wlan.fc.type_subtype == 13", ["radiotap.channel.freq"]) if out is not None: freq = out.splitlines() if len(freq) != 2: raise Exception("Unexpected number of Action frames (%d)" % len(freq)) if freq[0] != "2422": raise Exception("First Action frame on unexpected channel: %s MHz" % freq[0]) if freq[1] != "2412": raise Exception("Second Action frame on unexpected channel: %s MHz" % freq[1])
def test_p2p_device_grpform2(dev, apdev): """P2P group formation with driver using cfg80211 P2P Device (reverse)""" wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5') wpas.interface_add("wlan5") [i_res, r_res] = go_neg_pin_authorized(i_dev=wpas, i_intent=15, r_dev=dev[0], r_intent=0) check_grpform_results(i_res, r_res) remove_group(wpas, dev[0])
def test_pmksa_cache_multiple_sta(dev, apdev): """PMKSA cache with multiple stations""" params = hostapd.wpa2_eap_params(ssid="test-pmksa-cache") hostapd.add_ap(apdev[0]['ifname'], params) bssid = apdev[0]['bssid'] dev[0].connect("test-pmksa-cache", proto="RSN", key_mgmt="WPA-EAP", eap="GPSK", identity="gpsk-user-session-timeout", password="******", scan_freq="2412") dev[1].connect("test-pmksa-cache", proto="RSN", key_mgmt="WPA-EAP", eap="GPSK", identity="gpsk user", password="******", scan_freq="2412") dev[2].connect("test-pmksa-cache", proto="RSN", key_mgmt="WPA-EAP", eap="GPSK", identity="gpsk-user-session-timeout", password="******", scan_freq="2412") wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5') wpas.interface_add("wlan5") wpas.connect("test-pmksa-cache", proto="RSN", key_mgmt="WPA-EAP", eap="GPSK", identity="gpsk user", password="******", scan_freq="2412") hostapd.add_ap(apdev[1]['ifname'], params) bssid2 = apdev[1]['bssid'] logger.info("Roam to AP2") for sta in [ dev[1], dev[0], dev[2], wpas ]: sta.dump_monitor() sta.scan_for_bss(bssid2, freq="2412") sta.request("ROAM " + bssid2) ev = sta.wait_event(["CTRL-EVENT-EAP-SUCCESS"], timeout=10) if ev is None: raise Exception("EAP success timed out") sta.wait_connected(timeout=10, error="Roaming timed out") logger.info("Roam back to AP1") for sta in [ dev[1], wpas, dev[0], dev[2] ]: sta.dump_monitor() sta.scan(freq="2412") sta.dump_monitor() sta.request("ROAM " + bssid) sta.wait_connected(timeout=10, error="Roaming timed out") sta.dump_monitor() time.sleep(4) logger.info("Roam back to AP2") for sta in [ dev[1], wpas, dev[0], dev[2] ]: sta.dump_monitor() sta.scan(freq="2412") sta.dump_monitor() sta.request("ROAM " + bssid2) sta.wait_connected(timeout=10, error="Roaming timed out") sta.dump_monitor()
def test_p2p_device_grpform(dev, apdev): """P2P group formation with driver using cfg80211 P2P Device""" with HWSimRadio(use_p2p_device=True) as (radio, iface): wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5') wpas.interface_add(iface) [i_res, r_res] = go_neg_pin_authorized(i_dev=dev[0], i_intent=15, r_dev=wpas, r_intent=0) check_grpform_results(i_res, r_res) remove_group(dev[0], wpas)
def test_offchannel_tx_roc_grpform2(dev, apdev): """P2P group formation(2) using cfg80211 remain-on-channel for offchannel TX""" wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5') wpas.interface_add("wlan5", drv_params="no_offchannel_tx=1") [i_res, r_res] = go_neg_pin_authorized(i_dev=wpas, i_freq=2412, r_dev=dev[0], r_freq=2412) check_grpform_results(i_res, r_res) remove_group(dev[0], wpas)
def cleanup_macsec_br(count): wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5', monitor=False) for i in range(count): wpas.interface_remove("veth%d" % i) subprocess.call(["ip", "link", "del", "veth%d" % i], stderr=open('/dev/null', 'w')) del wpas subprocess.call(["ip", "link", "set", "brveth", "down"]) subprocess.call(["brctl", "delbr", "brveth"])
def test_p2p_device_persistent_group2_no_group_iface(dev): """P2P persistent group formation and re-invocation (reverse) with cfg80211 P2P Device (no separate group interface)""" with HWSimRadio(use_p2p_device=True) as (radio, iface): wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5') wpas.interface_add(iface) wpas.global_request("SET p2p_no_group_iface 1") form(wpas, dev[0]) invite_from_cli(wpas, dev[0]) invite_from_go(wpas, dev[0])
def get_wext_interface(): if not os.path.exists("/proc/net/wireless"): raise HwsimSkip("WEXT support not included in the kernel") wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5') try: wpas.interface_add("wlan5", driver="wext") except Exception, e: wpas.close_ctrl() raise HwsimSkip("WEXT driver support not included in wpa_supplicant")
def test_ap_open_sta_enable_disable(dev, apdev): """AP with open mode and wpa_supplicant ENABLE/DISABLE_NETWORK""" hapd = hostapd.add_ap(apdev[0], { "ssid": "open" }) bssid = apdev[0]['bssid'] sta_enable_disable(dev[0], bssid) wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5') wpas.interface_add("wlan5", drv_params="force_connect_cmd=1") sta_enable_disable(wpas, bssid)
def test_sta_dynamic(dev, apdev): """Dynamically added wpa_supplicant interface""" params = hostapd.wpa2_params(ssid="sta-dynamic", passphrase="12345678") hostapd.add_ap(apdev[0]['ifname'], params) logger.info("Create a dynamic wpa_supplicant interface and connect") wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5') wpas.interface_add("wlan5") wpas.connect("sta-dynamic", psk="12345678", scan_freq="2412")
def test_p2p_device_persistent_group(dev): """P2P persistent group formation and re-invocation with cfg80211 P2P Device""" with HWSimRadio(use_p2p_device=True) as (radio, iface): wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5') wpas.interface_add(iface) wpas.global_request("SET p2p_no_group_iface 0") form(dev[0], wpas) invite_from_cli(dev[0], wpas) invite_from_go(dev[0], wpas)
def test_owe_unsupported_group_connect_cmd(dev, apdev): """Opportunistic Wireless Encryption and unsupported group using cfg80211 connect command""" try: wpas = None wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5') wpas.interface_add("wlan5", drv_params="force_connect_cmd=1") run_owe_unsupported_group([wpas], apdev) finally: if wpas: wpas.request("VENDOR_ELEM_REMOVE 13 *")
def test_p2p_device_nfc_invite(dev, apdev): """P2P NFC invitiation with driver using cfg80211 P2P Device""" with HWSimRadio(use_p2p_device=True) as (radio, iface): wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5') wpas.interface_add(iface) set_ip_addr_info(dev[0]) logger.info("Start autonomous GO") dev[0].p2p_start_go() logger.info("Write NFC Tag on the P2P Client") res = wpas.global_request("P2P_LISTEN") if "FAIL" in res: raise Exception("Failed to start Listen mode") pw = wpas.global_request("WPS_NFC_TOKEN NDEF").rstrip() if "FAIL" in pw: raise Exception("Failed to generate password token") res = wpas.global_request("P2P_SET nfc_tag 1").rstrip() if "FAIL" in res: raise Exception("Failed to enable NFC Tag for P2P static handover") sel = wpas.global_request("NFC_GET_HANDOVER_SEL NDEF P2P-CR-TAG").rstrip() if "FAIL" in sel: raise Exception("Failed to generate NFC connection handover select") logger.info("Read NFC Tag on the GO to trigger invitation") res = dev[0].request("WPS_NFC_TAG_READ " + sel) if "FAIL" in res: raise Exception("Failed to provide NFC tag contents to wpa_supplicant") ev = wpas.wait_global_event(grpform_events, timeout=20) if ev is None: raise Exception("Joining the group timed out") res = wpas.group_form_result(ev) hwsim_utils.test_connectivity_p2p(dev[0], wpas) check_ip_addr(res)
def test_macsec_psk_mka_life_time(dev, apdev, params): """MACsec PSK - MKA life time""" try: run_macsec_psk(dev, apdev, params, "macsec_psk_mka_life_time") wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5', monitor=False) wpas.interface_remove("veth1") del wpas # Wait for live peer to be removed on veth0 time.sleep(6.1) finally: cleanup_macsec()
def test_p2p_go_move_active(dev, apdev): """P2P GO stays in freq although SCM is possible""" with HWSimRadio(n_channels=2) as (radio, iface): wpas = WpaSupplicant(global_iface="/tmp/wpas-wlan5") wpas.interface_add(iface) if wpas.get_mcc() < 2: raise Exception("New radio does not support MCC") ndev = [wpas, dev[1]] _test_p2p_go_move_active(ndev, apdev)
def test_p2p_go_move_scm_multi(dev, apdev): """P2P GO move due to SCM operation preference multiple times""" with HWSimRadio(n_channels=2) as (radio, iface): wpas = WpaSupplicant(global_iface="/tmp/wpas-wlan5") wpas.interface_add(iface) if wpas.get_mcc() < 2: raise Exception("New radio does not support MCC") ndev = [wpas, dev[1]] _test_p2p_go_move_scm_multi(ndev, apdev)
def test_p2p_go_move_scm_peer_does_not_support(dev, apdev): """No P2P GO move due to SCM operation (peer does not supports)""" with HWSimRadio(n_channels=2) as (radio, iface): wpas = WpaSupplicant(global_iface="/tmp/wpas-wlan5") wpas.interface_add(iface) if wpas.get_mcc() < 2: raise Exception("New radio does not support MCC") ndev = [wpas, dev[1]] _test_p2p_go_move_scm_peer_does_not_support(ndev, apdev)
def add_wpas_interfaces(count=2): wpa = [] try: for i in range(count): wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5') wpas.interface_add("veth%d" % i, driver="macsec_linux") wpa.append(wpas) except Exception as e: if "Failed to add a dynamic wpa_supplicant interface" in str(e): raise HwsimSkip("macsec supported (wpa_supplicant CONFIG_MACSEC, CONFIG_DRIVER_MACSEC_LINUX; kernel CONFIG_MACSEC)") raise return wpa
def test_discovery_dev_id(dev): """P2P device discovery with Device ID filter""" wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5') wpas.interface_add("wlan5") wpas.request("P2P_LISTEN 1") status = wpas.global_request("STATUS") if "p2p_state=LISTEN_ONLY" not in status: raise Exception("Unexpected status: " + status) addr1 = dev[1].p2p_dev_addr() dev[1].p2p_listen() dev[0].p2p_find(social=True, dev_id="02:03:04:05:06:07") ev = dev[0].wait_event(['P2P-DEVICE-FOUND'], timeout=1) if ev: raise Exception("Unexpected P2P device found") dev[0].p2p_find(social=True, dev_id=addr1) ev = dev[0].wait_event(['P2P-DEVICE-FOUND'], timeout=2) if ev is None: raise Exception("P2P device not found") if addr1 not in ev: raise Exception("Unexpected P2P peer found") status = wpas.global_request("STATUS") for i in range(0, 2): if "p2p_state=IDLE" in status: break time.sleep(0.5) status = wpas.global_request("STATUS") if "p2p_state=IDLE" not in status: raise Exception("Unexpected status: " + status)
def test_ext_password_psk_not_found(dev, apdev): """External password storage for PSK and PSK not found""" params = hostapd.wpa2_params(ssid="ext-pw-psk", passphrase="12345678") hostapd.add_ap(apdev[0]['ifname'], params) dev[0].request("SET ext_password_backend test:psk1=12345678") dev[0].connect("ext-pw-psk", raw_psk="ext:psk2", scan_freq="2412", wait_connect=False) dev[1].request("SET ext_password_backend test:psk1=1234567") dev[1].connect("ext-pw-psk", raw_psk="ext:psk1", scan_freq="2412", wait_connect=False) dev[2].request("SET ext_password_backend test:psk1=1234567890123456789012345678901234567890123456789012345678901234567890") dev[2].connect("ext-pw-psk", raw_psk="ext:psk1", scan_freq="2412", wait_connect=False) wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5') wpas.interface_add("wlan5") wpas.request("SET ext_password_backend test:psk1=123456789012345678901234567890123456789012345678901234567890123q") wpas.connect("ext-pw-psk", raw_psk="ext:psk1", scan_freq="2412", wait_connect=False) ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=1) if ev is not None: raise Exception("Unexpected association") ev = dev[1].wait_event(["CTRL-EVENT-CONNECTED"], timeout=0.1) if ev is not None: raise Exception("Unexpected association") ev = dev[2].wait_event(["CTRL-EVENT-CONNECTED"], timeout=0.1) if ev is not None: raise Exception("Unexpected association") ev = wpas.wait_event(["CTRL-EVENT-CONNECTED"], timeout=0.1) if ev is not None: raise Exception("Unexpected association")
def test_p2p_device_autogo(dev, apdev): """P2P autogo using cfg80211 P2P Device""" with HWSimRadio(use_p2p_device=True) as (radio, iface): wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5') wpas.interface_add(iface) res = wpas.p2p_start_go() if not res['ifname'].startswith('p2p-' + iface): raise Exception("Unexpected group ifname: " + res['ifname']) bssid = wpas.get_group_status_field('bssid') dev[0].scan_for_bss(bssid, res['freq']) connect_cli(wpas, dev[0], freq=res['freq']) terminate_group(wpas, dev[0])
def test_gas_no_pending(dev, apdev): """GAS and no pending query for comeback request""" hapd = start_ap(apdev[0]) bssid = apdev[0]['bssid'] wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5') wpas.interface_add("wlan5") if "OK" not in wpas.request("P2P_SET listen_channel 1"): raise Exception("Failed to set listen channel") if "OK" not in wpas.p2p_listen(): raise Exception("Failed to start listen state") if "FAIL" in wpas.request("SET ext_mgmt_frame_handling 1"): raise Exception("Failed to enable external management frame handling") msg = struct.pack('<BBB', ACTION_CATEG_PUBLIC, GAS_COMEBACK_REQUEST, 1) req = "MGMT_TX {} {} freq=2412 wait_time=10 action={}".format(bssid, bssid, binascii.hexlify(msg)) if "OK" not in wpas.request(req): raise Exception("Could not send management frame") resp = wpas.mgmt_rx() if resp is None: raise Exception("MGMT-RX timeout") if 'payload' not in resp: raise Exception("Missing payload") gresp = parse_gas(resp['payload']) status_code = gresp['status_code'] if status_code != 60: raise Exception("Unexpected status code {} (expected 60)".format(status_code))
def test_p2p_device_grpform(dev, apdev): """P2P group formation with driver using cfg80211 P2P Device""" with HWSimRadio(use_p2p_device=True) as (radio, iface): wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5') wpas.interface_add(iface) [i_res, r_res] = go_neg_pin_authorized(i_dev=dev[0], i_intent=15, r_dev=wpas, r_intent=0) check_grpform_results(i_res, r_res) wpas.dump_monitor() remove_group(dev[0], wpas) wpas.dump_monitor() res = wpas.global_request("IFNAME=p2p-dev-" + iface + " STATUS-DRIVER") lines = res.splitlines() found = False for l in lines: try: [name,value] = l.split('=', 1) if name == "wdev_id": found = True break except ValueError: pass if not found: raise Exception("wdev_id not found")
def test_wext_wpa2_psk(dev, apdev): """WEXT driver interface with WPA2-PSK""" if not os.path.exists("/proc/net/wireless"): logger.info("WEXT support not included in the kernel") return "skip" params = hostapd.wpa2_params(ssid="wext-wpa2-psk", passphrase="12345678") hostapd.add_ap(apdev[0]['ifname'], params) wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5') try: wpas.interface_add("wlan5", driver="wext") except Exception, e: logger.info("WEXT driver support not included in wpa_supplicant") return "skip"
def _test_ap_open_wpas_in_bridge(dev, apdev): hapd = hostapd.add_ap(apdev[0], { "ssid": "open" }) br_ifname='sta-br0' ifname='wlan5' wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5') # First, try a failure case of adding an interface try: wpas.interface_add(ifname, br_ifname=br_ifname) raise Exception("Interface addition succeeded unexpectedly") except Exception, e: if "Failed to add" in str(e): logger.info("Ignore expected interface_add failure due to missing bridge interface: " + str(e)) else: raise
def test_p2p_device_group_remove(dev, apdev): """P2P group removal via the P2P ctrl interface with driver using cfg80211 P2P Device""" with HWSimRadio(use_p2p_device=True) as (radio, iface): wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5') wpas.interface_add(iface) [i_res, r_res] = go_neg_pin_authorized(i_dev=dev[0], i_intent=15, r_dev=wpas, r_intent=0) check_grpform_results(i_res, r_res) # Issue the remove request on the interface which will be removed p2p_iface_wpas = WpaSupplicant(ifname=r_res['ifname']) res = p2p_iface_wpas.request("P2P_GROUP_REMOVE *") if "OK" not in res: raise Exception("Failed to remove P2P group") ev = wpas.wait_global_event(["P2P-GROUP-REMOVED"], timeout=10) if ev is None: raise Exception("Group removal event not received") if not wpas.global_ping(): raise Exception( "Could not ping global ctrl_iface after group removal")
def test_offchannel_tx_roc_gas(dev, apdev): """GAS using cfg80211 remain-on-channel for offchannel TX""" start_ap(apdev[0]) bssid = apdev[0]['bssid'] wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5') wpas.interface_add("wlan5", drv_params="no_offchannel_tx=1") wpas.scan(freq="2412") anqp_get(wpas, bssid, 263) ev = wpas.wait_event(["GAS-QUERY-DONE"], timeout=10) if ev is None: raise Exception("GAS query timed out") if "result=SUCCESS" not in ev: raise Exception("Unexpected GAS query result")
def get_wext_interface(): if not os.path.exists("/proc/net/wireless"): raise HwsimSkip("WEXT support not included in the kernel") wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5') try: wpas.interface_add("wlan5", driver="wext") except Exception as e: wpas.close_ctrl() raise HwsimSkip("WEXT driver support not included in wpa_supplicant") return wpas
def test_ap_vht_wifi_generation(dev, apdev): """VHT and wifi_generation""" try: hapd = None params = { "ssid": "vht", "country_code": "FI", "hw_mode": "a", "channel": "36", "ht_capab": "[HT40+]", "ieee80211n": "1", "ieee80211ac": "1", "vht_oper_chwidth": "1", "vht_oper_centr_freq_seg0_idx": "42" } hapd = hostapd.add_ap(apdev[0], params) bssid = apdev[0]['bssid'] dev[0].connect("vht", key_mgmt="NONE", scan_freq="5180") status = dev[0].get_status() if 'wifi_generation' not in status: # For now, assume this is because of missing kernel support raise HwsimSkip("Association Request IE reporting not supported") #raise Exception("Missing wifi_generation information") if status['wifi_generation'] != "5": raise Exception("Unexpected wifi_generation value: " + status['wifi_generation']) wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5') wpas.interface_add("wlan5", drv_params="force_connect_cmd=1") wpas.connect("vht", key_mgmt="NONE", scan_freq="5180") status = wpas.get_status() if 'wifi_generation' not in status: # For now, assume this is because of missing kernel support raise HwsimSkip("Association Request IE reporting not supported") #raise Exception("Missing wifi_generation information (connect)") if status['wifi_generation'] != "5": raise Exception("Unexpected wifi_generation value (connect): " + status['wifi_generation']) except Exception as e: if isinstance(e, Exception) and str(e) == "AP startup failed": if not vht_supported(): raise HwsimSkip( "80 MHz channel not supported in regulatory information") raise finally: dev[0].request("DISCONNECT") clear_regdom(hapd, dev)
def test_connect_cmd_disconnect_event(dev, apdev): """Connection using cfg80211 connect command getting disconnected by the AP""" params = {"ssid": "sta-connect"} hapd = hostapd.add_ap(apdev[0]['ifname'], params) wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5') wpas.interface_add("wlan5", drv_params="force_connect_cmd=1") wpas.connect("sta-connect", key_mgmt="NONE", scan_freq="2412") if "OK" not in hapd.request("DEAUTHENTICATE " + wpas.p2p_interface_addr()): raise Exception("DEAUTHENTICATE command failed") ev = wpas.wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=5) if ev is None: raise Exception("Disconnection event timed out") # This event was actually based on deauthenticate event since we force # connect command to be used with a driver that supports auth+assoc for # testing purposes. Anyway, wait some time to allow the debug log to capture # the following NL80211_CMD_DISCONNECT event. time.sleep(0.1)
def test_pmksa_cache_opportunistic_multiple_sta(dev, apdev): """Opportunistic PMKSA caching with multiple stations""" params = hostapd.wpa2_eap_params(ssid="test-pmksa-cache") params['okc'] = "1" hostapd.add_ap(apdev[0], params) bssid = apdev[0]['bssid'] for d in dev: d.flush_scan_cache() wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5') wpas.interface_add("wlan5") wpas.flush_scan_cache() for sta in [dev[0], dev[1], dev[2], wpas]: sta.connect("test-pmksa-cache", proto="RSN", key_mgmt="WPA-EAP", eap="GPSK", identity="gpsk user", password="******", okc=True, scan_freq="2412") hostapd.add_ap(apdev[1], params) bssid2 = apdev[1]['bssid'] logger.info("Roam to AP2") for sta in [dev[2], dev[0], wpas, dev[1]]: sta.dump_monitor() sta.scan_for_bss(bssid2, freq="2412") if "OK" not in sta.request("ROAM " + bssid2): raise Exception("ROAM command failed") ev = sta.wait_event(["CTRL-EVENT-EAP-STARTED", "CTRL-EVENT-CONNECTED"], timeout=10) if ev is None: raise Exception("Roaming with the AP timed out") if "CTRL-EVENT-EAP-STARTED" in ev: raise Exception("Unexpected EAP exchange") pmksa2 = sta.get_pmksa(bssid2) if pmksa2 is None: raise Exception("No PMKSA cache entry created") sta.dump_monitor() logger.info("Roam back to AP1") for sta in [dev[0], dev[1], dev[2], wpas]: sta.dump_monitor() sta.scan_for_bss(bssid, freq="2412") sta.request("ROAM " + bssid) ev = sta.wait_event(["CTRL-EVENT-EAP-STARTED", "CTRL-EVENT-CONNECTED"], timeout=10) if ev is None: raise Exception("Roaming with the AP timed out") if "CTRL-EVENT-EAP-STARTED" in ev: raise Exception("Unexpected EAP exchange")
def test_gas_max_pending(dev, apdev): """GAS and maximum pending query limit""" hapd = start_ap(apdev[0]) hapd.set("gas_frag_limit", "50") bssid = apdev[0]['bssid'] wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5') wpas.interface_add("wlan5") if "OK" not in wpas.request("P2P_SET listen_channel 1"): raise Exception("Failed to set listen channel") if "OK" not in wpas.p2p_listen(): raise Exception("Failed to start listen state") if "FAIL" in wpas.request("SET ext_mgmt_frame_handling 1"): raise Exception("Failed to enable external management frame handling") anqp_query = struct.pack('<HHHHHHHHHH', 256, 16, 257, 258, 260, 261, 262, 263, 264, 268) gas = struct.pack('<H', len(anqp_query)) + anqp_query for dialog_token in range(1, 10): msg = struct.pack('<BBB', ACTION_CATEG_PUBLIC, GAS_INITIAL_REQUEST, dialog_token) + anqp_adv_proto() + gas req = "MGMT_TX {} {} freq=2412 wait_time=10 action={}".format(bssid, bssid, binascii.hexlify(msg)) if "OK" not in wpas.request(req): raise Exception("Could not send management frame") resp = wpas.mgmt_rx() if resp is None: raise Exception("MGMT-RX timeout") if 'payload' not in resp: raise Exception("Missing payload") gresp = parse_gas(resp['payload']) if gresp['dialog_token'] != dialog_token: raise Exception("Dialog token mismatch") status_code = gresp['status_code'] if dialog_token < 9 and status_code != 0: raise Exception("Unexpected failure status code {} for dialog token {}".format(status_code, dialog_token)) if dialog_token > 8 and status_code == 0: raise Exception("Unexpected success status code {} for dialog token {}".format(status_code, dialog_token))
def test_connect_cmd_concurrent_grpform_while_connecting(dev, apdev): """Concurrent P2P group formation while connecting to an AP using cfg80211 connect command""" logger.info("Start connection to an infrastructure AP") hapd = hostapd.add_ap(apdev[0]['ifname'], {"ssid": "test-open"}) wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5') wpas.interface_add("wlan5", drv_params="force_connect_cmd=1") wpas.connect("test-open", key_mgmt="NONE", wait_connect=False) logger.info("Form a P2P group while connecting to an AP") wpas.request("SET p2p_no_group_iface 0") [i_res, r_res] = go_neg_pin_authorized(i_dev=dev[0], i_freq=2412, r_dev=wpas, r_freq=2412) check_grpform_results(i_res, r_res) remove_group(dev[0], wpas) logger.info("Confirm AP connection after P2P group removal") hwsim_utils.test_connectivity(wpas, hapd)
def _test_he_wifi_generation(dev, apdev, conf, scan_freq): """HE and wifi_generation""" try: hapd = None params = { "ssid": "he", "country_code": "FI", "ieee80211n": "1", "ieee80211ax": "1" } params.update(conf) hapd = hostapd.add_ap(apdev[0], params) bssid = apdev[0]['bssid'] dev[0].connect("he", key_mgmt="NONE", scan_freq=scan_freq) status = dev[0].get_status() if 'wifi_generation' not in status: # For now, assume this is because of missing kernel support raise HwsimSkip("Association Request IE reporting not supported") #raise Exception("Missing wifi_generation information") if status['wifi_generation'] != "6": raise Exception("Unexpected wifi_generation value: " + status['wifi_generation']) wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5') wpas.interface_add("wlan5", drv_params="force_connect_cmd=1") wpas.connect("he", key_mgmt="NONE", scan_freq=scan_freq) status = wpas.get_status() if 'wifi_generation' not in status: # For now, assume this is because of missing kernel support raise HwsimSkip("Association Request IE reporting not supported") #raise Exception("Missing wifi_generation information (connect)") if status['wifi_generation'] != "6": raise Exception("Unexpected wifi_generation value (connect): " + status['wifi_generation']) except Exception as e: if isinstance(e, Exception) and str(e) == "AP startup failed": if not he_supported(): raise HwsimSkip( "80 MHz channel not supported in regulatory information") raise finally: dev[0].request("DISCONNECT") clear_regdom(hapd, dev)
def test_wmediumd_path_ttl(dev, apdev, params): """Mesh path request TTL""" # 0 --- 1 --- 2 --- 3 --- 4 # Test the TTL of mesh path request. # If the TTL is shorter than path, the mesh path request should be dropped. require_wmediumd_version(0, 3, 1) local_dev = [] for i in range(0, 3): local_dev.append(dev[i]) for i in range(5, 7): wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5') wpas.interface_add("wlan" + str(i)) check_mesh_support(wpas) temp_dev = wpas.request("MESH_INTERFACE_ADD ifname=mesh" + str(i)) if "FAIL" in temp_dev: raise Exception("MESH_INTERFACE_ADD failed") local_dev.append(WpaSupplicant(ifname=temp_dev)) fd, fn = tempfile.mkstemp() try: f = os.fdopen(fd, 'w') f.write(CFG3 % (local_dev[0].own_addr(), local_dev[1].own_addr(), local_dev[2].own_addr(), local_dev[3].own_addr(), local_dev[4].own_addr())) f.close() p = start_wmediumd(fn, params) try: _test_wmediumd_path_ttl(local_dev, True) _test_wmediumd_path_ttl(local_dev, False) finally: stop_wmediumd(p, params) finally: os.unlink(fn) for i in range(5, 7): wpas.interface_remove("wlan" + str(i))
def check_pasn_fils_connected_diff_channel(dev, apdev, params, key_mgmt): check_pasn_capab(dev[0]) with HWSimRadio(n_channels=2) as (radio, iface): wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5') wpas.interface_add(iface) if wpas.get_mcc() < 2: raise Exception("New radio does not support MCC") hapd = pasn_fils_setup(wpas, apdev, params, key_mgmt); # Connect to another AP on a different channel hapd1 = hostapd.add_ap(apdev[1], {"ssid": "open", "channel" : "6"}) wpas.connect("open", key_mgmt="NONE", scan_freq="2437", bg_scan_period="0") hwsim_utils.test_connectivity(wpas, hapd1) # And perform the PASN authentication with FILS check_pasn_akmp_cipher(wpas, hapd, key_mgmt, "CCMP", nid="0")
def test_connect_cmd_reject_assoc(dev, apdev): """Connection using cfg80211 connect command getting rejected""" params = {"ssid": "sta-connect", "require_ht": "1"} hostapd.add_ap(apdev[0]['ifname'], params) wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5') wpas.interface_add("wlan5", drv_params="force_connect_cmd=1") wpas.connect("sta-connect", key_mgmt="NONE", scan_freq="2412", disable_ht="1", wait_connect=False) # Reject event gets reported twice since we force connect command to be used # with a driver that supports auth+assoc for testing purposes. for i in range(0, 2): ev = wpas.wait_event(["CTRL-EVENT-ASSOC-REJECT"], timeout=15) if ev is None: raise Exception("Association rejection timed out") if "status_code=27" not in ev: raise Exception("Unexpected rejection status code")
def _test_ap_wpa2_psk_wpas_in_bridge(dev, apdev): ssid = "test-wpa2-psk" passphrase = 'qwertyuiop' params = hostapd.wpa2_params(ssid=ssid, passphrase=passphrase) hapd = hostapd.add_ap(apdev[0]['ifname'], params) br_ifname = 'sta-br0' ifname = 'wlan5' wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5') subprocess.call(['brctl', 'addbr', br_ifname]) subprocess.call(['brctl', 'setfd', br_ifname, '0']) subprocess.call(['ip', 'link', 'set', 'dev', br_ifname, 'up']) subprocess.call(['iw', ifname, 'set', '4addr', 'on']) subprocess.check_call(['brctl', 'addif', br_ifname, ifname]) wpas.interface_add(ifname, br_ifname=br_ifname) wpas.connect(ssid, psk=passphrase, scan_freq="2412")
def test_pasn_while_connected_diff_channel(dev, apdev): """PASN authentication with WPA2/CCMP AP while connected diff channel""" check_pasn_capab(dev[0]) with HWSimRadio(n_channels=2) as (radio, iface): wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5') wpas.interface_add(iface) if wpas.get_mcc() < 2: raise HwsimSkip("PASN: New radio does not support MCC") params = hostapd.wpa2_params(ssid="test-wpa2-psk", passphrase="12345678") params['channel'] = "6" hapd = start_pasn_ap(apdev[0], params) wpas.connect("test-wpa2-psk", psk="12345678", scan_freq="2437") params = pasn_ap_params("PASN", "CCMP") hapd2 = start_pasn_ap(apdev[1], params) check_pasn_akmp_cipher(wpas, hapd2, "PASN", "CCMP")
def reset_devs(dev, apdev): ok = True for d in dev: try: d.reset() except Exception as e: logger.info("Failed to reset device " + d.ifname) print(str(e)) ok = False wpas = None try: wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5', monitor=False) ifaces = wpas.global_request("INTERFACES").splitlines() for iface in ifaces: if iface.startswith("wlan"): wpas.interface_remove(iface) except Exception as e: pass if wpas: wpas.close_ctrl() del wpas try: hapd = HostapdGlobal() hapd.flush() hapd.remove('wlan3-6') hapd.remove('wlan3-5') hapd.remove('wlan3-4') hapd.remove('wlan3-3') hapd.remove('wlan3-2') for ap in apdev: hapd.remove(ap['ifname']) hapd.remove('as-erp') except Exception as e: logger.info("Failed to remove hostapd interface") print(str(e)) ok = False return ok
def get_instance(self): """Return the Hostapd/WpaSupplicant instance""" if self.instance is None: self.instance = WpaSupplicant(global_iface='/tmp/wpas-wlan5') return self.instance
class FstSTA(FstDevice): def __init__(self, iface, 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.""" FstDevice.__init__(self, iface, fst_group, fst_pri, fst_llt, rsn) self.connected = None # FstAP object the station is connected to def start(self): """Current implementation involves running another instance of wpa_supplicant with fixed FST STAs configurations. When any type of dynamic STA loading is implemented, rewrite the function similarly to FstAP.""" h = self.get_instance() h.interface_add(self.iface, drv_params="force_connect_cmd=1") if not h.global_ping(): raise Exception("Could not ping FST wpa_supplicant") if len(self.fst_group) != 0: self.send_iface_attach_request(self.iface, self.fst_group, self.fst_llt, self.fst_pri) return None def stop(self): """Removes the STA. In a static (temporary) implementation does nothing, the STA will be removed when the fst wpa_supplicant process is killed by fstap.cleanup().""" h = self.get_instance() h.dump_monitor() if len(self.fst_group) != 0: self.remove_all_sessions() self.send_iface_detach_request(self.iface) h.dump_monitor() h.interface_remove(self.iface) h.close_ctrl() del h self.instance = None def get_instance(self): """Return the Hostapd/WpaSupplicant instance""" if self.instance is None: self.instance = WpaSupplicant(global_iface='/tmp/wpas-wlan5') return self.instance def get_own_mac_address(self): """Gets the device's own MAC address""" h = self.get_instance() status = h.get_status() return status['address'] def get_actual_peer_addr(self): """Gets the peer address. A connected station address is returned""" h = self.get_instance() status = h.get_status() return status['bssid'] def grequest(self, req): """Send request on the global control interface""" logger.debug("FstSTA::grequest: " + req) h = self.get_instance() return h.global_request(req) def wait_gevent(self, events, timeout=None): """Wait for a list of events on the global interface""" h = self.get_instance() if timeout is not None: return h.wait_global_event(events, timeout=timeout) else: return h.wait_global_event(events) def scan(self, freq=None, no_wait=False, only_new=False): """Issue Scan with given parameters. Returns the BSS dictionary for the AP found (the 1st BSS found. TODO: What if the AP required is not the 1st in list?) or None if no BSS found. None call be also a result of no_wait=True. Note, request("SCAN_RESULTS") can be used to get all the results at once.""" h = self.get_instance() h.dump_monitor() h.scan(None, freq, no_wait, only_new) r = h.get_bss('0') h.dump_monitor() return r def connect(self, ap, **kwargs): """Connects to the given AP""" if not isinstance(ap, FstAP): raise Exception("Bad AP object to connect to") h = self.get_instance() hap = ap.get_instance() h.dump_monitor() h.connect(ap.get_ssid(), **kwargs) h.dump_monitor() self.connected = ap def connect_to_external_ap(self, ap, ssid, check_connection=True, **kwargs): """Connects to the given external AP""" if not isinstance(ap, hostapd.Hostapd): raise Exception("Bad AP object to connect to") h = self.get_instance() h.dump_monitor() h.connect(ssid, **kwargs) self.connected = ap if check_connection: ev = ap.wait_event(["AP-STA-CONNECTED"], timeout=10) if ev is None: self.connected = None raise Exception("No connection event received from %s" % ssid) h.dump_monitor() def disconnect(self, check_disconnect=True): """Disconnects from the AP the station is currently connected to""" if self.connected is not None: h = self.get_instance() h.dump_monitor() h.request("DISCONNECT") if check_disconnect: hap = self.connected.get_instance() ev = hap.wait_event(["AP-STA-DISCONNECTED"], timeout=10) if ev is None: raise Exception("No disconnection event received from %s" % self.connected.get_ssid()) h.dump_monitor() self.connected = None def disconnect_from_external_ap(self, check_disconnect=True): """Disconnects from the external AP the station is currently connected to""" if self.connected is not None: h = self.get_instance() h.dump_monitor() h.request("DISCONNECT") if check_disconnect: hap = self.connected ev = hap.wait_event(["AP-STA-DISCONNECTED"], timeout=10) if ev is None: raise Exception("No disconnection event received from AP") h.dump_monitor() self.connected = None def dump_monitor(self): """Dump control interface monitor events""" if self.instance: self.instance.dump_monitor()
def test_wpas_ap_params(dev): """wpa_supplicant AP mode - parameters""" wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5') wpas.interface_add("wlan5") wpas.request("SET manufacturer test") wpas.request("SET model_name test") wpas.request("SET model_number test") wpas.request("SET serial_number test") wpas.request("SET serial_number test") wpas.request("SET serial_number test") wpas.request("SET ap_vendor_elements dd0411223301") id = wpas.add_network() wpas.set_network(id, "mode", "2") wpas.set_network_quoted(id, "ssid", "wpas-ap") wpas.set_network(id, "key_mgmt", "NONE") wpas.set_network(id, "frequency", "2412") wpas.set_network(id, "scan_freq", "2412") wpas.select_network(id) wpas.wait_connected() wpas.request("DISCONNECT") wpas.wait_disconnected() wpas.request("SET beacon_int 200 3") wpas.request("SET dtim_period 3") wpas.select_network(id) wpas.wait_connected() wpas.request("DISCONNECT") wpas.wait_disconnected() wpas.set_network(id, "beacon_int", "300") wpas.set_network(id, "dtim_period", "2") wpas.select_network(id) wpas.wait_connected() if "---- AP ----" not in wpas.request("PMKSA"): raise Exception("AP section missing from PMKSA output") if "OK" not in wpas.request("PMKSA_FLUSH"): raise Exception("PMKSA_FLUSH failed") wpas.request("DISCONNECT") wpas.wait_disconnected()
def test_wpas_ap_oom(dev): """wpa_supplicant AP mode - OOM""" id = dev[0].add_network() dev[0].set_network(id, "mode", "2") dev[0].set_network_quoted(id, "ssid", "wpas-ap") dev[0].set_network_quoted(id, "psk", "1234567890") dev[0].set_network(id, "frequency", "2412") dev[0].set_network(id, "scan_freq", "2412") with alloc_fail(dev[0], 1, "=wpa_supplicant_conf_ap"): dev[0].select_network(id) dev[0].wait_disconnected() dev[0].request("REMOVE_NETWORK all") id = dev[0].add_network() dev[0].set_network(id, "mode", "2") dev[0].set_network_quoted(id, "ssid", "wpas-ap") dev[0].set_network( id, "psk", "1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef") dev[0].set_network(id, "frequency", "2412") dev[0].set_network(id, "scan_freq", "2412") with alloc_fail(dev[0], 1, "=wpa_supplicant_conf_ap"): dev[0].select_network(id) dev[0].wait_disconnected() dev[0].request("REMOVE_NETWORK all") if "WEP40" in dev[0].get_capability("group"): id = dev[0].add_network() dev[0].set_network(id, "mode", "2") dev[0].set_network_quoted(id, "ssid", "wpas-ap") dev[0].set_network(id, "key_mgmt", "NONE") dev[0].set_network_quoted(id, "wep_key0", "hello") dev[0].set_network(id, "frequency", "2412") dev[0].set_network(id, "scan_freq", "2412") with alloc_fail(dev[0], 1, "=wpa_supplicant_conf_ap"): dev[0].select_network(id) dev[0].wait_disconnected() dev[0].request("REMOVE_NETWORK all") wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5') wpas.interface_add("wlan5") wpas.request("SET manufacturer test") wpas.request("SET model_name test") wpas.request("SET model_number test") wpas.request("SET serial_number test") wpas.request("SET serial_number test") wpas.request("SET serial_number test") wpas.request("SET ap_vendor_elements dd0411223301") id = wpas.add_network() wpas.set_network(id, "mode", "2") wpas.set_network_quoted(id, "ssid", "wpas-ap") wpas.set_network(id, "key_mgmt", "NONE") wpas.set_network(id, "frequency", "2412") wpas.set_network(id, "scan_freq", "2412") for i in range(5): with alloc_fail(wpas, i, "=wpa_supplicant_conf_ap"): wpas.select_network(id) ev = dev[0].wait_event( ["CTRL-EVENT-CONNECTED", "CTRL-EVENT-DISCONNECTED"], timeout=1) wpas.request("DISCONNECT") wpas.wait_disconnected()
def test_p2p_config_methods(dev): """P2P and WPS config method update""" addr0 = dev[0].p2p_dev_addr() wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5') wpas.interface_add("wlan5") addr1 = wpas.p2p_dev_addr() if "OK" not in wpas.request( "SET config_methods keypad virtual_push_button"): raise Exception("Failed to set config_methods") wpas.p2p_listen() if not dev[0].discover_peer(addr1): raise Exception("Device discovery timed out") dev[0].p2p_stop_find() peer = dev[0].get_peer(addr1) if peer['config_methods'] != '0x180': raise Exception("Unexpected peer config methods(1): " + peer['config_methods']) dev[0].global_request("P2P_FLUSH") if "OK" not in wpas.request("SET config_methods virtual_display"): raise Exception("Failed to set config_methods") if not dev[0].discover_peer(addr1): raise Exception("Device discovery timed out") dev[0].p2p_stop_find() peer = dev[0].get_peer(addr1) if peer['config_methods'] != '0x8': raise Exception("Unexpected peer config methods(2): " + peer['config_methods']) wpas.p2p_stop_find()
def test_owe_group_negotiation_connect_cmd(dev, apdev): """Opportunistic Wireless Encryption and group negotiation (connect command)""" wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5') wpas.interface_add("wlan5", drv_params="force_connect_cmd=1") run_owe_group_negotiation(wpas, apdev)
def test_owe_transition_mode_connect_cmd(dev, apdev): """Opportunistic Wireless Encryption transition mode using cfg80211 connect command""" wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5') wpas.interface_add("wlan5", drv_params="force_connect_cmd=1") run_owe_transition_mode([wpas], apdev)
def test_radio_work_cancel(dev, apdev): """Radio work items cancelled on interface removal""" params = hostapd.wpa2_params(ssid="radio", passphrase="12345678") hostapd.add_ap(apdev[0], params) wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5') wpas.interface_add("wlan5") wpas.scan(freq="2412") id = wpas.request("RADIO_WORK add test-work-a") if "FAIL" in id: raise Exception("Failed to add radio work") ev = wpas.wait_event(["EXT-RADIO-WORK-START"]) if ev is None: raise Exception("Timeout while waiting radio work to start") if "EXT-RADIO-WORK-START " + id not in ev: raise Exception("Unexpected radio work start id") wpas.connect("radio", psk="12345678", scan_freq="2412", wait_connect=False) time.sleep(1) wpas.interface_remove("wlan5") # add to allow log file renaming wpas.interface_add("wlan5")
def start_wpas_ap(ssid): wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5') wpas.interface_add("wlan5", drv_params="use_monitor=1") id = wpas.add_network() wpas.set_network(id, "mode", "2") wpas.set_network_quoted(id, "ssid", ssid) wpas.set_network(id, "proto", "WPA2") wpas.set_network(id, "key_mgmt", "WPA-PSK-SHA256") wpas.set_network(id, "ieee80211w", "2") wpas.set_network_quoted(id, "psk", "12345678") wpas.set_network(id, "pairwise", "CCMP") wpas.set_network(id, "group", "CCMP") wpas.set_network(id, "frequency", "2412") wpas.set_network(id, "scan_freq", "2412") wpas.connect_network(id) wpas.dump_monitor() return wpas
def test_owe_pmksa_caching_connect_cmd(dev, apdev): """Opportunistic Wireless Encryption and PMKSA caching using cfg80211 connect command""" wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5') wpas.interface_add("wlan5", drv_params="force_connect_cmd=1") run_owe_pmksa_caching([wpas], apdev)