3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-11-29 13:59:24 +01:00

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.
This commit is contained in:
James Prestwood 2021-02-05 10:09:10 -08:00 committed by Denis Kenzior
parent b60f564bed
commit e7d941dc3c

View File

@ -330,15 +330,19 @@ class Hwsim(iwd.AsyncOpAbstract):
obj = objects[path] obj = objects[path]
for interface in obj: for interface in obj:
if interface == HWSIM_INTERFACE_INTERFACE: 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 radio_path = path
break 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), iface = dbus.Interface(self._bus.get_object(HWSIM_SERVICE, radio_path),
HWSIM_INTERFACE_INTERFACE) HWSIM_INTERFACE_INTERFACE)
iface.SendFrame(bytearray.fromhex(station.replace(':', '')), iface.SendFrame(dbus.ByteArray.fromhex(station.replace(':', '')),
freq, -30, bytearray.fromhex(frame)) freq, -30, dbus.ByteArray.fromhex(frame))
def get_radio(self, name): def get_radio(self, name):
for path in self.radios: for path in self.radios: