iwinfo: fix frequency/channel and channel/frequency conversions to properly implement...
authorJo-Philipp Wich <jow@openwrt.org>
Tue, 9 Apr 2013 14:37:55 +0000 (14:37 +0000)
committerJo-Philipp Wich <jow@openwrt.org>
Tue, 9 Apr 2013 14:37:55 +0000 (14:37 +0000)
SVN-Revision: 36292

package/network/utils/iwinfo/Makefile
package/network/utils/iwinfo/src/iwinfo_nl80211.c

index f8a92dac4bf0e50d9e0655300b58b87b77e144cd..23f3f38cb4d5d7a9ee73bab8d8f55aca77c8f6d2 100644 (file)
@@ -7,7 +7,7 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=libiwinfo
-PKG_RELEASE:=39
+PKG_RELEASE:=40
 
 PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
 PKG_CONFIG_DEPENDS := \
index 819845ad1d2b05d398b4aafddb051d28c9a09ab6..2a2bb66dfeba3f240d4dd4e4defa8ff525991bb6 100644 (file)
@@ -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;
 }