tests: Add own_addr() for both Hostapd and WpaSupplicant classes

This makes it easier to use instances of control interfaces in common
code without having to separately address hostapd and wpa_supplicant
behavior differences.

Signed-off-by: Jouni Malinen <j@w1.fi>
This commit is contained in:
Jouni Malinen 2014-10-19 20:55:02 +03:00
parent 4a6cc86272
commit f6420942cb
2 changed files with 13 additions and 0 deletions

View file

@ -54,6 +54,12 @@ class Hostapd:
self.ctrl = wpaspy.Ctrl(os.path.join(hapd_ctrl, ifname)) self.ctrl = wpaspy.Ctrl(os.path.join(hapd_ctrl, ifname))
self.mon = wpaspy.Ctrl(os.path.join(hapd_ctrl, ifname)) self.mon = wpaspy.Ctrl(os.path.join(hapd_ctrl, ifname))
self.mon.attach() self.mon.attach()
self.bssid = None
def own_addr(self):
if self.bssid is None:
self.bssid = self.get_status_field('bssid[0]')
return self.bssid
def request(self, cmd): def request(self, cmd):
logger.debug(self.ifname + ": CTRL: " + cmd) logger.debug(self.ifname + ": CTRL: " + cmd)

View file

@ -335,6 +335,13 @@ class WpaSupplicant:
def p2p_interface_addr(self): def p2p_interface_addr(self):
return self.get_group_status_field("address") return self.get_group_status_field("address")
def own_addr(self):
try:
res = self.p2p_interface_addr()
except:
res = self.p2p_dev_addr()
return res
def p2p_listen(self): def p2p_listen(self):
return self.global_request("P2P_LISTEN") return self.global_request("P2P_LISTEN")