2019-12-10 14:45:44

by Markus Theil

[permalink] [raw]
Subject: [PATCH] iw: event: add sta opmode changed command

Parsing this command helps tracking num spatial stream
and bandwidth changes.

Signed-off-by: Markus Theil <[email protected]>
---
event.c | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)

diff --git a/event.c b/event.c
index 0cedeb9..7600781 100644
--- a/event.c
+++ b/event.c
@@ -708,6 +708,32 @@ static void parse_set_interface(struct nlattr **attrs)
printf("\n");
}

+static void parse_sta_opmode_changed(struct nlattr **attrs)
+{
+ char macbuf[ETH_ALEN*3];
+
+ printf("sta opmode changed");
+
+ if (attrs[NL80211_ATTR_MAC]) {
+ mac_addr_n2a(macbuf, nla_data(attrs[NL80211_ATTR_MAC]));
+ printf(" %s", macbuf);
+ }
+
+ if (attrs[NL80211_ATTR_SMPS_MODE]) {
+ printf(" smps mode %i", nla_get_u8(attrs[NL80211_ATTR_SMPS_MODE]));
+ }
+
+ if (attrs[NL80211_ATTR_CHANNEL_WIDTH]) {
+ printf(" chan width %i", nla_get_u8(attrs[NL80211_ATTR_CHANNEL_WIDTH]));
+ }
+
+ if (attrs[NL80211_ATTR_NSS]) {
+ printf(" nss %i", nla_get_u8(attrs[NL80211_ATTR_NSS]));
+ }
+
+ printf("\n");
+}
+
static int print_event(struct nl_msg *msg, void *arg)
{
struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg));
@@ -1055,6 +1081,10 @@ static int print_event(struct nl_msg *msg, void *arg)
parse_set_interface(tb);
break;
}
+ case NL80211_CMD_STA_OPMODE_CHANGED: {
+ parse_sta_opmode_changed(tb);
+ break;
+ }
default:
printf("unknown event %d (%s)\n",
gnlh->cmd, command_name(gnlh->cmd));
--
2.24.0