aboutsummaryrefslogtreecommitdiffstats
path: root/package/network/utils
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
commit6da1c9d3eae138e95e884aa8a22585b33952638b (patch)
treea8a876e10500e946d9e5ef23fb9c2a13d1e96238 /package/network/utils
parentc8e0c28c15677d010fc4cf11b53e36ba91fa4d96 (diff)
downloadupstream-6da1c9d3eae138e95e884aa8a22585b33952638b.tar.gz
upstream-6da1c9d3eae138e95e884aa8a22585b33952638b.tar.bz2
upstream-6da1c9d3eae138e95e884aa8a22585b33952638b.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> SVN-Revision: 38449
Diffstat (limited to 'package/network/utils')
-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;