aboutsummaryrefslogtreecommitdiffstats
path: root/package/network/utils/iw
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2013-10-18 11:43:02 +0000
committerJo-Philipp Wich <jow@openwrt.org>2013-10-18 11:43:02 +0000
commit04f2b28bd674fd6013b93ea6877389f62d2d6005 (patch)
treeff282ecb2910c6e9f2d35d7963621b8c0504be3f /package/network/utils/iw
parent533eac9728b417b9ec2aaf3d5505963b243f74ef (diff)
downloadupstream-04f2b28bd674fd6013b93ea6877389f62d2d6005.tar.gz
upstream-04f2b28bd674fd6013b93ea6877389f62d2d6005.tar.bz2
upstream-04f2b28bd674fd6013b93ea6877389f62d2d6005.zip
iw: add patch to support 802.11j frequencies
A similar change was recently merged in iw commit 58b46da26ab9b5ff31c7033e175351eb1301d9af Signed-off-by: Bruno Randolf <br1@einfach.org> git-svn-id: svn://svn.openwrt.org/openwrt/trunk@38449 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'package/network/utils/iw')
-rw-r--r--package/network/utils/iw/patches/140-freq-11j.patch85
1 files changed, 85 insertions, 0 deletions
diff --git a/package/network/utils/iw/patches/140-freq-11j.patch b/package/network/utils/iw/patches/140-freq-11j.patch
new file mode 100644
index 0000000000..eae1f2182d
--- /dev/null
+++ b/package/network/utils/iw/patches/140-freq-11j.patch
@@ -0,0 +1,85 @@
+--- a/iw.h
++++ b/iw.h
+@@ -146,7 +146,7 @@ void print_ht_capability(__u16 cap);
+
+ const char *iftype_name(enum nl80211_iftype iftype);
+ const char *command_name(enum nl80211_commands cmd);
+-int ieee80211_channel_to_frequency(int chan);
++int ieee80211_channel_to_frequency(int chan, enum nl80211_band band);
+ int ieee80211_frequency_to_channel(int freq);
+
+ void print_ssid_escaped(const uint8_t len, const uint8_t *data);
+--- a/phy.c
++++ b/phy.c
+@@ -66,8 +66,12 @@ static int handle_freqchan(struct nl_msg
+ if (*end)
+ return 1;
+
+- if (chan)
+- freq = ieee80211_channel_to_frequency(freq);
++ if (chan) {
++ enum nl80211_band band;
++ band = freq <= 14 ? NL80211_BAND_2GHZ : NL80211_BAND_5GHZ;
++ freq = ieee80211_channel_to_frequency(freq, band);
++ }
++
+
+ NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_FREQ, freq);
+ NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_CHANNEL_TYPE, htval);
+--- a/util.c
++++ b/util.c
+@@ -248,31 +248,37 @@ const char *command_name(enum nl80211_co
+ return cmdbuf;
+ }
+
+-int ieee80211_channel_to_frequency(int chan)
++int ieee80211_channel_to_frequency(int chan, enum nl80211_band band)
+ {
+- if (chan < 14)
+- return 2407 + chan * 5;
+-
+- if (chan == 14)
+- return 2484;
+-
+- /* FIXME: dot11ChannelStartingFactor (802.11-2007 17.3.8.3.2) */
+- return (chan + 1000) * 5;
++ /* see 802.11-2007 17.3.8.3.2 and Annex J
++ * there are overlapping channel numbers in 5GHz and 2GHz bands */
++ if (band == NL80211_BAND_5GHZ) {
++ if (chan >= 182 && chan <= 196)
++ return 4000 + chan * 5;
++ else
++ return 5000 + chan * 5;
++ } else { /* NL80211_BAND_2GHZ */
++ if (chan == 14)
++ return 2484;
++ else if (chan < 14)
++ return 2407 + chan * 5;
++ else
++ return 0; /* not supported */
++ }
+ }
+
+ int ieee80211_frequency_to_channel(int freq)
+ {
++ /* see 802.11-2007 17.3.8.3.2 and Annex J */
+ if (freq == 2484)
+ return 14;
+-
+- if (freq < 2484)
++ else if (freq < 2484)
+ return (freq - 2407) / 5;
+-
+- /* FIXME: dot11ChannelStartingFactor (802.11-2007 17.3.8.3.2) */
+- if (freq < 45000)
+- return freq/5 - 1000;
+-
+- if (freq >= 58320 && freq <= 64800)
++ else if (freq >= 4910 && freq <= 4980)
++ return (freq - 4000) / 5;
++ else if (freq < 45000)
++ return (freq - 5000) / 5;
++ else if (freq >= 58320 && freq <= 64800)
+ return (freq - 56160) / 2160;
+
+ return 0;