summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndre Heider <a.heider@gmail.com>2022-11-23 15:21:57 +0100
committerChristian Marangi <ansuelsmth@gmail.com>2023-01-20 17:26:57 +0100
commitafa147c45ad35a036600bc737b6b39cf1d33ccd4 (patch)
treeb8e6f4f64130d5aab77369bb5963f5393875ad40
parent0d5ea34245433a403c3c6bb2b1f4070c92d02451 (diff)
downloadiwinfo-afa147c45ad35a036600bc737b6b39cf1d33ccd4.tar.gz
nl80211: add "mhz" and "band" to iwinfo_scanlist_entry
Providing the channel alone isn't clear as there're overlapping channels on e.g. band 2 and 6. Note: This changes the ABI. Signed-off-by: Andre Heider <a.heider@gmail.com>
-rw-r--r--include/iwinfo.h2
-rw-r--r--iwinfo_nl80211.c25
2 files changed, 24 insertions, 3 deletions
diff --git a/include/iwinfo.h b/include/iwinfo.h
index 71c4c80..c76aab7 100644
--- a/include/iwinfo.h
+++ b/include/iwinfo.h
@@ -313,7 +313,9 @@ struct iwinfo_scanlist_entry {
uint8_t mac[6];
char ssid[IWINFO_ESSID_MAX_SIZE+1];
enum iwinfo_opmode mode;
+ uint8_t band;
uint8_t channel;
+ uint32_t mhz;
uint8_t signal;
uint8_t quality;
uint8_t quality_max;
diff --git a/iwinfo_nl80211.c b/iwinfo_nl80211.c
index 50caf01..7a67467 100644
--- a/iwinfo_nl80211.c
+++ b/iwinfo_nl80211.c
@@ -742,6 +742,20 @@ static int nl80211_channel2freq(int channel, const char *band, bool ax)
return 0;
}
+static uint8_t nl80211_freq2band(int freq)
+{
+ if (freq >= 2412 && freq <= 2484)
+ return IWINFO_BAND_24;
+ else if (freq >= 5160 && freq <= 5885)
+ return IWINFO_BAND_5;
+ else if (freq >= 5925 && freq <= 7125)
+ return IWINFO_BAND_6;
+ else if (freq >= 58320 && freq <= 69120)
+ return IWINFO_BAND_60;
+
+ return 0;
+}
+
static int nl80211_phyname_cb(struct nl_msg *msg, void *arg)
{
char *buf = arg;
@@ -2619,8 +2633,11 @@ static int nl80211_get_scanlist_cb(struct nl_msg *msg, void *arg)
sl->e->crypto.enabled = 1;
if (bss[NL80211_BSS_FREQUENCY])
- sl->e->channel = nl80211_freq2channel(nla_get_u32(
- bss[NL80211_BSS_FREQUENCY]));
+ {
+ sl->e->mhz = nla_get_u32(bss[NL80211_BSS_FREQUENCY]);
+ sl->e->band = nl80211_freq2band(sl->e->mhz);
+ sl->e->channel = nl80211_freq2channel(sl->e->mhz);
+ }
if (bss[NL80211_BSS_INFORMATION_ELEMENTS])
nl80211_get_scanlist_ie(bss, sl->e);
@@ -2842,7 +2859,9 @@ static int nl80211_get_scanlist_wpactl(const char *ifname, char *buf, int *len)
e->mode = IWINFO_OPMODE_MASTER;
/* Channel */
- e->channel = nl80211_freq2channel(atoi(freq));
+ e->mhz = atoi(freq);
+ e->band = nl80211_freq2band(e->mhz);
+ e->channel = nl80211_freq2channel(e->mhz);
/* Signal */
rssi = atoi(signal);