diff options
author | Andre Heider <a.heider@gmail.com> | 2023-01-11 12:13:44 +0100 |
---|---|---|
committer | Christian Marangi <ansuelsmth@gmail.com> | 2023-01-20 17:27:00 +0100 |
commit | f766138662cb1d62bacd1087fab597bedcf708b9 (patch) | |
tree | 9626fd7b7cc19442cfd6f4c8e3674b4ffeaa91c9 /iwinfo_cli.c | |
parent | 8ee7971c76314b44ff01385c47ac7a98edce79d9 (diff) | |
download | iwinfo-f766138662cb1d62bacd1087fab597bedcf708b9.tar.gz |
cli: print the flags on the frequency list
Provide info for each flags applied to the frequency on frequency list
dump.
Signed-off-by: Andre Heider <a.heider@gmail.com>
Diffstat (limited to 'iwinfo_cli.c')
-rw-r--r-- | iwinfo_cli.c | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/iwinfo_cli.c b/iwinfo_cli.c index c1242bf..5dcee9a 100644 --- a/iwinfo_cli.c +++ b/iwinfo_cli.c @@ -79,6 +79,25 @@ static char * format_frequency(int freq) return buf; } +static char * format_freqflags(uint32_t flags) +{ + static char str[512] = "["; + char *pos = str + 1; + int i; + + if (!flags) + return ""; + + for (i = 0; i < IWINFO_FREQ_FLAG_COUNT; i++) + if (flags & (1 << i)) + pos += sprintf(pos, "%s, ", IWINFO_FREQ_FLAG_NAMES[i]); + + *(pos - 2) = ']'; + *(pos - 1) = 0; + + return str; +} + static char * format_txpower(int pwr) { static char buf[16]; @@ -742,12 +761,12 @@ static void print_freqlist(const struct iwinfo_ops *iw, const char *ifname) { e = (struct iwinfo_freqlist_entry *) &buf[i]; - printf("%s %s (Band: %s, Channel %s)%s\n", + printf("%s %s (Band: %s, Channel %s) %s\n", (freq == e->mhz) ? "*" : " ", format_frequency(e->mhz), format_band(e->band), format_channel(e->channel), - e->restricted ? " [restricted]" : ""); + format_freqflags(e->flags)); } } |