From d308a44fccc0b191956649b2264182621986af27 Mon Sep 17 00:00:00 2001 From: Luciano Coelho Date: Tue, 8 Sep 2015 12:46:29 +0300 Subject: [PATCH] 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 --- src/ap/drv_callbacks.c | 7 ++++--- src/ap/hostapd.c | 8 ++++---- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/ap/drv_callbacks.c b/src/ap/drv_callbacks.c index ca8b75c83..37537b3c6 100644 --- a/src/ap/drv_callbacks.c +++ b/src/ap/drv_callbacks.c @@ -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; } diff --git a/src/ap/hostapd.c b/src/ap/hostapd.c index 8036de44e..36adf3eb8 100644 --- a/src/ap/hostapd.c +++ b/src/ap/hostapd.c @@ -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? */