[PATCH 3/7] tests: wpasupplicant: allow to use remote wpa_cli

Janusz Dziedzic janusz.dziedzic at gmail.com
Sat Mar 9 11:42:24 PST 2024


Signed-off-by: Janusz Dziedzic <janusz.dziedzic at gmail.com>
---
 tests/hwsim/wpasupplicant.py | 30 ++++++++++++++++++++++--------
 1 file changed, 22 insertions(+), 8 deletions(-)

diff --git a/tests/hwsim/wpasupplicant.py b/tests/hwsim/wpasupplicant.py
index 8912310b9..15dce0ac9 100644
--- a/tests/hwsim/wpasupplicant.py
+++ b/tests/hwsim/wpasupplicant.py
@@ -19,7 +19,7 @@ wpas_ctrl = '/var/run/wpa_supplicant'
 
 class WpaSupplicant:
     def __init__(self, ifname=None, global_iface=None, hostname=None,
-                 port=9877, global_port=9878, monitor=True):
+                 port=9877, global_port=9878, monitor=True, remote_cli=False):
         self.monitor = monitor
         self.hostname = hostname
         self.group_ifname = None
@@ -31,6 +31,7 @@ class WpaSupplicant:
         self.ifname = None
         self.host = remotehost.Host(hostname, ifname)
         self._group_dbg = None
+        self.remote_cli = remote_cli
         if ifname:
             self.set_ifname(ifname, hostname, port)
             res = self.get_driver_status()
@@ -42,10 +43,16 @@ class WpaSupplicant:
         self.global_iface = global_iface
         if global_iface:
             if hostname != None:
-                self.global_ctrl = wpaspy.Ctrl(hostname, global_port)
-                if self.monitor:
-                    self.global_mon = wpaspy.Ctrl(hostname, global_port)
-                self.global_dbg = hostname + "/" + str(global_port) + "/"
+                if remote_cli:
+                    self.global_ctrl = wpaspy.Ctrl(global_iface, global_port, hostname=hostname)
+                    if self.monitor:
+                        self.global_mon = wpaspy.Ctrl(global_iface, global_port, hostname=hostname)
+                        self.global_dbg = hostname + "/global"
+                else:
+                    self.global_ctrl = wpaspy.Ctrl(hostname, global_port)
+                    if self.monitor:
+                        self.global_mon = wpaspy.Ctrl(hostname, global_port)
+                    self.global_dbg = hostname + "/" + str(global_port) + "/"
             else:
                 self.global_ctrl = wpaspy.Ctrl(global_iface)
                 if self.monitor:
@@ -164,9 +171,14 @@ class WpaSupplicant:
         self.remove_ifname()
         self.ifname = ifname
         if hostname != None:
-            self.ctrl = wpaspy.Ctrl(hostname, port)
-            if self.monitor:
-                self.mon = wpaspy.Ctrl(hostname, port)
+            if self.remote_cli:
+                self.ctrl = wpaspy.Ctrl(wpas_ctrl, port, hostname=hostname, ifname=ifname)
+                if self.monitor:
+                    self.mon = wpaspy.Ctrl(wpas_ctrl, port, hostname=hostname, ifname=ifname)
+            else:
+                self.ctrl = wpaspy.Ctrl(hostname, port)
+                if self.monitor:
+                    self.mon = wpaspy.Ctrl(hostname, port)
             self.host = remotehost.Host(hostname, ifname)
             self.dbg = hostname + "/" + ifname
         else:
@@ -185,6 +197,8 @@ class WpaSupplicant:
     def get_ctrl_iface_port(self, ifname):
         if self.hostname is None:
             return None
+        if self.remote_cli:
+            return None
 
         res = self.global_request("INTERFACES ctrl")
         lines = res.splitlines()
-- 
2.25.1




More information about the Hostap mailing list