A similar change was recently merged in iw commit 58b46da26ab9b5ff31c7033e175351eb1301d9af Signed-off-by: Bruno Randolf <br1@einfach.org> SVN-Revision: 38449master
parent
c8e0c28c15
commit
6da1c9d3ea
@ -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;
|
Loading…
Reference in new issue