From c47c9c66e37ecff2519ce17f22db1b542ec4436c Mon Sep 17 00:00:00 2001 From: Pradeep Kumar Chitrapu Date: Wed, 9 Mar 2022 09:47:40 -0800 Subject: [PATCH] hostapd: Fix 2G EHT40 failure Currently, AP in 2g EHT40, the control field is getting assigned wrong values. Basically, the control field contains the value 0 instead of 1 because when seg0 is not set, it is not able to distinguish between 20 MHz and 40 MHz. Hence, determining operation bandwidth from op_class in 6 GHz band and secondary_channel in 5 GHz and 2 GHz bands. Signed-off-by: Pradeep Kumar Chitrapu Signed-off-by: Aloka Dixit --- diff --git a/src/ap/ieee802_11_eht.c b/src/ap/ieee802_11_eht.c index 9a07f75..e1ab09c 100644 --- a/src/ap/ieee802_11_eht.c +++ b/src/ap/ieee802_11_eht.c @@ -225,6 +225,8 @@ u8 * hostapd_eid_eht_operation(struct hostapd_data *hapd, u8 *eid) chwidth = conf->eht_oper_chwidth; seg0 = hostapd_get_oper_centr_freq_seg0_idx(conf); + if (!seg0) + seg0 = hapd->iconf->channel; switch (chwidth) { case CONF_OPER_CHWIDTH_320MHZ: @@ -247,14 +249,20 @@ u8 * hostapd_eid_eht_operation(struct hostapd_data *hapd, u8 *eid) oper->oper_info.control |= EHT_OPER_CHANNEL_WIDTH_80MHZ; break; case CONF_OPER_CHWIDTH_USE_HT: - if (seg0) + if ((is_6ghz_op_class(hapd->iconf->op_class) && + op_class_to_bandwidth(hapd->iconf->op_class) == 40) || + hapd->iconf->secondary_channel) oper->oper_info.control |= EHT_OPER_CHANNEL_WIDTH_40MHZ; + else + oper->oper_info.control |= EHT_OPER_CHANNEL_WIDTH_20MHZ; + break; default: - return eid; + oper->oper_info.control |= EHT_OPER_CHANNEL_WIDTH_20MHZ; + break; } - oper->oper_info.ccfs0 = seg0 ? seg0 : hapd->iconf->channel; + oper->oper_info.ccfs0 = seg0; oper->oper_info.ccfs1 = seg1; if (hapd->iconf->punct_bitmap) {