Update ieee80211_mhz2ieee to understand public safety bands and spectrum
that can potentially be mapped to negative ieee #'s. NB: before operation on the latter can be supported we need to cleanup various code that assumes ieee channel #'s are >= 0
This commit is contained in:
parent
de66ac4427
commit
6f322b78de
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=152450
@ -233,33 +233,48 @@ ieee80211_ifdetach(struct ieee80211com *ic)
|
||||
/*
|
||||
* Convert MHz frequency to IEEE channel number.
|
||||
*/
|
||||
u_int
|
||||
int
|
||||
ieee80211_mhz2ieee(u_int freq, u_int flags)
|
||||
{
|
||||
#define IS_CHAN_IN_PUBLIC_SAFETY_BAND(_c) ((_c) > 4940 && (_c) < 4990)
|
||||
if (flags & IEEE80211_CHAN_2GHZ) { /* 2GHz band */
|
||||
if (freq == 2484)
|
||||
return 14;
|
||||
if (freq < 2484)
|
||||
return (freq - 2407) / 5;
|
||||
return ((int) freq - 2407) / 5;
|
||||
else
|
||||
return 15 + ((freq - 2512) / 20);
|
||||
} else if (flags & IEEE80211_CHAN_5GHZ) { /* 5Ghz band */
|
||||
return (freq - 5000) / 5;
|
||||
if (IS_CHAN_IN_PUBLIC_SAFETY_BAND(freq))
|
||||
return ((freq * 10) +
|
||||
(((freq % 5) == 2) ? 5 : 0) - 49400) / 5;
|
||||
if (freq <= 5000)
|
||||
return (freq - 4000) / 5;
|
||||
else
|
||||
return (freq - 5000) / 5;
|
||||
} else { /* either, guess */
|
||||
if (freq == 2484)
|
||||
return 14;
|
||||
if (freq < 2484)
|
||||
return (freq - 2407) / 5;
|
||||
if (freq < 5000)
|
||||
return 15 + ((freq - 2512) / 20);
|
||||
return ((int) freq - 2407) / 5;
|
||||
if (freq < 5000) {
|
||||
if (IS_CHAN_IN_PUBLIC_SAFETY_BAND(freq))
|
||||
return ((freq * 10) +
|
||||
(((freq % 5) == 2) ? 5 : 0) - 49400)/5;
|
||||
else if (freq > 4900)
|
||||
return (freq - 4000) / 5;
|
||||
else
|
||||
return 15 + ((freq - 2512) / 20);
|
||||
}
|
||||
return (freq - 5000) / 5;
|
||||
}
|
||||
#undef IS_CHAN_IN_PUBLIC_SAFETY_BAND
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert channel to IEEE channel number.
|
||||
*/
|
||||
u_int
|
||||
int
|
||||
ieee80211_chan2ieee(struct ieee80211com *ic, struct ieee80211_channel *c)
|
||||
{
|
||||
if (ic->ic_channels <= c && c <= &ic->ic_channels[IEEE80211_CHAN_MAX])
|
||||
|
@ -286,8 +286,8 @@ void ieee80211_watchdog(struct ieee80211com *);
|
||||
int ieee80211_rate2media(struct ieee80211com *, int,
|
||||
enum ieee80211_phymode);
|
||||
int ieee80211_media2rate(int);
|
||||
u_int ieee80211_mhz2ieee(u_int, u_int);
|
||||
u_int ieee80211_chan2ieee(struct ieee80211com *, struct ieee80211_channel *);
|
||||
int ieee80211_mhz2ieee(u_int, u_int);
|
||||
int ieee80211_chan2ieee(struct ieee80211com *, struct ieee80211_channel *);
|
||||
u_int ieee80211_ieee2mhz(u_int, u_int);
|
||||
int ieee80211_setmode(struct ieee80211com *, enum ieee80211_phymode);
|
||||
enum ieee80211_phymode ieee80211_chan2mode(struct ieee80211com *,
|
||||
|
Loading…
Reference in New Issue
Block a user