[PATCH v4 24/29] tests: add terminate support for hostapd/wpa_supplicant

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Janusz Dziedzic <janusz.dziedzic@xxxxxxxxx>
---
 tests/hwsim/hostapd.py       | 20 ++++++++++++++++++++
 tests/hwsim/wpasupplicant.py |  7 +++++++
 2 files changed, 27 insertions(+)

diff --git a/tests/hwsim/hostapd.py b/tests/hwsim/hostapd.py
index e4d6bc8..3efebb9 100644
--- a/tests/hwsim/hostapd.py
+++ b/tests/hwsim/hostapd.py
@@ -102,6 +102,13 @@ class HostapdGlobal:
         words = line.split(":")
         return int(words[1])
 
+    def terminate(self):
+        self.mon.detach()
+        self.mon.close()
+        self.mon = None
+        self.ctrl.terminate()
+        self.ctrl = None
+
 class Hostapd:
     def __init__(self, ifname, bssidx=0, hostname=None, port=8877):
         self.host = wpaspy.Host(hostname, ifname)
@@ -117,6 +124,14 @@ class Hostapd:
         self.bssid = None
         self.bssidx = bssidx
 
+    def close_ctrl(self):
+        if self.mon is not None:
+            self.mon.detach()
+            self.mon.close()
+            self.mon = None
+            self.ctrl.close()
+            self.ctrl = None
+
     def own_addr(self):
         if self.bssid is None:
             self.bssid = self.get_status_field('bssid[%d]' % self.bssidx)
@@ -366,6 +381,11 @@ def remove_bss(ifname, hostname=None, port=8878):
     hapd_global = HostapdGlobal(hostname=hostname, port=port)
     hapd_global.remove(ifname)
 
+def terminate(hostname=None, port=8878):
+    logger.info("Terminating hostapd")
+    hapd_global = HostapdGlobal(hostname=hostname, port=port)
+    hapd_global.terminate()
+
 def wpa2_params(ssid=None, passphrase=None):
     params = { "wpa": "2",
                "wpa_key_mgmt": "WPA-PSK",
diff --git a/tests/hwsim/wpasupplicant.py b/tests/hwsim/wpasupplicant.py
index de814be..b167772 100644
--- a/tests/hwsim/wpasupplicant.py
+++ b/tests/hwsim/wpasupplicant.py
@@ -39,6 +39,13 @@ class WpaSupplicant:
         else:
             self.global_mon = None
 
+    def terminate(self):
+        if self.global_mon:
+            self.global_mon.detach()
+            self.global_mon = None
+            self.global_ctrl.terminate()
+            self.global_ctrl = None
+
     def close_ctrl(self):
         if self.global_mon:
             self.global_mon.detach()
-- 
1.9.1


_______________________________________________
Hostap mailing list
Hostap@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/hostap



[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux