diff --git a/sys/net80211/ieee80211.c b/sys/net80211/ieee80211.c index 39da95fe1a96..229217ee765f 100644 --- a/sys/net80211/ieee80211.c +++ b/sys/net80211/ieee80211.c @@ -1169,6 +1169,53 @@ ieee80211_add_channel_ht40(struct ieee80211_channel chans[], int maxchans, return (error); } +/* + * Fetch the center frequency for the primary channel. + */ +uint32_t +ieee80211_get_channel_center_freq(const struct ieee80211_channel *c) +{ + + return (c->ic_freq); +} + +/* + * Fetch the center frequency for the primary BAND channel. + * + * For 5, 10, 20MHz channels it'll be the normally configured channel + * frequency. + * + * For 40MHz, 80MHz, 160Mhz channels it'll the the centre of the + * wide channel, not the centre of the primary channel (that's ic_freq). + * + * For 80+80MHz channels this will be the centre of the primary + * 80MHz channel; the secondary 80MHz channel will be center_freq2(). + */ + +uint32_t +ieee80211_get_channel_center_freq1(const struct ieee80211_channel *c) +{ + + if (IEEE80211_IS_CHAN_HT40U(c)) { + return (c->ic_freq + 10); + } + if (IEEE80211_IS_CHAN_HT40D(c)) { + return (c->ic_freq - 10); + } + + return (c->ic_freq); +} + +/* + * For now, no 80+80 support; this is zero. + */ +uint32_t +ieee80211_get_channel_center_freq2(const struct ieee80211_channel *c) +{ + + return (0); +} + /* * Adds channels into specified channel list (ieee[] array must be sorted). * Channels are already sorted. diff --git a/sys/net80211/ieee80211_var.h b/sys/net80211/ieee80211_var.h index 37f4f6dde7f8..d8e20c2d631b 100644 --- a/sys/net80211/ieee80211_var.h +++ b/sys/net80211/ieee80211_var.h @@ -668,6 +668,9 @@ int ieee80211_add_channel(struct ieee80211_channel[], int, int *, uint8_t, uint16_t, int8_t, uint32_t, const uint8_t[]); int ieee80211_add_channel_ht40(struct ieee80211_channel[], int, int *, uint8_t, int8_t, uint32_t); +uint32_t ieee80211_get_channel_center_freq(const struct ieee80211_channel *); +uint32_t ieee80211_get_channel_center_freq1(const struct ieee80211_channel *); +uint32_t ieee80211_get_channel_center_freq2(const struct ieee80211_channel *); int ieee80211_add_channel_list_2ghz(struct ieee80211_channel[], int, int *, const uint8_t[], int, const uint8_t[], int); int ieee80211_add_channel_list_5ghz(struct ieee80211_channel[], int, int *, @@ -684,6 +687,10 @@ uint32_t ieee80211_mac_hash(const struct ieee80211com *, const uint8_t addr[IEEE80211_ADDR_LEN]); char ieee80211_channel_type_char(const struct ieee80211_channel *c); +#define ieee80211_get_current_channel(_ic) ((_ic)->ic_curchan) +#define ieee80211_get_home_channel(_ic) ((_ic)->ic_bsschan) +#define ieee80211_get_vap_desired_channel(_iv) ((_iv)->iv_des_chan) + void ieee80211_radiotap_attach(struct ieee80211com *, struct ieee80211_radiotap_header *th, int tlen, uint32_t tx_radiotap,