diff options
author | Andre Heider <a.heider@gmail.com> | 2022-11-22 09:39:12 +0100 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2022-12-16 00:09:07 +0100 |
commit | 9e14e643c5e8bac2b8aeb4efb76cff3f86bf80ca (patch) | |
tree | 452666095ccda112383100de389dd503e319ffae /iwinfo_utils.c | |
parent | e084781afc99075c4154614b49d99d3308d8c8ee (diff) | |
download | iwinfo-9e14e643c5e8bac2b8aeb4efb76cff3f86bf80ca.tar.gz |
utils: add iwinfo_band2ghz() and iwinfo_ghz2band() helpers
To classify bands, to be used as ubus values.
Signed-off-by: Andre Heider <a.heider@gmail.com>
Diffstat (limited to 'iwinfo_utils.c')
-rw-r--r-- | iwinfo_utils.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/iwinfo_utils.c b/iwinfo_utils.c index 83f049a..a342b6a 100644 --- a/iwinfo_utils.c +++ b/iwinfo_utils.c @@ -115,6 +115,40 @@ const char * const iwinfo_htmode_name(int mask) return iwinfo_name(mask, IWINFO_HTMODE_COUNT, IWINFO_HTMODE_NAMES); } +uint32_t iwinfo_band2ghz(uint8_t band) +{ + switch (band) + { + case IWINFO_BAND_24: + return 2; + case IWINFO_BAND_5: + return 5; + case IWINFO_BAND_6: + return 6; + case IWINFO_BAND_60: + return 60; + } + + return 0; +} + +uint8_t iwinfo_ghz2band(uint32_t ghz) +{ + switch (ghz) + { + case 2: + return IWINFO_BAND_24; + case 5: + return IWINFO_BAND_5; + case 6: + return IWINFO_BAND_6; + case 60: + return IWINFO_BAND_60; + } + + return 0; +} + size_t iwinfo_format_hwmodes(int modes, char *buf, size_t len) { // bit numbers as per IWINFO_80211_*: ad ac ax a b g n |