From daad14ccd4de19423f32ced94476b558dc88d69d Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Sun, 6 Apr 2014 13:49:05 +0300 Subject: [PATCH] tests: WPS operations on channel 14 and on 5 GHz band Signed-off-by: Jouni Malinen --- tests/hwsim/test_ap_wps.py | 44 +++++++++++++++++++++++++++ tests/hwsim/test_nfc_wps.py | 60 +++++++++++++++++++++++++++++++++++++ 2 files changed, 104 insertions(+) diff --git a/tests/hwsim/test_ap_wps.py b/tests/hwsim/test_ap_wps.py index 52cee69b2..b6412d5ca 100644 --- a/tests/hwsim/test_ap_wps.py +++ b/tests/hwsim/test_ap_wps.py @@ -194,6 +194,50 @@ def test_ap_wps_conf(dev, apdev): if 'wpsDeviceName' not in sta or sta['wpsDeviceName'] != "Device A": raise Exception("Device name not available in STA command") +def test_ap_wps_conf_5ghz(dev, apdev): + """WPS PBC provisioning with configured AP on 5 GHz band""" + try: + ssid = "test-wps-conf" + params = { "ssid": ssid, "eap_server": "1", "wps_state": "2", + "wpa_passphrase": "12345678", "wpa": "2", + "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP", + "country_code": "FI", "hw_mode": "a", "channel": "36" } + hapd = hostapd.add_ap(apdev[0]['ifname'], params) + logger.info("WPS provisioning step") + hapd.request("WPS_PBC") + 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") + + sta = hapd.get_sta(dev[0].p2p_interface_addr()) + if 'wpsDeviceName' not in sta or sta['wpsDeviceName'] != "Device A": + raise Exception("Device name not available in STA command") + finally: + subprocess.call(['sudo', 'iw', 'reg', 'set', '00']) + +def test_ap_wps_conf_chan14(dev, apdev): + """WPS PBC provisioning with configured AP on channel 14""" + try: + ssid = "test-wps-conf" + params = { "ssid": ssid, "eap_server": "1", "wps_state": "2", + "wpa_passphrase": "12345678", "wpa": "2", + "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP", + "country_code": "JP", "hw_mode": "b", "channel": "14" } + hapd = hostapd.add_ap(apdev[0]['ifname'], params) + logger.info("WPS provisioning step") + hapd.request("WPS_PBC") + 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") + + sta = hapd.get_sta(dev[0].p2p_interface_addr()) + if 'wpsDeviceName' not in sta or sta['wpsDeviceName'] != "Device A": + raise Exception("Device name not available in STA command") + finally: + subprocess.call(['sudo', 'iw', 'reg', 'set', '00']) + def test_ap_wps_twice(dev, apdev): """WPS provisioning with twice to change passphrase""" ssid = "test-wps-twice" diff --git a/tests/hwsim/test_nfc_wps.py b/tests/hwsim/test_nfc_wps.py index 1142840ad..6b30dda9c 100644 --- a/tests/hwsim/test_nfc_wps.py +++ b/tests/hwsim/test_nfc_wps.py @@ -227,6 +227,66 @@ def test_nfc_wps_handover(dev, apdev): raise Exception("Association with the AP timed out") check_wpa2_connection(dev[0], apdev[0], ssid) +def test_nfc_wps_handover_5ghz(dev, apdev): + """Connect to WPS AP with NFC connection handover on 5 GHz band""" + try: + ssid = "test-wps-nfc-handover" + params = ap_wps_params(ssid) + params["country_code"] = "FI" + params["hw_mode"] = "a" + params["channel"] = "36" + hapd = hostapd.add_ap(apdev[0]['ifname'], params) + logger.info("NFC connection handover") + req = dev[0].request("NFC_GET_HANDOVER_REQ NDEF WPS-CR").rstrip() + if "FAIL" in req: + raise Exception("Failed to generate NFC connection handover request") + sel = hapd.request("NFC_GET_HANDOVER_SEL NDEF WPS-CR").rstrip() + if "FAIL" in sel: + raise Exception("Failed to generate NFC connection handover select") + res = hapd.request("NFC_REPORT_HANDOVER RESP WPS " + req + " " + sel) + if "FAIL" in res: + raise Exception("Failed to report NFC connection handover to to hostapd") + dev[0].dump_monitor() + res = dev[0].request("NFC_REPORT_HANDOVER INIT WPS " + req + " " + sel) + if "FAIL" in res: + raise Exception("Failed to report NFC connection handover to to wpa_supplicant") + ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=30) + if ev is None: + raise Exception("Association with the AP timed out") + check_wpa2_connection(dev[0], apdev[0], ssid) + finally: + subprocess.call(['sudo', 'iw', 'reg', 'set', '00']) + +def test_nfc_wps_handover_chan14(dev, apdev): + """Connect to WPS AP with NFC connection handover on channel 14""" + try: + ssid = "test-wps-nfc-handover" + params = ap_wps_params(ssid) + params["country_code"] = "JP" + params["hw_mode"] = "b" + params["channel"] = "14" + hapd = hostapd.add_ap(apdev[0]['ifname'], params) + logger.info("NFC connection handover") + req = dev[0].request("NFC_GET_HANDOVER_REQ NDEF WPS-CR").rstrip() + if "FAIL" in req: + raise Exception("Failed to generate NFC connection handover request") + sel = hapd.request("NFC_GET_HANDOVER_SEL NDEF WPS-CR").rstrip() + if "FAIL" in sel: + raise Exception("Failed to generate NFC connection handover select") + res = hapd.request("NFC_REPORT_HANDOVER RESP WPS " + req + " " + sel) + if "FAIL" in res: + raise Exception("Failed to report NFC connection handover to to hostapd") + dev[0].dump_monitor() + res = dev[0].request("NFC_REPORT_HANDOVER INIT WPS " + req + " " + sel) + if "FAIL" in res: + raise Exception("Failed to report NFC connection handover to to wpa_supplicant") + ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=30) + if ev is None: + raise Exception("Association with the AP timed out") + check_wpa2_connection(dev[0], apdev[0], ssid) + finally: + subprocess.call(['sudo', 'iw', 'reg', 'set', '00']) + def test_nfc_wps_handover_with_pw_token_set(dev, apdev): """Connect to WPS AP with NFC connection handover (wps_nfc_* set)""" ssid = "test-wps-nfc-handover2"