summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorsam <sam@FreeBSD.org>2005-11-15 05:56:32 +0000
committersam <sam@FreeBSD.org>2005-11-15 05:56:32 +0000
commit0bc81b535724c930e0ee0dbb084bbf30a4e9d734 (patch)
tree71ec0542689853d9159985c6d4cd37b2d8b2e01e /sys
parente0af8384a54604568157aeab1d58c52b68026924 (diff)
downloadFreeBSD-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')
-rw-r--r--sys/net80211/ieee80211.c29
-rw-r--r--sys/net80211/ieee80211_var.h4
2 files changed, 24 insertions, 9 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])
diff --git a/sys/net80211/ieee80211_var.h b/sys/net80211/ieee80211_var.h
index c552d36..05a8849 100644
--- a/sys/net80211/ieee80211_var.h
+++ b/sys/net80211/ieee80211_var.h
@@ -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 *,
OpenPOWER on IntegriCloud