-
Hi, #!/usr/bin/env python3
# -*- coding: utf-8 -*-
import pprint
import sys
sys.path.append('/usr/lib/python3.9/site-packages')
import pyroute2
import struct
ifname = "wlp6s0f3u3"
iw = pyroute2.iwutil.IW()
ip = pyroute2.IPRoute()
ifindex = ip.link_lookup(ifname=ifname)[0]
ip.close()
msg = pyroute2.netlink.nl80211.nl80211cmd()
msg['cmd'] = pyroute2.netlink.nl80211.NL80211_NAMES['NL80211_CMD_GET_SURVEY']
msg['attrs'] = [['NL80211_ATTR_IFINDEX', ifindex]]
result = iw.nlm_request(msg,
msg_type=iw.prid,
msg_flags=pyroute2.netlink.NLM_F_REQUEST | pyroute2.netlink.NLM_F_DUMP)
pp = pprint.PrettyPrinter(indent=4)
pp.pprint(result)
results = [entry['attrs'][1][1].replace(":"," ") for entry in result]
results_bytes = [bytearray.fromhex(i) for i in results] As a result, I get this: Script output
According to https://elixir.bootlin.com/linux/latest/source/include/net/cfg80211.h#L935 the first four bytes should be the channel band of the survey result, but they are the same in every entry, even though iw shows results for 2.4 and 5 GHz like this: iw output
I probably don't understand the format of the results. Could you give me some pointers? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
Probably the library does not parse the survey info. I'm not sure since I don't work with the wifi code so close :) But the result is looking as an NLA list for me:
I've tried the script on my hardware and it returns nothing, probably the wireless adapter does not support the survey info command. I'll try to look into the kernel code and update the library to support these NLA types. PS: I've created a ticket for that — #818 |
Beta Was this translation helpful? Give feedback.
Probably the library does not parse the survey info. I'm not sure since I don't work with the wifi code so close :)
But the result is looking as an NLA list for me:
I've tried the script on my hardware and it returns nothing, probably the wireless adapter does not support the survey info command.
I'll try to look into the kernel code and update the library to support these NLA types.
PS: I've created a ticket for tha…