Browse Source

tests: cfg80211 connect command with bssid_hint

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
Jouni Malinen 7 years ago
parent
commit
3ed72148b0
2 changed files with 43 additions and 1 deletions
  1. 42 0
      tests/hwsim/test_connect_cmd.py
  2. 1 1
      tests/hwsim/wpasupplicant.py

+ 42 - 0
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")

+ 1 - 1
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])