diff options
author | sam <sam@FreeBSD.org> | 2005-11-15 05:56:32 +0000 |
---|---|---|
committer | sam <sam@FreeBSD.org> | 2005-11-15 05:56:32 +0000 |
commit | 0bc81b535724c930e0ee0dbb084bbf30a4e9d734 (patch) | |
tree | 71ec0542689853d9159985c6d4cd37b2d8b2e01e /sys/net80211/ieee80211.c | |
parent | e0af8384a54604568157aeab1d58c52b68026924 (diff) | |
download | FreeBSD-src-0bc81b535724c930e0ee0dbb084bbf30a4e9d734.zip FreeBSD-src-0bc81b535724c930e0ee0dbb084bbf30a4e9d734.tar.gz |
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
Diffstat (limited to 'sys/net80211/ieee80211.c')
-rw-r--r-- | sys/net80211/ieee80211.c | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/sys/net80211/ieee80211.c b/sys/net80211/ieee80211.c index 74ee627..5bd64a4 100644 --- a/sys/net80211/ieee80211.c +++ b/sys/net80211/ieee80211.c @@ -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]) |