From 3ed72148b008f125a7130fd537897d7a80a934fa Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Fri, 12 May 2017 00:33:06 +0300 Subject: [PATCH] tests: cfg80211 connect command with bssid_hint Signed-off-by: Jouni Malinen --- tests/hwsim/test_connect_cmd.py | 42 +++++++++++++++++++++++++++++++++ tests/hwsim/wpasupplicant.py | 2 +- 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/tests/hwsim/test_connect_cmd.py b/tests/hwsim/test_connect_cmd.py index 4f2bf49ec..0c748991f 100644 --- a/tests/hwsim/test_connect_cmd.py +++ b/tests/hwsim/test_connect_cmd.py @@ -188,3 +188,45 @@ def test_connect_cmd_roam(dev, apdev): wpas.request("DISCONNECT") wpas.wait_disconnected() wpas.dump_monitor() + +def test_connect_cmd_bssid_hint(dev, apdev): + """cfg80211 connect command with bssid_hint""" + params = { "ssid": "sta-connect" } + hostapd.add_ap(apdev[0], params) + hostapd.add_ap(apdev[1], params) + + # This does not really give full coverage with mac80211_hwsim since the + # driver does not end up claiming support for driver-based BSS selection. + # Anyway, some test coverage can be achieved for setting the parameter and + # checking that it does not prevent connection with another BSSID. + + 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", + bssid_hint=apdev[0]['bssid']) + wpas.request("REMOVE_NETWORK all") + wpas.wait_disconnected() + wpas.dump_monitor() + + wpas.request("BSS_FLUSH 0") + wpas.connect("sta-connect", key_mgmt="NONE", scan_freq="2412", + bssid_hint='22:33:44:55:66:77') + wpas.request("REMOVE_NETWORK all") + wpas.wait_disconnected() + wpas.dump_monitor() + + # Additional coverage using ap_scan=2 to prevent scan entry -based selection + # within wpa_supplicant from overriding bssid_hint. + + try: + if "OK" not in wpas.request("AP_SCAN 2"): + raise Exception("Failed to set AP_SCAN 2") + wpas.request("BSS_FLUSH 0") + wpas.connect("sta-connect", key_mgmt="NONE", scan_freq="2412", + bssid_hint='22:33:44:55:66:77') + wpas.request("REMOVE_NETWORK all") + wpas.wait_disconnected() + wpas.dump_monitor() + finally: + wpas.request("AP_SCAN 1") diff --git a/tests/hwsim/wpasupplicant.py b/tests/hwsim/wpasupplicant.py index 65686d1e0..de62f5d8c 100644 --- a/tests/hwsim/wpasupplicant.py +++ b/tests/hwsim/wpasupplicant.py @@ -1025,7 +1025,7 @@ class WpaSupplicant: "ht40_intolerant", "update_identifier", "mac_addr", "erp", "bg_scan_period", "bssid_blacklist", "bssid_whitelist", "mem_only_psk", "eap_workaround", - "engine", "fils_dh_group" ] + "engine", "fils_dh_group", "bssid_hint" ] for field in not_quoted: if field in kwargs and kwargs[field]: self.set_network(id, field, kwargs[field])