Skip to content

Commit

Permalink
util/agents/network_interface: handle wifis without SSID
Browse files Browse the repository at this point in the history
Hidden wifis do not send an SSID. If a hidden wifi is in reach, the
following error can be observed:

  Traceback (most recent call last):
    File "/path/to/labgrid/examples/networkmanager/nm.py", line 68, in <module>
      pprint(d.get_access_points())
             ^^^^^^^^^^^^^^^^^^^^^
    File "/path/to/labgrid/labgrid/binding.py", line 102, in wrapper
      return func(self, *_args, **_kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/path/to/labgrid/labgrid/step.py", line 215, in wrapper
      _result = func(*_args, **_kwargs)
                ^^^^^^^^^^^^^^^^^^^^^^^
    File "/path/to/labgrid/labgrid/driver/networkinterfacedriver.py", line 126, in get_access_points
      return self.proxy.get_access_points(self.iface.ifname, scan)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/path/to/labgrid/labgrid/util/agentwrapper.py", line 29, in __call__
      return self.wrapper.call(self.name, *args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/path/to/labgrid/labgrid/util/agentwrapper.py", line 106, in call
      raise AgentException(e)
  labgrid.util.agentwrapper.AgentException: AttributeError("'NoneType' object has no attribute 'get_data'")

Fix that by retrieving the SSID only if it was received. The AP dict
will not contain the "ssid" key if no SSID was received.

Signed-off-by: Bastian Krause <[email protected]>
  • Loading branch information
Bastian-Krause committed Nov 19, 2024
1 parent 92b0ec5 commit 04f4655
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion labgrid/util/agents/network_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,8 @@ def _accesspoint_to_dict(self, ap):
res['wpa-flags'] = self._flags_to_str(ap.get_wpa_flags())
res['rsn-flags'] = self._flags_to_str(ap.get_rsn_flags())
res['bssid'] = ap.get_bssid()
res['ssid'] = ap.get_ssid().get_data().decode(errors='surrogateescape')
if ap.get_ssid():
res['ssid'] = ap.get_ssid().get_data().decode(errors='surrogateescape')
res['frequency'] = ap.get_frequency()
res['mode'] = self._flags_to_str(ap.get_mode())
res['max-bitrate'] = ap.get_max_bitrate()
Expand Down

0 comments on commit 04f4655

Please sign in to comment.