cli: fix marking the active channel
authorAndre Heider <a.heider@gmail.com>
Thu, 17 Nov 2022 20:59:46 +0000 (21:59 +0100)
committerJo-Philipp Wich <jo@mein.io>
Thu, 15 Dec 2022 23:09:07 +0000 (00:09 +0100)
Match by frequency and not by channel as the radio might have the same
channel on multiple bands:

$ iwinfo radio0 freqlist
[snip]
* 2.432 GHz (Channel 5)
[snip]
* 5.975 GHz (Channel 5)
[snip]

Signed-off-by: Andre Heider <a.heider@gmail.com>
iwinfo_cli.c

index caefac6272372556421fb019c694d25c7e49b337..6ed60f2b86f9522b956e799d7d137b9d7687729e 100644 (file)
@@ -723,7 +723,7 @@ static void print_txpwrlist(const struct iwinfo_ops *iw, const char *ifname)
 
 static void print_freqlist(const struct iwinfo_ops *iw, const char *ifname)
 {
-       int i, len, ch;
+       int i, len, freq;
        char buf[IWINFO_BUFSIZE];
        struct iwinfo_freqlist_entry *e;
 
@@ -733,15 +733,15 @@ static void print_freqlist(const struct iwinfo_ops *iw, const char *ifname)
                return;
        }
 
-       if (iw->channel(ifname, &ch))
-               ch = -1;
+       if (iw->frequency(ifname, &freq))
+               freq = -1;
 
        for (i = 0; i < len; i += sizeof(struct iwinfo_freqlist_entry))
        {
                e = (struct iwinfo_freqlist_entry *) &buf[i];
 
                printf("%s %s (Channel %s)%s\n",
-                       (ch == e->channel) ? "*" : " ",
+                       (freq == e->mhz) ? "*" : " ",
                        format_frequency(e->mhz),
                        format_channel(e->channel),
                        e->restricted ? " [restricted]" : "");