diff options
-rw-r--r-- | sys/net80211/ieee80211.c | 29 | ||||
-rw-r--r-- | sys/net80211/ieee80211_var.h | 4 |
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 *, |