From e7d941dc3cb6f77bcab614666ee99339d90d9289 Mon Sep 17 00:00:00 2001 From: James Prestwood Date: Fri, 5 Feb 2021 10:09:10 -0800 Subject: [PATCH] auto-t: make spoof_frame more robust Sometimes scan results can come in with a MAC address which should be in the first index of addrs[] (42:xx:xx:xx:xx:xx). This causes a failure to lookup the radio path. There was also a failure path added if the radio cannot be found rather than rely on DBus to fail with a None path. The arguments to SendFrame were also changed to use the ByteArray DBus type rather than python's internal bytearray. This shouldn't have any effect, but its more consistent with how DBus arguments should be used. --- autotests/util/hwsim.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/autotests/util/hwsim.py b/autotests/util/hwsim.py index 9aa14cbc..ad4bec1f 100755 --- a/autotests/util/hwsim.py +++ b/autotests/util/hwsim.py @@ -330,15 +330,19 @@ class Hwsim(iwd.AsyncOpAbstract): obj = objects[path] for interface in obj: if interface == HWSIM_INTERFACE_INTERFACE: - if obj[interface]['Address'] == radio.addresses[0]: + if obj[interface]['Address'] == radio.addresses[0] or \ + obj[interface]['Address'] == radio.addresses[1]: radio_path = path break + if not radio_path: + raise Exception("Could not find radio %s" % radio.path) + iface = dbus.Interface(self._bus.get_object(HWSIM_SERVICE, radio_path), HWSIM_INTERFACE_INTERFACE) - iface.SendFrame(bytearray.fromhex(station.replace(':', '')), - freq, -30, bytearray.fromhex(frame)) + iface.SendFrame(dbus.ByteArray.fromhex(station.replace(':', '')), + freq, -30, dbus.ByteArray.fromhex(frame)) def get_radio(self, name): for path in self.radios: