summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeorge Sapkin2026-01-09 17:16:52 +0000
committerHauke Mehrtens2026-01-13 23:33:03 +0000
commitf5dd57a84cc31a403a1383dd14944fa2e2b5824a (patch)
tree1834beded14c08bec53b68a4c1283b6436c7c3b4
parent2ebef3da84e8e35e54657eb8d7e493a9a144da4d (diff)
downloadiwinfo-master.tar.gz
nl80211: fix 5Ghz frequency calculationsHEADmaster
nl80211_channel2freq assumes that if ieee80211ax=1 is set in /var/run/hostapd-XXX.conf, the channel must be in the 6GHz band. Check op_class instead, which is between 131 and 137 for 6GHz. Fixes: 3f619a5fbe10 ("nl80211: fix frequency/channel conversion for the 6G band") Signed-off-by: George Sapkin <george@sapk.in> Link: https://github.com/openwrt/iwinfo/pull/31 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
-rw-r--r--iwinfo_nl80211.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/iwinfo_nl80211.c b/iwinfo_nl80211.c
index 813678a..1dd6a67 100644
--- a/iwinfo_nl80211.c
+++ b/iwinfo_nl80211.c
@@ -707,7 +707,7 @@ static int nl80211_freq2channel(int freq)
* Copyright 2017 Intel Deutschland GmbH
* Copyright (C) 2018-2022 Intel Corporation
*/
-static int nl80211_channel2freq(int channel, const char *band, bool ax)
+static int nl80211_channel2freq(const int channel, const char *band, const int opclass)
{
if (channel < 1)
return 0;
@@ -724,7 +724,8 @@ static int nl80211_channel2freq(int channel, const char *band, bool ax)
if (channel < 7)
return 56160 + 2160 * channel;
}
- else if (ax)
+ // 6GHz: opclass between 131 and 137
+ else if (opclass >= 131 && opclass <= 137)
{
if (channel == 2)
return 5935;
@@ -1492,7 +1493,7 @@ static int nl80211_get_frequency_info_cb(struct nl_msg *msg, void *arg)
static int nl80211_get_frequency(const char *ifname, int *buf)
{
- char *res, channel[4] = { 0 }, hwmode[3] = { 0 }, ax[2] = { 0 };
+ char *res, channel[4] = { 0 }, hwmode[3] = { 0 }, opclass[4] = { 0 };
/* try to find frequency from interface info */
res = nl80211_phy2ifname(ifname);
@@ -1505,9 +1506,9 @@ static int nl80211_get_frequency(const char *ifname, int *buf)
if ((*buf == 0) &&
nl80211_hostapd_query(ifname, "hw_mode", hwmode, sizeof(hwmode),
"channel", channel, sizeof(channel),
- "ieee80211ax", ax, sizeof(ax)) >= 2)
+ "op_class", opclass, sizeof(opclass)) >= 2)
{
- *buf = nl80211_channel2freq(atoi(channel), hwmode, ax[0] == '1');
+ *buf = nl80211_channel2freq(atoi(channel), hwmode, atoi(opclass));
}
/* failed, try to find frequency from scan results */
@@ -3860,7 +3861,7 @@ const struct iwinfo_ops nl80211_ops = {
.mbssid_support = nl80211_get_mbssid_support,
.hwmodelist = nl80211_get_hwmodelist,
.htmodelist = nl80211_get_htmodelist,
- .htmode = nl80211_get_htmode,
+ .htmode = nl80211_get_htmode,
.mode = nl80211_get_mode,
.ssid = nl80211_get_ssid,
.bssid = nl80211_get_bssid,