[RFC v2 81/99] tests: Add get_iface_addr() to wpasupplicant.py
Andrei Otcheretianski
andrei.otcheretianski at intel.com
Tue Dec 23 03:52:25 PST 2025
This function is needed to get interface address by name.
It will be used for NAN testing.
Signed-off-by: Andrei Otcheretianski <andrei.otcheretianski at intel.com>
---
tests/hwsim/wpasupplicant.py | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/tests/hwsim/wpasupplicant.py b/tests/hwsim/wpasupplicant.py
index fb512eddae..04230d9726 100644
--- a/tests/hwsim/wpasupplicant.py
+++ b/tests/hwsim/wpasupplicant.py
@@ -1762,3 +1762,21 @@ class WpaSupplicant:
if addr and addr not in ev:
raise Exception("Unexpected STA address in disconnection event: " + ev)
return ev
+
+ def get_iface_addr(self, ifname):
+ ifaces = self.global_request("STATUS")
+ addr = None
+ lines = ifaces.split('\n')
+ for i, line in enumerate(lines):
+ if line.startswith('ifname=' + ifname):
+ # The address should be on the next line
+ if i + 1 < len(lines):
+ addr_line = lines[i + 1]
+ if addr_line.startswith('address='):
+ addr = addr_line.split('=')[1]
+ break
+
+ if addr is None:
+ raise Exception(f"Failed to get {ifname} address from STATUS output")
+
+ return addr
--
2.49.0
More information about the Hostap
mailing list