]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Use ieee80211_freq_to_chan() when getting segment indices
authorLuciano Coelho <luciano.coelho@intel.com>
Tue, 8 Sep 2015 09:46:29 +0000 (12:46 +0300)
committerJouni Malinen <j@w1.fi>
Sat, 3 Oct 2015 18:19:09 +0000 (21:19 +0300)
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>
src/ap/drv_callbacks.c
src/ap/hostapd.c

index ca8b75c8390605d031bada4d7a60777c67da2939..37537b3c649b0ae7f35e4955122aa2abfb781acd 100644 (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;
        }
 
index 8036de44ef1948722f978c2f7249cef2a16b5c58..36adf3eb8e6bcc4e4e0d0705c39383c2081517e3 100644 (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? */