summaryrefslogtreecommitdiff
path: root/package/network/utils/iwinfo/src/iwinfo_nl80211.c
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2013-04-09 14:37:55 +0000
committerJo-Philipp Wich <jow@openwrt.org>2013-04-09 14:37:55 +0000
commit7ca7bc501e15282d4fac3719052731113afcece1 (patch)
tree6812e713f0f4e6feabbb9e8b2d5486e440624bf1 /package/network/utils/iwinfo/src/iwinfo_nl80211.c
parent9f21b979f4896e7cbce5ddf91fd40db1d2472c5e (diff)
downloadmtk-20170518-7ca7bc501e15282d4fac3719052731113afcece1.zip
mtk-20170518-7ca7bc501e15282d4fac3719052731113afcece1.tar.gz
mtk-20170518-7ca7bc501e15282d4fac3719052731113afcece1.tar.bz2
iwinfo: fix frequency/channel and channel/frequency conversions to properly implement 802.11j
SVN-Revision: 36292
Diffstat (limited to 'package/network/utils/iwinfo/src/iwinfo_nl80211.c')
-rw-r--r--package/network/utils/iwinfo/src/iwinfo_nl80211.c31
1 files changed, 19 insertions, 12 deletions
diff --git a/package/network/utils/iwinfo/src/iwinfo_nl80211.c b/package/network/utils/iwinfo/src/iwinfo_nl80211.c
index 819845a..2a2bb66 100644
--- a/package/network/utils/iwinfo/src/iwinfo_nl80211.c
+++ b/package/network/utils/iwinfo/src/iwinfo_nl80211.c
@@ -346,23 +346,30 @@ static int nl80211_freq2channel(int freq)
{
if (freq == 2484)
return 14;
-
- if (freq < 2484)
+ else if (freq < 2484)
return (freq - 2407) / 5;
-
- return (freq / 5) - 1000;
+ else if (freq >= 4910 && freq <= 4980)
+ return (freq - 4000) / 5;
+ else
+ return (freq - 5000) / 5;
}
static int nl80211_channel2freq(int channel, const char *band)
{
- if (channel == 14)
- return 2484;
-
- if ((channel < 14) && (!band || band[0] != 'a'))
- return (channel * 5) + 2407;
-
- if (channel > 0)
- return (1000 + channel) * 5;
+ if (!band || band[0] != 'a')
+ {
+ if (channel == 14)
+ return 2484;
+ else if (channel < 14)
+ return (channel * 5) + 2407;
+ }
+ else
+ {
+ if (channel >= 182 && channel <= 196)
+ return (channel * 5) + 4000;
+ else
+ return (channel * 5) + 5000;
+ }
return 0;
}