I am trying to use Python to determine whether a wireless card supports AP mode. I started with example_show_wifi_interface.py, and I thought I would be able to add a bit of code like this to the callback() function right before it prints:
if tb[nl80211.NL80211_ATTR_SUPPORTED_IFTYPES]:
iftypes = nla_get_u32(tb[NL80211_ATTR_SUPPORTED_IFTYPES])
rem = c_int()
ap_mode = False
for subattr in nla_for_each_nested(tb[iftypes], rem):
if subattr == nl80211.NL80211_IFTYPE_AP:
ap_mode = True
break
table.table_data.append(['Supports AP mode', str(ap_mode)])
else:
print("Couldn't get attribute NL80211_ATTR_SUPPORTED_IFTYPES")
However, tb[nl80211.NL80211_ATTR_SUPPORTED_IFTYPES] is evaluating to None, and I don't know why, or even where to start looking for the right path forward. My first thought was to try to read some C code that uses the nl80211 library and model my Python on that, but the only thing I discovered was that I'm not enough of a C programmer to understand how iw is working internally :).
What am I doing wrong?
I am trying to use Python to determine whether a wireless card supports AP mode. I started with
example_show_wifi_interface.py, and I thought I would be able to add a bit of code like this to thecallback()function right before it prints:However,
tb[nl80211.NL80211_ATTR_SUPPORTED_IFTYPES]is evaluating toNone, and I don't know why, or even where to start looking for the right path forward. My first thought was to try to read some C code that uses the nl80211 library and model my Python on that, but the only thing I discovered was that I'm not enough of a C programmer to understand howiwis working internally :).What am I doing wrong?