aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJanusz Dziedzic <janusz.dziedzic@tieto.com>2016-03-04 09:20:38 (GMT)
committerJouni Malinen <j@w1.fi>2016-03-05 15:44:51 (GMT)
commit4d48d44ca2225875c5d4735a41649a405dec6c1f (patch)
tree7f11de0a26766f6a544775e9635ef50b4b8ae034
parentcb73f7e84df77d3dbdd471a5840ab23b91bf650b (diff)
downloadhostap-4d48d44ca2225875c5d4735a41649a405dec6c1f.zip
hostap-4d48d44ca2225875c5d4735a41649a405dec6c1f.tar.gz
hostap-4d48d44ca2225875c5d4735a41649a405dec6c1f.tar.bz2
tests: Add HostapdGlobal.get_ctrl_iface_port()
This adds a method to get the UDP port for an interface. Signed-off-by: Janusz Dziedzic <janusz.dziedzic@tieto.com>
-rw-r--r--tests/hwsim/hostapd.py28
1 files changed, 25 insertions, 3 deletions
diff --git a/tests/hwsim/hostapd.py b/tests/hwsim/hostapd.py
index 92c8460..54bc578 100644
--- a/tests/hwsim/hostapd.py
+++ b/tests/hwsim/hostapd.py
@@ -81,6 +81,25 @@ class HostapdGlobal:
def flush(self):
self.ctrl.request("FLUSH")
+ def get_ctrl_iface_port(self, ifname):
+ if self.hostname is None:
+ return None
+
+ res = self.ctrl.request("INTERFACES ctrl")
+ lines = res.splitlines()
+ found = False
+ for line in lines:
+ words = line.split()
+ if words[0] == ifname:
+ found = True
+ break
+ if not found:
+ raise Exception("Could not find UDP port for " + ifname)
+ res = line.find("ctrl_iface=udp:")
+ if res == -1:
+ raise Exception("Wrong ctrl_interface format")
+ words = line.split(":")
+ return int(words[1])
class Hostapd:
def __init__(self, ifname, bssidx=0, hostname=None, port=8877):
@@ -291,7 +310,8 @@ def add_ap(ifname, params, wait_enabled=True, no_enable=False, timeout=30,
hapd_global = HostapdGlobal(hostname=hostname, port=port)
hapd_global.remove(ifname)
hapd_global.add(ifname)
- hapd = Hostapd(ifname, hostname=hostname)
+ port = hapd_global.get_ctrl_iface_port(ifname)
+ hapd = Hostapd(ifname, hostname=hostname, port=port)
if not hapd.ping():
raise Exception("Could not ping hostapd")
hapd.set_defaults()
@@ -326,7 +346,8 @@ def add_bss(phy, ifname, confname, ignore_error=False, hostname=None,
logger.info("Starting BSS phy=" + phy + " ifname=" + ifname)
hapd_global = HostapdGlobal(hostname=hostname, port=port)
hapd_global.add_bss(phy, confname, ignore_error)
- hapd = Hostapd(ifname, hostname=hostname)
+ port = hapd_global.get_ctrl_iface_port(ifname)
+ hapd = Hostapd(ifname, hostname=hostname, port=port)
if not hapd.ping():
raise Exception("Could not ping hostapd")
@@ -334,7 +355,8 @@ def add_iface(ifname, confname, hostname=None, port=8878):
logger.info("Starting interface " + ifname)
hapd_global = HostapdGlobal(hostname=hostname, port=port)
hapd_global.add_iface(ifname, confname)
- hapd = Hostapd(ifname, hostname=hostname)
+ port = hapd_global.get_ctrl_iface_port(ifname)
+ hapd = Hostapd(ifname, hostname=hostname, port=port)
if not hapd.ping():
raise Exception("Could not ping hostapd")