Use ieee80211_freq_to_chan() when getting segment indices

The hostapd_hw_get_channel() function can't be used to convert center
frequencies to channel numbers, because the hw mode lists don't have all
the center frequencies. The hw mode lists have the main channel
frequencies and flags to indicate the channel topography.

For instance, channel 5805 with VHT80- has the channel center frequency
segment 0 at 5775. This segment is only indicated indirectly in the hw
mode list by the HOSTAPD_CHAN_VHT_50_30 flag. The hw mode list doesn't
have any elements with frequency 5775 to allow the conversion to a
channel number. Thus, we need to use ieee80211_freq_to_chan() instead.

Signed-off-by: Luciano Coelho <luciano.coelho@intel.com>
This commit is contained in:
Luciano Coelho 2015-09-08 12:46:29 +03:00 committed by Jouni Malinen
parent 95e551c5f7
commit d308a44fcc
2 changed files with 8 additions and 7 deletions

View file

@ -447,7 +447,8 @@ void hostapd_event_ch_switch(struct hostapd_data *hapd, int freq, int ht,
int offset, int width, int cf1, int cf2)
{
#ifdef NEED_AP_MLME
int channel, chwidth, seg0_idx = 0, seg1_idx = 0, is_dfs;
int channel, chwidth, is_dfs;
u8 seg0_idx = 0, seg1_idx = 0;
hostapd_logger(hapd, NULL, HOSTAPD_MODULE_IEEE80211,
HOSTAPD_LEVEL_INFO,
@ -491,8 +492,8 @@ void hostapd_event_ch_switch(struct hostapd_data *hapd, int freq, int ht,
seg1_idx = (cf2 - 5000) / 5;
break;
default:
seg0_idx = hostapd_hw_get_channel(hapd, cf1);
seg1_idx = hostapd_hw_get_channel(hapd, cf2);
ieee80211_freq_to_chan(cf1, &seg0_idx);
ieee80211_freq_to_chan(cf2, &seg1_idx);
break;
}

View file

@ -2811,10 +2811,10 @@ static int hostapd_change_config_freq(struct hostapd_data *hapd,
conf->channel = channel;
conf->ieee80211n = params->ht_enabled;
conf->secondary_channel = params->sec_channel_offset;
conf->vht_oper_centr_freq_seg0_idx =
hostapd_hw_get_channel(hapd, params->center_freq1);
conf->vht_oper_centr_freq_seg1_idx =
hostapd_hw_get_channel(hapd, params->center_freq2);
ieee80211_freq_to_chan(params->center_freq1,
&conf->vht_oper_centr_freq_seg0_idx);
ieee80211_freq_to_chan(params->center_freq2,
&conf->vht_oper_centr_freq_seg1_idx);
/* TODO: maybe call here hostapd_config_check here? */