diff options
author | jow <jow@3c298f89-4303-0410-b956-a3cf2f4a3e73> | 2013-10-18 11:43:02 +0000 |
---|---|---|
committer | jow <jow@3c298f89-4303-0410-b956-a3cf2f4a3e73> | 2013-10-18 11:43:02 +0000 |
commit | 47c63481fc0cc74b4e3a61c3912b7075874f9f7f (patch) | |
tree | ff282ecb2910c6e9f2d35d7963621b8c0504be3f | |
parent | ed408392b42ba1317b17aaed02fe3ee2b204ffa0 (diff) |
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
-rw-r--r-- | package/network/utils/iw/patches/140-freq-11j.patch | 85 |
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; |