[PATCH v2 05/17] tests: pass apdev param to HostapdGlobal()

Janusz Dziedzic janusz.dziedzic at tieto.com
Wed Apr 6 22:38:03 PDT 2016


Pass apdev param to HostapdGlobal().

Signed-off-by: Janusz Dziedzic <janusz.dziedzic at tieto.com>
---
 tests/hwsim/hostapd.py | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/tests/hwsim/hostapd.py b/tests/hwsim/hostapd.py
index 01b336e..44035b3 100644
--- a/tests/hwsim/hostapd.py
+++ b/tests/hwsim/hostapd.py
@@ -21,7 +21,13 @@ def mac2tuple(mac):
     return struct.unpack('6B', binascii.unhexlify(mac.replace(':','')))
 
 class HostapdGlobal:
-    def __init__(self, hostname=None, port=8878):
+    def __init__(self, apdev=None):
+        try:
+            hostname = apdev['hostname']
+            port = apdev['port']
+        except:
+            hostname = None
+            port = 8878
         self.host = remotehost.Host(hostname)
         self.hostname = hostname
         self.port = port
@@ -356,7 +362,7 @@ def add_ap(apdev, params, wait_enabled=True, no_enable=False, timeout=30):
             logger.info("Starting AP " + ifname + " (old add_ap argument type)")
             hostname = None
             port = 8878
-        hapd_global = HostapdGlobal(hostname=hostname, port=port)
+        hapd_global = HostapdGlobal(apdev)
         hapd_global.remove(ifname)
         hapd_global.add(ifname)
         port = hapd_global.get_ctrl_iface_port(ifname)
@@ -401,7 +407,7 @@ def add_bss(apdev, ifname, confname, phy=None, ignore_error=False):
         logger.info("Starting BSS phy=" + phy + " ifname=" + ifname)
         hostname = None
         port = 8878
-    hapd_global = HostapdGlobal(hostname=hostname, port=port)
+    hapd_global = HostapdGlobal(apdev)
     hapd_global.add_bss(phy, confname, ignore_error)
     port = hapd_global.get_ctrl_iface_port(ifname)
     hapd = Hostapd(ifname, hostname=hostname, port=port)
@@ -419,7 +425,7 @@ def add_iface(apdev, confname, ifname=None):
         logger.info("Starting interface " + ifname)
         hostname = None
         port = 8878
-    hapd_global = HostapdGlobal(hostname=hostname, port=port)
+    hapd_global = HostapdGlobal(apdev)
     hapd_global.add_iface(ifname, confname)
     port = hapd_global.get_ctrl_iface_port(ifname)
     hapd = Hostapd(ifname, hostname=hostname, port=port)
@@ -431,25 +437,19 @@ def remove_bss(apdev, ifname=None):
         ifname = apdev['ifname']
     try:
         hostname = apdev['hostname']
-        port = apdev['port']
         logger.info("Removing BSS " + hostname + "/" + port + " " + ifname)
     except:
         logger.info("Removing BSS " + ifname)
-        hostname = None
-        port = 8878
-    hapd_global = HostapdGlobal(hostname=hostname, port=port)
+    hapd_global = HostapdGlobal(apdev)
     hapd_global.remove(ifname)
 
 def terminate(apdev):
     try:
         hostname = apdev['hostname']
-        port = apdev['port']
         logger.info("Terminating hostapd " + apdev['hostname'] + "/" + apdev['port'])
     except:
-        hostname = None
-        port = 8878
         logger.info("Terminating hostapd")
-    hapd_global = HostapdGlobal(hostname=hostname, port=port)
+    hapd_global = HostapdGlobal(apdev)
     hapd_global.terminate()
 
 def wpa2_params(ssid=None, passphrase=None):
-- 
1.9.1




More information about the Hostap mailing list