Handle VHT operating classes correctly
Fix and extend the ieee80211_freq_to_channel_ext() function to deal correctly with VHT operating classes (128, 129, 130). Signed-off-by: Andrei Otcheretianski <andrei.otcheretianski@intel.com>
This commit is contained in:
parent
7d82170aba
commit
fa53d74c9e
2 changed files with 50 additions and 27 deletions
|
@ -2828,16 +2828,31 @@ static int hostapd_fill_csa_settings(struct hostapd_data *hapd,
|
|||
struct hostapd_iface *iface = hapd->iface;
|
||||
struct hostapd_freq_params old_freq;
|
||||
int ret;
|
||||
u8 chan;
|
||||
u8 chan, vht_bandwidth;
|
||||
|
||||
os_memset(&old_freq, 0, sizeof(old_freq));
|
||||
if (!iface || !iface->freq || hapd->csa_in_progress)
|
||||
return -1;
|
||||
|
||||
switch (settings->freq_params.bandwidth) {
|
||||
case 80:
|
||||
if (settings->freq_params.center_freq2)
|
||||
vht_bandwidth = VHT_CHANWIDTH_80P80MHZ;
|
||||
else
|
||||
vht_bandwidth = VHT_CHANWIDTH_80MHZ;
|
||||
break;
|
||||
case 160:
|
||||
vht_bandwidth = VHT_CHANWIDTH_160MHZ;
|
||||
break;
|
||||
default:
|
||||
vht_bandwidth = VHT_CHANWIDTH_USE_HT;
|
||||
break;
|
||||
}
|
||||
|
||||
if (ieee80211_freq_to_channel_ext(
|
||||
settings->freq_params.freq,
|
||||
settings->freq_params.sec_channel_offset,
|
||||
settings->freq_params.vht_enabled,
|
||||
vht_bandwidth,
|
||||
&hapd->iface->cs_oper_class,
|
||||
&chan) == NUM_HOSTAPD_MODES) {
|
||||
wpa_printf(MSG_DEBUG,
|
||||
|
|
|
@ -570,7 +570,8 @@ enum hostapd_hw_mode ieee80211_freq_to_chan(int freq, u8 *channel)
|
|||
{
|
||||
u8 op_class;
|
||||
|
||||
return ieee80211_freq_to_channel_ext(freq, 0, 0, &op_class, channel);
|
||||
return ieee80211_freq_to_channel_ext(freq, 0, VHT_CHANWIDTH_USE_HT,
|
||||
&op_class, channel);
|
||||
}
|
||||
|
||||
|
||||
|
@ -579,7 +580,7 @@ enum hostapd_hw_mode ieee80211_freq_to_chan(int freq, u8 *channel)
|
|||
* for HT40 and VHT. DFS channels are not covered.
|
||||
* @freq: Frequency (MHz) to convert
|
||||
* @sec_channel: 0 = non-HT40, 1 = sec. channel above, -1 = sec. channel below
|
||||
* @vht: 0 - non-VHT, 1 - 80 MHz
|
||||
* @vht: VHT channel width (VHT_CHANWIDTH_*)
|
||||
* @op_class: Buffer for returning operating class
|
||||
* @channel: Buffer for returning channel number
|
||||
* Returns: hw_mode on success, NUM_HOSTAPD_MODES on failure
|
||||
|
@ -588,6 +589,8 @@ enum hostapd_hw_mode ieee80211_freq_to_channel_ext(unsigned int freq,
|
|||
int sec_channel, int vht,
|
||||
u8 *op_class, u8 *channel)
|
||||
{
|
||||
u8 vht_opclass;
|
||||
|
||||
/* TODO: more operating classes */
|
||||
|
||||
if (sec_channel > 1 || sec_channel < -1)
|
||||
|
@ -631,17 +634,32 @@ enum hostapd_hw_mode ieee80211_freq_to_channel_ext(unsigned int freq,
|
|||
return HOSTAPD_MODE_IEEE80211A;
|
||||
}
|
||||
|
||||
switch (vht) {
|
||||
case VHT_CHANWIDTH_80MHZ:
|
||||
vht_opclass = 128;
|
||||
break;
|
||||
case VHT_CHANWIDTH_160MHZ:
|
||||
vht_opclass = 129;
|
||||
break;
|
||||
case VHT_CHANWIDTH_80P80MHZ:
|
||||
vht_opclass = 130;
|
||||
break;
|
||||
default:
|
||||
vht_opclass = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
/* 5 GHz, channels 36..48 */
|
||||
if (freq >= 5180 && freq <= 5240) {
|
||||
if ((freq - 5000) % 5)
|
||||
return NUM_HOSTAPD_MODES;
|
||||
|
||||
if (sec_channel == 1)
|
||||
if (vht_opclass)
|
||||
*op_class = vht_opclass;
|
||||
else if (sec_channel == 1)
|
||||
*op_class = 116;
|
||||
else if (sec_channel == -1)
|
||||
*op_class = 117;
|
||||
else if (vht)
|
||||
*op_class = 128;
|
||||
else
|
||||
*op_class = 115;
|
||||
|
||||
|
@ -650,31 +668,21 @@ enum hostapd_hw_mode ieee80211_freq_to_channel_ext(unsigned int freq,
|
|||
return HOSTAPD_MODE_IEEE80211A;
|
||||
}
|
||||
|
||||
/* 5 GHz, channels 149..161 */
|
||||
if (freq >= 5745 && freq <= 5805) {
|
||||
if ((freq - 5000) % 5)
|
||||
return NUM_HOSTAPD_MODES;
|
||||
|
||||
if (sec_channel == 1)
|
||||
*op_class = 126;
|
||||
else if (sec_channel == -1)
|
||||
*op_class = 127;
|
||||
else if (vht)
|
||||
*op_class = 128;
|
||||
else
|
||||
*op_class = 124;
|
||||
|
||||
*channel = (freq - 5000) / 5;
|
||||
|
||||
return HOSTAPD_MODE_IEEE80211A;
|
||||
}
|
||||
|
||||
/* 5 GHz, channels 149..169 */
|
||||
if (freq >= 5745 && freq <= 5845) {
|
||||
if ((freq - 5000) % 5)
|
||||
return NUM_HOSTAPD_MODES;
|
||||
|
||||
*op_class = 125;
|
||||
if (vht_opclass)
|
||||
*op_class = vht_opclass;
|
||||
else if (sec_channel == 1)
|
||||
*op_class = 126;
|
||||
else if (sec_channel == -1)
|
||||
*op_class = 127;
|
||||
else if (freq <= 5805)
|
||||
*op_class = 124;
|
||||
else
|
||||
*op_class = 125;
|
||||
|
||||
*channel = (freq - 5000) / 5;
|
||||
|
||||
|
|
Loading…
Reference in a new issue