Skip to content
This repository was archived by the owner on Dec 13, 2020. It is now read-only.
This repository was archived by the owner on Dec 13, 2020. It is now read-only.

How to check the NL80211_ATTR_SUPPORTED_IFTYPES attribute?  #20

@mrled

Description

@mrled

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions