summaryrefslogtreecommitdiff
path: root/iwinfo_nl80211.c
diff options
context:
space:
mode:
authorRafał Miłecki <zajec5@gmail.com>2015-09-28 13:39:15 +0200
committerJo-Philipp Wich <jow@openwrt.org>2015-10-05 11:00:22 +0200
commit813f61e48b9b1a76cb55f3b4a229bf98d3cd53a9 (patch)
tree2e1fee2a9e87a205dd0c7adcb7b3d7fe5cb8dc2e /iwinfo_nl80211.c
parent3d38d1d17eba37b0985dd2857b4539410824a3e6 (diff)
downloadiwinfo-813f61e48b9b1a76cb55f3b4a229bf98d3cd53a9.tar.gz
nl80211: read TX power using NL80211_CMD_GET_INTERFACE
With the mac80211 commit d55d0d598e66 ("nl80211: put current TX power in interface info") it is possible now to get TX power using nl80211. As we don't really support any wext-only drivers it doesn't make sense to leave wext as a fallback. Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
Diffstat (limited to 'iwinfo_nl80211.c')
-rw-r--r--iwinfo_nl80211.c31
1 files changed, 22 insertions, 9 deletions
diff --git a/iwinfo_nl80211.c b/iwinfo_nl80211.c
index 7aaae6b..a65ed1e 100644
--- a/iwinfo_nl80211.c
+++ b/iwinfo_nl80211.c
@@ -1188,22 +1188,35 @@ static int nl80211_get_channel(const char *ifname, int *buf)
return -1;
}
+static int nl80211_get_txpower_cb(struct nl_msg *msg, void *arg)
+{
+ int *buf = arg;
+ struct nlattr **tb = nl80211_parse(msg);
+
+ if (tb[NL80211_ATTR_WIPHY_TX_POWER_LEVEL])
+ *buf = iwinfo_mbm2dbm(nla_get_u32(tb[NL80211_ATTR_WIPHY_TX_POWER_LEVEL]));
+
+ return NL_SKIP;
+}
static int nl80211_get_txpower(const char *ifname, int *buf)
{
-#if 0
char *res;
- char path[PATH_MAX];
+ struct nl80211_msg_conveyor *req;
- res = nl80211_ifname2phy(ifname);
- snprintf(path, sizeof(path), "/sys/kernel/debug/ieee80211/%s/power",
- res ? res : ifname);
+ res = nl80211_phy2ifname(ifname);
+ req = nl80211_msg(res ? res : ifname, NL80211_CMD_GET_INTERFACE, 0);
- if ((*buf = nl80211_readint(path)) > -1)
- return 0;
-#endif
+ if (req)
+ {
+ *buf = 0;
+ nl80211_send(req, nl80211_get_txpower_cb, buf);
+ nl80211_free(req);
+ if (*buf)
+ return 0;
+ }
- return wext_ops.txpower(ifname, buf);
+ return -1;
}