blob: 69e9ff375524be99838027ae12eb5806e765a997 [file] [log] [blame]
developerce9e5092022-11-10 22:41:59 +08001diff --git a/package/kernel/mac80211/Makefile b/package/kernel/mac80211/Makefile
developer8169b4f2023-10-12 09:34:58 +08002index c9e2a37..af1932f 100644
developerce9e5092022-11-10 22:41:59 +08003--- a/package/kernel/mac80211/Makefile
4+++ b/package/kernel/mac80211/Makefile
developerad1f3172023-05-02 11:10:08 +08005@@ -20,6 +20,7 @@ PKG_SOURCE:=backports-$(PKG_VERSION).tar.xz
developerce9e5092022-11-10 22:41:59 +08006 PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/backports-$(PKG_VERSION)
7 PKG_BUILD_PARALLEL:=1
developer356ecec2022-11-14 10:25:04 +08008
developerce9e5092022-11-10 22:41:59 +08009+SOURCE_PATH:=./src
10 PKG_MAINTAINER:=Felix Fietkau <nbd@nbd.name>
developer356ecec2022-11-14 10:25:04 +080011
developerce9e5092022-11-10 22:41:59 +080012 PKG_DRIVERS = \
developerad1f3172023-05-02 11:10:08 +080013@@ -72,6 +73,10 @@ config-y:= \
developer6ec8e342022-11-21 18:47:15 +080014 WLAN_VENDOR_ST \
15 WLAN_VENDOR_TI \
16 WLAN_VENDOR_ZYDAS \
17+ MAC80211_DEBUG_MENU \
18+ MAC80211_MLME_DEBUG \
19+ MAC80211_STA_DEBUG \
20+ MAC80211_HT_DEBUG \
21
22 config-$(call config_package,cfg80211) += CFG80211
23 config-$(CONFIG_PACKAGE_CFG80211_TESTMODE) += NL80211_TESTMODE
developerad1f3172023-05-02 11:10:08 +080024@@ -297,6 +302,8 @@ define Build/Prepare
developer356ecec2022-11-14 10:25:04 +080025 mkdir -p $(PKG_BUILD_DIR)
26 $(PKG_UNPACK)
27 $(Build/Patch)
28+ $(CP) $(SOURCE_PATH)/net $(PKG_BUILD_DIR) 2>/dev/null || :
29+ $(CP) $(SOURCE_PATH)/include $(PKG_BUILD_DIR) 2>/dev/null || :
30 rm -rf \
31 $(PKG_BUILD_DIR)/include/linux/ssb \
32 $(PKG_BUILD_DIR)/include/linux/bcma \
developer20d67712022-03-02 14:09:32 +080033diff --git a/package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh b/package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh
developer8169b4f2023-10-12 09:34:58 +080034index 8606093..e1091df 100644
developer20d67712022-03-02 14:09:32 +080035--- a/package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh
36+++ b/package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh
developer37215362023-09-15 14:16:34 +080037@@ -25,10 +25,12 @@ drv_mac80211_init_device_config() {
developer0ba09b62023-03-10 18:43:49 +080038 config_add_string path phy 'macaddr:macaddr'
39 config_add_string tx_burst
developer0ba09b62023-03-10 18:43:49 +080040 config_add_string distance
developer93607dd2023-08-30 04:53:00 +080041+ config_add_int mbssid mu_onoff sr_enable sr_enhanced rnr obss_interval
developer0ba09b62023-03-10 18:43:49 +080042 config_add_int beacon_int chanbw frag rts
developer93607dd2023-08-30 04:53:00 +080043 config_add_int rxantenna txantenna txpower min_tx_power
developer37215362023-09-15 14:16:34 +080044 config_add_int num_global_macaddr multiple_bssid
45 config_add_boolean noscan ht_coex acs_exclude_dfs background_radar
developer75c99f42023-09-04 11:28:21 +080046+ config_add_boolean noscan ht_coex acs_exclude_dfs background_radar background_cert_mode
47 config_add_array ht_capab
48 config_add_array channels
49 config_add_array scan_list
developer37215362023-09-15 14:16:34 +080050@@ -51,7 +53,10 @@ drv_mac80211_init_device_config() {
developer785b6502023-04-19 18:31:11 +080051 he_spr_sr_control \
52 he_spr_psr_enabled \
53 he_bss_color_enabled \
54- he_twt_required
55+ he_twt_required \
56+ he_twt_responder \
57+ etxbfen \
58+ itxbfen
59 config_add_int \
60 beamformer_antennas \
61 beamformee_antennas \
developer37215362023-09-15 14:16:34 +080062@@ -138,13 +143,11 @@ mac80211_hostapd_setup_base() {
developer0ba09b62023-03-10 18:43:49 +080063 [ -n "$acs_exclude_dfs" ] && [ "$acs_exclude_dfs" -gt 0 ] &&
64 append base_cfg "acs_exclude_dfs=1" "$N"
65
66- json_get_vars noscan ht_coex min_tx_power:0 tx_burst
developer93607dd2023-08-30 04:53:00 +080067+ json_get_vars noscan ht_coex min_tx_power:0 tx_burst mbssid mu_onoff rnr obss_interval
developer2c4f7e82023-05-11 19:56:55 +080068+ json_get_vars etxbfen:1 itxbfen:0
developer8d77be32022-10-20 15:08:25 +080069 json_get_values ht_capab_list ht_capab
developer20d67712022-03-02 14:09:32 +080070 json_get_values channel_list channels
71
72- [ "$auto_channel" = 0 ] && [ -z "$channel_list" ] && \
73- channel_list="$channel"
74-
developer9b3248d2022-07-06 00:44:05 +080075 [ "$min_tx_power" -gt 0 ] && append base_cfg "min_tx_power=$min_tx_power"
developer20d67712022-03-02 14:09:32 +080076
developer9b3248d2022-07-06 00:44:05 +080077 set_default noscan 0
developerda1bac72023-09-19 10:32:47 +080078@@ -158,21 +161,42 @@ mac80211_hostapd_setup_base() {
developer785b6502023-04-19 18:31:11 +080079 ieee80211n=1
80 ht_capab=
81 case "$htmode" in
82- VHT20|HT20|HE20) ;;
83- HT40*|VHT40|VHT80|VHT160|HE40|HE80|HE160)
84+ VHT20|HT20|HE20|EHT20) ;;
developerbe3cf972023-04-27 09:58:26 +080085+ HT40*|VHT40|VHT80|VHT160|HE40*|HE80|HE160|EHT40*|EHT80|EHT160|EHT320*)
developer785b6502023-04-19 18:31:11 +080086 case "$hwmode" in
87 a)
88 case "$(( (($channel / 4) + $chan_ofs) % 2 ))" in
developerda1bac72023-09-19 10:32:47 +080089 1) ht_capab="[HT40+]";;
90 0) ht_capab="[HT40-]";;
91 esac
92+ case "$htmode" in
93+ HT40-|HE40-|EHT40-)
94+ if [ "$auto_channel" -gt 0 ]; then
95+ ht_capab="[HT40-]"
96+ fi
97+ ;;
98+ esac
developerbe3cf972023-04-27 09:58:26 +080099 ;;
100 *)
101 case "$htmode" in
102- HT40+) ht_capab="[HT40+]";;
103- HT40-) ht_capab="[HT40-]";;
104+ HT40+|HE40+|EHT40+)
105+ if [ "$channel" -gt 9 ]; then
106+ echo "Could not set the center freq with this HT mode setting"
107+ return 1
108+ else
109+ ht_capab="[HT40+]"
110+ fi
111+ ;;
112+ HT40-|HE40-|EHT40-)
developerda1bac72023-09-19 10:32:47 +0800113+ if [ "$channel" -lt 5 -a "$auto_channel" -eq 0 ]; then
developerbe3cf972023-04-27 09:58:26 +0800114+ echo "Could not set the center freq with this HT mode setting"
115+ return 1
116+ else
117+ ht_capab="[HT40-]"
118+ fi
119+ ;;
120 *)
developerda1bac72023-09-19 10:32:47 +0800121- if [ "$channel" -lt 7 ]; then
122+ if [ "$channel" -lt 7 -o "$auto_channel" -gt 0 ]; then
developerbe3cf972023-04-27 09:58:26 +0800123 ht_capab="[HT40+]"
developerda1bac72023-09-19 10:32:47 +0800124 else
125 ht_capab="[HT40-]"
126@@ -181,7 +205,6 @@ mac80211_hostapd_setup_base() {
127 esac
128 ;;
129 esac
130- [ "$auto_channel" -gt 0 ] && ht_capab="[HT40+]"
131 ;;
132 *) ieee80211n= ;;
133 esac
134@@ -192,6 +215,11 @@ mac80211_hostapd_setup_base() {
developer93607dd2023-08-30 04:53:00 +0800135 set_default ht_coex 0
136 append base_cfg "ht_coex=$ht_coex" "$N"
137
138+ [ "$ht_coex" -eq 1 ] && {
139+ set_default obss_interval 300
140+ append base_cfg "obss_interval=$obss_interval" "$N"
141+ }
142+
143 json_get_vars \
144 ldpc:1 \
145 greenfield:0 \
developerda1bac72023-09-19 10:32:47 +0800146@@ -203,7 +231,7 @@ mac80211_hostapd_setup_base() {
developer785b6502023-04-19 18:31:11 +0800147 dsss_cck_40:1
148
149 ht_cap_mask=0
150- for cap in $(iw phy "$phy" info | grep 'Capabilities:' | cut -d: -f2); do
151+ for cap in $(iw phy "$phy" info | grep 'Capabilities: 0x' | cut -d: -f2); do
152 ht_cap_mask="$(($ht_cap_mask | $cap))"
153 done
154
developerda1bac72023-09-19 10:32:47 +0800155@@ -234,8 +262,8 @@ mac80211_hostapd_setup_base() {
developer785b6502023-04-19 18:31:11 +0800156
157 idx="$channel"
158 case "$htmode" in
159- VHT20|HE20) enable_ac=1;;
160- VHT40|HE40)
161+ VHT20|HE20|EHT20) enable_ac=1;;
162+ VHT40|HE40|EHT40)
163 case "$(( (($channel / 4) + $chan_ofs) % 2 ))" in
164 1) idx=$(($channel + 2));;
165 0) idx=$(($channel - 2));;
developerda1bac72023-09-19 10:32:47 +0800166@@ -243,7 +271,7 @@ mac80211_hostapd_setup_base() {
developer785b6502023-04-19 18:31:11 +0800167 enable_ac=1
168 vht_center_seg0=$idx
169 ;;
170- VHT80|HE80)
171+ VHT80|HE80|EHT80)
172 case "$(( (($channel / 4) + $chan_ofs) % 4 ))" in
173 1) idx=$(($channel + 6));;
174 2) idx=$(($channel + 2));;
developerda1bac72023-09-19 10:32:47 +0800175@@ -254,7 +282,7 @@ mac80211_hostapd_setup_base() {
developer785b6502023-04-19 18:31:11 +0800176 vht_oper_chwidth=1
177 vht_center_seg0=$idx
178 ;;
179- VHT160|HE160)
180+ VHT160|HE160|EHT160)
181 if [ "$band" = "6g" ]; then
182 case "$channel" in
183 1|5|9|13|17|21|25|29) idx=15;;
developerda1bac72023-09-19 10:32:47 +0800184@@ -269,23 +297,58 @@ mac80211_hostapd_setup_base() {
developeradd8de62023-05-02 16:25:52 +0800185 case "$channel" in
186 36|40|44|48|52|56|60|64) idx=50;;
187 100|104|108|112|116|120|124|128) idx=114;;
188+ 149|153|157|161|165|169|173|177) idx=163;;
189 esac
190 fi
191 enable_ac=1
developer785b6502023-04-19 18:31:11 +0800192 vht_oper_chwidth=2
193 vht_center_seg0=$idx
194 ;;
195+ EHT320*)
196+ case "$channel" in
197+ 1|5|9|13|17|21|25|29) idx=31;;
198+ 33|37|41|45|49|53|57|61| \
199+ 65|69|73|77|81|85|89|93) idx=63;;
200+ 97|101|105|109|113|117|121|125| \
201+ 129|133|137|141|145|149|153|157) idx=127;;
202+ 161|165|169|173|177|181|185|189| \
203+ 193|197|201|205|209|213|217|221) idx=191;;
204+ esac
205+ if [[ "$htmode" = "EHT320-1" && "$channel" -ge "193" ]] ||
206+ [[ "$htmode" = "EHT320-2" && "$channel" -le "29" ]]; then
207+ echo "Could not set the center freq with this EHT setting"
208+ return 1
209+ elif [[ "$htmode" = "EHT320-1" && "$channel" -ge "33" ]]; then
210+ if [ "$channel" -gt $idx ]; then
211+ idx=$(($idx + 32))
212+ else
213+ idx=$(($idx - 32))
214+ fi
215+ fi
216+ vht_oper_chwidth=2
217+ if [ "$channel" -gt $idx ]; then
218+ vht_center_seg0=$(($idx + 16))
219+ else
220+ vht_center_seg0=$(($idx - 16))
221+ fi
222+ eht_oper_chwidth=9
223+ eht_oper_centr_freq_seg0_idx=$idx
224+ ;;
225 esac
226 [ "$band" = "5g" ] && {
developer75c99f42023-09-04 11:28:21 +0800227- json_get_vars background_radar:0
228+ json_get_vars \
229+ background_radar:0 \
230+ background_cert_mode:0 \
231
232 [ "$background_radar" -eq 1 ] && append base_cfg "enable_background_radar=1" "$N"
233+ [ "$background_cert_mode" -eq 1 ] && append base_cfg "background_radar_mode=1" "$N"
234 }
developer785b6502023-04-19 18:31:11 +0800235 [ "$band" = "6g" ] && {
236 op_class=
237 case "$htmode" in
238- HE20) op_class=131;;
239- HE*) op_class=$((132 + $vht_oper_chwidth))
240+ HE20|EHT20) op_class=131;;
241+ EHT320*) op_class=137;;
242+ HE*|EHT*) op_class=$((132 + $vht_oper_chwidth))
243 esac
244 [ -n "$op_class" ] && append base_cfg "op_class=$op_class" "$N"
245 }
developerda1bac72023-09-19 10:32:47 +0800246@@ -313,7 +376,6 @@ mac80211_hostapd_setup_base() {
developer8b04dfd2022-12-07 16:29:19 +0800247 vht_link_adapt:3 \
248 vht160:2
249
250- set_default tx_burst 2.0
251 append base_cfg "ieee80211ac=1" "$N"
252 vht_cap=0
253 for cap in $(iw phy "$phy" info | awk -F "[()]" '/VHT Capabilities/ { print $2 }'); do
developerda1bac72023-09-19 10:32:47 +0800254@@ -327,6 +389,12 @@ mac80211_hostapd_setup_base() {
developer785b6502023-04-19 18:31:11 +0800255 [ "$rx_stbc" -lt "$cap_rx_stbc" ] && cap_rx_stbc="$rx_stbc"
256 vht_cap="$(( ($vht_cap & ~(0x700)) | ($cap_rx_stbc << 8) ))"
257
258+ [ "$etxbfen" -eq 0 ] && {
259+ su_beamformer=0
260+ su_beamformee=0
261+ mu_beamformer=0
262+ }
263+
264 mac80211_add_capabilities vht_capab $vht_cap \
265 RXLDPC:0x10::$rxldpc \
266 SHORT-GI-80:0x20::$short_gi_80 \
developerda1bac72023-09-19 10:32:47 +0800267@@ -408,7 +476,7 @@ mac80211_hostapd_setup_base() {
developer785b6502023-04-19 18:31:11 +0800268 # 802.11ax
269 enable_ax=0
270 case "$htmode" in
271- HE*) enable_ax=1 ;;
272+ HE*|EHT*) enable_ax=1 ;;
273 esac
274
275 if [ "$enable_ax" != "0" ]; then
developerda1bac72023-09-19 10:32:47 +0800276@@ -417,10 +485,11 @@ mac80211_hostapd_setup_base() {
developer785b6502023-04-19 18:31:11 +0800277 he_su_beamformee:1 \
278 he_mu_beamformer:1 \
279 he_twt_required:0 \
280+ he_twt_responder \
281 he_spr_sr_control:3 \
282 he_spr_psr_enabled:0 \
283 he_spr_non_srg_obss_pd_max_offset:0 \
284- he_bss_color:128 \
285+ he_bss_color \
286 he_bss_color_enabled:1
287
288 he_phy_cap=$(iw phy "$phy" info | sed -n '/HE Iftypes: AP/,$p' | awk -F "[()]" '/HE PHY Capabilities/ { print $2 }' | head -1)
developerda1bac72023-09-19 10:32:47 +0800289@@ -434,6 +503,11 @@ mac80211_hostapd_setup_base() {
developer785b6502023-04-19 18:31:11 +0800290 append base_cfg "he_oper_centr_freq_seg0_idx=$vht_center_seg0" "$N"
291 }
292
293+ [ "$etxbfen" -eq 0 ] && {
294+ he_su_beamformer=0
295+ he_mu_beamformer=0
296+ }
297+
298 mac80211_add_he_capabilities \
299 he_su_beamformer:${he_phy_cap:6:2}:0x80:$he_su_beamformer \
300 he_su_beamformee:${he_phy_cap:8:2}:0x1:$he_su_beamformee \
developerda1bac72023-09-19 10:32:47 +0800301@@ -441,7 +515,14 @@ mac80211_hostapd_setup_base() {
developer785b6502023-04-19 18:31:11 +0800302 he_spr_psr_enabled:${he_phy_cap:14:2}:0x1:$he_spr_psr_enabled \
303 he_twt_required:${he_mac_cap:0:2}:0x6:$he_twt_required
304
305+ if [ -n "$he_twt_responder" ]; then
306+ append base_cfg "he_twt_responder=$he_twt_responder" "$N"
307+ fi
308 if [ "$he_bss_color_enabled" -gt 0 ]; then
developer830efa72023-05-18 19:32:48 +0800309+ if !([ "$he_bss_color" -gt 0 ] && [ "$he_bss_color" -le 64 ]); then
developer785b6502023-04-19 18:31:11 +0800310+ rand=$(head -n 1 /dev/urandom | tr -dc 0-9 | head -c 2)
311+ he_bss_color=$((rand % 63 + 1))
312+ fi
313 append base_cfg "he_bss_color=$he_bss_color" "$N"
314 [ "$he_spr_non_srg_obss_pd_max_offset" -gt 0 ] && { \
315 append base_cfg "he_spr_non_srg_obss_pd_max_offset=$he_spr_non_srg_obss_pd_max_offset" "$N"
developerda1bac72023-09-19 10:32:47 +0800316@@ -460,34 +541,69 @@ mac80211_hostapd_setup_base() {
developer619eaa32023-08-29 13:33:51 +0800317 append base_cfg "he_mu_edca_qos_info_q_ack=0" "$N"
318 append base_cfg "he_mu_edca_qos_info_queue_request=0" "$N"
319 append base_cfg "he_mu_edca_qos_info_txop_request=0" "$N"
320- append base_cfg "he_mu_edca_ac_be_aifsn=8" "$N"
321+ append base_cfg "he_mu_edca_ac_be_aifsn=0" "$N"
322 append base_cfg "he_mu_edca_ac_be_aci=0" "$N"
323 append base_cfg "he_mu_edca_ac_be_ecwmin=9" "$N"
324 append base_cfg "he_mu_edca_ac_be_ecwmax=10" "$N"
325 append base_cfg "he_mu_edca_ac_be_timer=255" "$N"
326- append base_cfg "he_mu_edca_ac_bk_aifsn=15" "$N"
327+ append base_cfg "he_mu_edca_ac_bk_aifsn=0" "$N"
328 append base_cfg "he_mu_edca_ac_bk_aci=1" "$N"
329 append base_cfg "he_mu_edca_ac_bk_ecwmin=9" "$N"
330 append base_cfg "he_mu_edca_ac_bk_ecwmax=10" "$N"
331 append base_cfg "he_mu_edca_ac_bk_timer=255" "$N"
332 append base_cfg "he_mu_edca_ac_vi_ecwmin=5" "$N"
333 append base_cfg "he_mu_edca_ac_vi_ecwmax=7" "$N"
334- append base_cfg "he_mu_edca_ac_vi_aifsn=5" "$N"
335+ append base_cfg "he_mu_edca_ac_vi_aifsn=0" "$N"
336 append base_cfg "he_mu_edca_ac_vi_aci=2" "$N"
337 append base_cfg "he_mu_edca_ac_vi_timer=255" "$N"
338- append base_cfg "he_mu_edca_ac_vo_aifsn=5" "$N"
339+ append base_cfg "he_mu_edca_ac_vo_aifsn=0" "$N"
340 append base_cfg "he_mu_edca_ac_vo_aci=3" "$N"
341 append base_cfg "he_mu_edca_ac_vo_ecwmin=5" "$N"
342 append base_cfg "he_mu_edca_ac_vo_ecwmax=7" "$N"
developer8b04dfd2022-12-07 16:29:19 +0800343 append base_cfg "he_mu_edca_ac_vo_timer=255" "$N"
344 fi
345
developer18015ad2023-07-13 13:18:19 +0800346+ set_default tx_burst 2
developer8b04dfd2022-12-07 16:29:19 +0800347+
developer785b6502023-04-19 18:31:11 +0800348+ # 802.11be
349+ enable_be=0
350+ case "$htmode" in
351+ EHT*) enable_be=1 ;;
352+ esac
353+
354+ if [ "$enable_be" != "0" ]; then
355+ append base_cfg "ieee80211be=1" "$N"
356+ if [ "$etxbfen" -eq 0 ]; then
357+ append base_cfg "eht_su_beamformee=1" "$N"
358+ else
359+ append base_cfg "eht_su_beamformer=1" "$N"
360+ append base_cfg "eht_su_beamformee=1" "$N"
361+ append base_cfg "eht_mu_beamformer=1" "$N"
362+ fi
363+ [ "$hwmode" = "a" ] && {
364+ case $htmode in
365+ EHT320*)
366+ append base_cfg "eht_oper_chwidth=$eht_oper_chwidth" "$N"
367+ append base_cfg "eht_oper_centr_freq_seg0_idx=$eht_oper_centr_freq_seg0_idx" "$N"
368+ ;;
369+ *)
370+ append base_cfg "eht_oper_chwidth=$vht_oper_chwidth" "$N"
371+ append base_cfg "eht_oper_centr_freq_seg0_idx=$vht_center_seg0" "$N"
372+ ;;
373+ esac
374+ }
375+ fi
376+
developer8b04dfd2022-12-07 16:29:19 +0800377 hostapd_prepare_device_config "$hostapd_conf_file" nl80211
378 cat >> "$hostapd_conf_file" <<EOF
379 ${channel:+channel=$channel}
developer0ba09b62023-03-10 18:43:49 +0800380 ${channel_list:+chanlist=$channel_list}
381 ${hostapd_noscan:+noscan=1}
382 ${tx_burst:+tx_queue_data2_burst=$tx_burst}
383+${mbssid:+mbssid=$mbssid}
developer785b6502023-04-19 18:31:11 +0800384+${mu_onoff:+mu_onoff=$mu_onoff}
385+${itxbfen:+ibf_enable=$itxbfen}
developer2c6592a2023-07-21 11:20:56 +0800386+${rnr:+rnr=$rnr}
developer37215362023-09-15 14:16:34 +0800387 ${multiple_bssid:+mbssid=$multiple_bssid}
388 #num_global_macaddr=$num_global_macaddr
developer0ba09b62023-03-10 18:43:49 +0800389 $base_cfg
developerda1bac72023-09-19 10:32:47 +0800390@@ -515,7 +631,7 @@ mac80211_hostapd_setup_bss() {
developer093e1a32023-02-24 16:10:53 +0800391 append hostapd_cfg "wds_sta=1" "$N"
392 [ -n "$wds_bridge" ] && append hostapd_cfg "wds_bridge=$wds_bridge" "$N"
393 }
394- [ "$staidx" -gt 0 -o "$start_disabled" -eq 1 ] && append hostapd_cfg "start_disabled=1" "$N"
395+ [ "$start_disabled" -eq 1 ] && append hostapd_cfg "start_disabled=1" "$N"
396
397 cat >> /var/run/hostapd-$phy.conf <<EOF
398 $hostapd_cfg
developerda1bac72023-09-19 10:32:47 +0800399@@ -526,6 +642,31 @@ ${max_listen_int:+max_listen_interval=$max_listen_int}
developer0ba09b62023-03-10 18:43:49 +0800400 EOF
401 }
402
403+mac80211_generate_mbssid_mac() {
404+ local phy="$1"
405+ local transmitted_bssid="$2"
developer1952bcd2023-06-20 20:14:37 +0800406+ local id="${mbssidx:-0}"
developer0ba09b62023-03-10 18:43:49 +0800407+
408+ local ref="$(cat /sys/class/ieee80211/${phy}/macaddress)"
developer0ba09b62023-03-10 18:43:49 +0800409+
410+ if [ -z "$transmitted_bssid" ]; then
411+ transmitted_bssid=$ref
412+ fi
413+
414+ if [ $id -eq 0 ]; then
415+ echo "$transmitted_bssid"
416+ return
417+ fi
418+
419+ local oIFS="$IFS"; IFS=":"; set -- $transmitted_bssid; IFS="$oIFS"
420+
421+ # Calculate nontransmitted bssid
developer0ba09b62023-03-10 18:43:49 +0800422+ b6="0x$6"
423+ ref_b6=$(($b6 % $max_mbssid))
developer1952bcd2023-06-20 20:14:37 +0800424+ b6=$(($b6 - $ref_b6 + ($ref_b6 + $id) % $max_mbssid))
developer0ba09b62023-03-10 18:43:49 +0800425+ printf "%s:%s:%s:%s:%s:%02x" $1 $2 $3 $4 $5 $b6
426+}
427+
428 mac80211_get_addr() {
429 local phy="$1"
430 local idx="$(($2 + 1))"
developerda1bac72023-09-19 10:32:47 +0800431@@ -649,7 +790,19 @@ mac80211_prepare_vif() {
developer24684862023-08-02 08:10:38 +0800432 json_add_string _ifname "$ifname"
developer0ba09b62023-03-10 18:43:49 +0800433
developer37215362023-09-15 14:16:34 +0800434 default_macaddr=
developer0ba09b62023-03-10 18:43:49 +0800435- if [ -z "$macaddr" ]; then
developerd2fbd572023-06-19 19:48:25 +0800436+ if [ "$mbssid" -gt 0 ] && [ "$mode" == "ap" ]; then
developer1952bcd2023-06-20 20:14:37 +0800437+ [ "$mbssidx" -eq 0 ] && {
438+ if [ -z $macaddr ]; then
439+ transmitted_bssid="$(mac80211_generate_mac $phy)"
440+ else
441+ # uci set mac address
442+ transmitted_bssid=$macaddr
443+ fi
444+ macidx="$(($macidx + 1))"
developer0ba09b62023-03-10 18:43:49 +0800445+ }
446+ macaddr="$(mac80211_generate_mbssid_mac $phy $transmitted_bssid)"
developer1952bcd2023-06-20 20:14:37 +0800447+ mbssidx="$(($mbssidx + 1))"
developer0ba09b62023-03-10 18:43:49 +0800448+ elif [ -z "$macaddr" ]; then
449 macaddr="$(mac80211_generate_mac $phy)"
450 macidx="$(($macidx + 1))"
developer37215362023-09-15 14:16:34 +0800451 default_macaddr=1
developerda1bac72023-09-19 10:32:47 +0800452@@ -913,6 +1066,14 @@ hostapd_set_config() {
developer24684862023-08-02 08:10:38 +0800453 }
454
455 ubus wait_for hostapd
456+
457+ # each phy sleeps different times to prevent for ubus race condition.
458+ if [ "$phy" = "phy1" ]; then
developer8169b4f2023-10-12 09:34:58 +0800459+ sleep 3;
developer24684862023-08-02 08:10:38 +0800460+ elif [ "$phy" = "phy2" ]; then
developer8169b4f2023-10-12 09:34:58 +0800461+ sleep 6;
developer24684862023-08-02 08:10:38 +0800462+ fi
463+
464 local hostapd_res="$(ubus call hostapd config_set "{ \"phy\": \"$phy\", \"config\":\"${hostapd_conf_file}\", \"prev_config\": \"${hostapd_conf_file}.prev\"}")"
465 ret="$?"
466 [ "$ret" != 0 -o -z "$hostapd_res" ] && {
developerda1bac72023-09-19 10:32:47 +0800467@@ -990,6 +1151,9 @@ mac80211_setup_vif() {
developerf0de14b2022-12-14 23:07:34 +0800468
469 json_select ..
470 [ -n "$failed" ] || wireless_add_vif "$name" "$ifname"
471+
472+ echo "Setup SMP Affinity"
473+ /sbin/smp-mt76.sh
474 }
475
476 get_freq() {
developerda1bac72023-09-19 10:32:47 +0800477@@ -1041,6 +1205,10 @@ mac80211_reset_config() {
developer37215362023-09-15 14:16:34 +0800478 wdev_tool "$phy" set_config '{}'
developer0ba09b62023-03-10 18:43:49 +0800479 }
480
481+mac80211_count_ap() {
482+ total_num_ap=$(($total_num_ap + 1))
483+}
484+
485 drv_mac80211_setup() {
486 json_select config
487 json_get_vars \
developerda1bac72023-09-19 10:32:47 +0800488@@ -1049,7 +1217,8 @@ drv_mac80211_setup() {
developer93607dd2023-08-30 04:53:00 +0800489 txpower \
developer74503112023-06-29 17:34:49 +0800490 rxantenna txantenna \
developer37215362023-09-15 14:16:34 +0800491 frag rts beacon_int:100 htmode \
492- num_global_macaddr:1 multiple_bssid
493+ num_global_macaddr:1 multiple_bssid \
developer74503112023-06-29 17:34:49 +0800494+ sr_enable sr_enhanced
495 json_get_values basic_rate_list basic_rate
496 json_get_values scan_list scan_list
497 json_select ..
developerda1bac72023-09-19 10:32:47 +0800498@@ -1084,6 +1253,7 @@ drv_mac80211_setup() {
developer24684862023-08-02 08:10:38 +0800499
developer1952bcd2023-06-20 20:14:37 +0800500 macidx=0
501 staidx=0
502+ mbssidx=0
503
504 [ -n "$chanbw" ] && {
505 for file in /sys/kernel/debug/ieee80211/$phy/ath9k*/chanbw /sys/kernel/debug/ieee80211/$phy/ath5k/bwmode; do
developerda1bac72023-09-19 10:32:47 +0800506@@ -1132,6 +1302,16 @@ drv_mac80211_setup() {
developer24684862023-08-02 08:10:38 +0800507
508 wpa_supplicant_init_config
developer0ba09b62023-03-10 18:43:49 +0800509
510+ total_num_ap=0
511+ max_mbssid=1
512+ for_each_interface "ap" mac80211_count_ap
513+ total_num_ap=$(($total_num_ap - 1))
514+ while [ $total_num_ap -gt 0 ]
515+ do
516+ total_num_ap=$(($total_num_ap >> 1))
517+ max_mbssid=$(($max_mbssid << 1))
518+ done
519+
520 mac80211_prepare_iw_htmode
developer24684862023-08-02 08:10:38 +0800521 active_ifnames=
522 for_each_interface "ap sta adhoc mesh monitor" mac80211_prepare_vif
developerda1bac72023-09-19 10:32:47 +0800523@@ -1140,6 +1320,9 @@ drv_mac80211_setup() {
developer24684862023-08-02 08:10:38 +0800524 [ -x /usr/sbin/wpa_supplicant ] && wpa_supplicant_set_config "$phy"
525 [ -x /usr/sbin/hostapd ] && hostapd_set_config "$phy"
developer74503112023-06-29 17:34:49 +0800526
527+ [ -n "$sr_enable" ] && echo "$sr_enable" > /sys/kernel/debug/ieee80211/$phy/mt76/sr_enable
528+ [ -n "$sr_enhanced" ] && echo "$sr_enhanced" > /sys/kernel/debug/ieee80211/$phy/mt76/sr_enhanced_enable
529+
developer24684862023-08-02 08:10:38 +0800530 [ -x /usr/sbin/wpa_supplicant ] && wpa_supplicant_start "$phy"
developer74503112023-06-29 17:34:49 +0800531
developer24684862023-08-02 08:10:38 +0800532 json_set_namespace wdev_uc prev
developer9b3248d2022-07-06 00:44:05 +0800533diff --git a/package/kernel/mac80211/files/lib/wifi/mac80211.sh b/package/kernel/mac80211/files/lib/wifi/mac80211.sh
developer8169b4f2023-10-12 09:34:58 +0800534index e24a2a6..da3ee8c 100644
developere2597ba2022-06-24 13:09:16 +0800535--- a/package/kernel/mac80211/files/lib/wifi/mac80211.sh
536+++ b/package/kernel/mac80211/files/lib/wifi/mac80211.sh
developer20ce7bd2023-05-20 13:25:14 +0800537@@ -60,6 +60,9 @@ BEGIN {
developer785b6502023-04-19 18:31:11 +0800538 if (vht && band != "1:") mode="VHT80"
539 if (he) mode="HE80"
540 if (he && band == "1:") mode="HE20"
developer20ce7bd2023-05-20 13:25:14 +0800541+ if (eht && band == "2:") mode="EHT160"
542+ if (eht && band == "4:") mode="EHT320"
developer785b6502023-04-19 18:31:11 +0800543+ if (eht && band == "1:") mode="EHT20"
544 sub("\\[", "", channel)
545 sub("\\]", "", channel)
546 bands = bands band channel ":" mode " "
developer20ce7bd2023-05-20 13:25:14 +0800547@@ -73,6 +76,7 @@ $1 == "Band" {
developer785b6502023-04-19 18:31:11 +0800548 vht = ""
549 ht = ""
550 he = ""
551+ eht = ""
552 }
553
554 $0 ~ "Capabilities:" {
developer20ce7bd2023-05-20 13:25:14 +0800555@@ -87,6 +91,18 @@ $0 ~ "HE Iftypes" {
developer785b6502023-04-19 18:31:11 +0800556 he=1
557 }
558
559+$0 ~ "EHT Iftypes" {
560+ eht=1
561+}
562+
developer20ce7bd2023-05-20 13:25:14 +0800563+$0 ~ / *HE MAC Capabilities \(0x000000000000\)/ {
564+ he=0
565+}
566+
567+$0 ~ / *EHT MAC Capabilities \(0x0000\)/ {
568+ eht=0
569+}
570+
developer785b6502023-04-19 18:31:11 +0800571 $1 == "*" && $3 == "MHz" && $0 !~ /disabled/ && band && !channel {
572 channel = $4
573 }
developer75c99f42023-09-04 11:28:21 +0800574@@ -120,6 +136,25 @@ get_band_defaults() {
developere2597ba2022-06-24 13:09:16 +0800575 mode_band="$band"
576 channel="$chan"
577 htmode="$mode"
578+ if [ "$band" = "6g" ]
579+ then
580+ encryption=sae
581+ key=12345678
developer20ce7bd2023-05-20 13:25:14 +0800582+ sae_pwe=2
583+ ieee80211w=2
developeradbb45b2023-06-09 14:43:01 +0800584+ channel=37
585+ mbssid=1
developer75c99f42023-09-04 11:28:21 +0800586+ elif [ "$band" = "5g" ]
587+ then
588+ noscan=1
589+ encryption=none
590+ rnr=1
591+ background_radar=1
developere2597ba2022-06-24 13:09:16 +0800592+ else
developer659b07e2023-05-25 12:34:13 +0800593+ noscan=1
developere2597ba2022-06-24 13:09:16 +0800594+ encryption=none
developer2c6592a2023-07-21 11:20:56 +0800595+ rnr=1
developere2597ba2022-06-24 13:09:16 +0800596+ fi
597 done
598 }
599
developer75c99f42023-09-04 11:28:21 +0800600@@ -153,6 +188,10 @@ detect_mac80211() {
developer785b6502023-04-19 18:31:11 +0800601
602 json_load_file /etc/board.json
603
604+ # generate random bytes for macaddr
605+ rand=$(hexdump -C /dev/urandom | head -n 1 &)
606+ killall hexdump
607+
608 for _dev in /sys/class/ieee80211/*; do
609 [ -e "$_dev" ] || continue
610
developer75c99f42023-09-04 11:28:21 +0800611@@ -162,6 +201,14 @@ detect_mac80211() {
developere2597ba2022-06-24 13:09:16 +0800612 channel=""
613 htmode=""
614 ht_capab=""
615+ encryption=""
developer659b07e2023-05-25 12:34:13 +0800616+ noscan=""
developere2597ba2022-06-24 13:09:16 +0800617+ key=""
developer09257932023-05-09 13:41:30 +0800618+ sae_pwe=""
developer20ce7bd2023-05-20 13:25:14 +0800619+ ieee80211w=""
developeradbb45b2023-06-09 14:43:01 +0800620+ mbssid=""
developer2c6592a2023-07-21 11:20:56 +0800621+ rnr=""
developer75c99f42023-09-04 11:28:21 +0800622+ background_radar=""
developere2597ba2022-06-24 13:09:16 +0800623
624 get_band_defaults "$dev"
625
developer75c99f42023-09-04 11:28:21 +0800626@@ -196,6 +243,14 @@ detect_mac80211() {
developer785b6502023-04-19 18:31:11 +0800627 ;;
628 esac
629
developer212c0d82023-07-13 19:41:47 +0800630+ macaddr=""
developer1325ba72023-06-26 13:43:31 +0800631+ if (dmesg | grep -q "eeprom load fail"); then
developer1952bcd2023-06-20 20:14:37 +0800632+ for i in $(seq 2 3); do
633+ macaddr=${macaddr}:$(echo $rand | cut -d ' ' -f $i)
634+ done
635+ macaddr="00:0$(($devidx - 1)):55:66${macaddr}"
developer1952bcd2023-06-20 20:14:37 +0800636+ fi
developer785b6502023-04-19 18:31:11 +0800637+
638 uci -q batch <<-EOF
639 set wireless.${name}=wifi-device
640 set wireless.${name}.type=mac80211
developer75c99f42023-09-04 11:28:21 +0800641@@ -203,15 +258,43 @@ detect_mac80211() {
developer09257932023-05-09 13:41:30 +0800642 set wireless.${name}.channel=${channel}
643 set wireless.${name}.band=${mode_band}
644 set wireless.${name}.htmode=$htmode
645- set wireless.${name}.disabled=1
developer20ce7bd2023-05-20 13:25:14 +0800646+ set wireless.${name}.country='US'
developer659b07e2023-05-25 12:34:13 +0800647+ set wireless.${name}.noscan=${noscan}
developer09257932023-05-09 13:41:30 +0800648+ set wireless.${name}.disabled=0
developeradbb45b2023-06-09 14:43:01 +0800649+EOF
650+ [ -n "$mbssid" ] && {
651+ uci -q set wireless.${name}.mbssid=${mbssid}
652+ }
developer2c6592a2023-07-21 11:20:56 +0800653+ [ -n "$rnr" ] && {
654+ uci -q set wireless.${name}.rnr=${rnr}
655+ }
developer75c99f42023-09-04 11:28:21 +0800656+ [ -n "$background_radar" ] && {
657+ uci -q set wireless.${name}.background_radar=${background_radar}
658+ }
developer09257932023-05-09 13:41:30 +0800659
developeradbb45b2023-06-09 14:43:01 +0800660+ uci -q batch <<-EOF
developer09257932023-05-09 13:41:30 +0800661 set wireless.default_${name}=wifi-iface
662 set wireless.default_${name}.device=${name}
developer8d77be32022-10-20 15:08:25 +0800663 set wireless.default_${name}.network=lan
664 set wireless.default_${name}.mode=ap
developer09257932023-05-09 13:41:30 +0800665- set wireless.default_${name}.ssid=OpenWrt
developer8d77be32022-10-20 15:08:25 +0800666- set wireless.default_${name}.encryption=none
developer09257932023-05-09 13:41:30 +0800667+ set wireless.default_${name}.ssid=OpenWrt-${mode_band}
developer8d77be32022-10-20 15:08:25 +0800668+ set wireless.default_${name}.encryption=${encryption}
developere2597ba2022-06-24 13:09:16 +0800669 EOF
developer212c0d82023-07-13 19:41:47 +0800670+
671+ # calibrated board will use eeprom macaddress, not ramdom address
672+ [ -n "$macaddr" ] && {
673+ uci -q set wireless.default_${name}.macaddr=${macaddr}
674+ }
675+
developere2597ba2022-06-24 13:09:16 +0800676+ [ -n "$key" ] && {
developer8d77be32022-10-20 15:08:25 +0800677+ uci -q set wireless.default_${name}.key=${key}
developere2597ba2022-06-24 13:09:16 +0800678+ }
developer09257932023-05-09 13:41:30 +0800679+ [ -n "$sae_pwe" ] && {
680+ uci -q set wireless.default_${name}.sae_pwe=${sae_pwe}
681+ }
developer20ce7bd2023-05-20 13:25:14 +0800682+ [ -n "$ieee80211w" ] && {
683+ uci -q set wireless.default_${name}.ieee80211w=${ieee80211w}
684+ }
developere2597ba2022-06-24 13:09:16 +0800685 uci -q commit wireless
developer8d77be32022-10-20 15:08:25 +0800686 done
687 }
developer85839fe2023-02-23 10:32:51 +0800688diff --git a/package/network/services/hostapd/files/hostapd.sh b/package/network/services/hostapd/files/hostapd.sh
developer8169b4f2023-10-12 09:34:58 +0800689index 271c1f7..4482c17 100644
developer85839fe2023-02-23 10:32:51 +0800690--- a/package/network/services/hostapd/files/hostapd.sh
691+++ b/package/network/services/hostapd/files/hostapd.sh
developer74503112023-06-29 17:34:49 +0800692@@ -60,7 +60,14 @@ hostapd_append_wpa_key_mgmt() {
developer93607dd2023-08-30 04:53:00 +0800693 append wpa_key_mgmt "WPA-EAP-SHA256"
developer74503112023-06-29 17:34:49 +0800694 ;;
695 sae)
696- append wpa_key_mgmt "SAE"
697+ case "$encryption" in
698+ *sae-ext*)
699+ append wpa_key_mgmt "SAE-EXT-KEY"
700+ ;;
701+ *)
702+ append wpa_key_mgmt "SAE"
703+ ;;
704+ esac
705 [ "${ieee80211r:-0}" -gt 0 ] && append wpa_key_mgmt "FT-SAE"
706 ;;
707 psk-sae)
developer93607dd2023-08-30 04:53:00 +0800708@@ -119,6 +126,7 @@ hostapd_common_add_device_config() {
developer74503112023-06-29 17:34:49 +0800709 config_add_int rts_threshold
710 config_add_int rssi_reject_assoc_rssi
711 config_add_int rssi_ignore_probe_request
712+ config_add_int rssi_reject_assoc_timeout
713 config_add_int maxassoc
714
715 config_add_string acs_chan_bias
developer93607dd2023-08-30 04:53:00 +0800716@@ -231,8 +239,10 @@ hostapd_prepare_device_config() {
developer74503112023-06-29 17:34:49 +0800717 hostapd_add_rate brlist "$br"
718 done
719
720+ json_get_vars rssi_reject_assoc_timeout
721 [ -n "$rssi_reject_assoc_rssi" ] && append base_cfg "rssi_reject_assoc_rssi=$rssi_reject_assoc_rssi" "$N"
722 [ -n "$rssi_ignore_probe_request" ] && append base_cfg "rssi_ignore_probe_request=$rssi_ignore_probe_request" "$N"
723+ [ -n "$rssi_reject_assoc_timeout" ] && append base_cfg "rssi_reject_assoc_timeout=$rssi_reject_assoc_timeout" "$N"
724 [ -n "$beacon_rate" ] && append base_cfg "beacon_rate=$beacon_rate" "$N"
725 [ -n "$rlist" ] && append base_cfg "supported_rates=$rlist" "$N"
726 [ -n "$brlist" ] && append base_cfg "basic_rates=$brlist" "$N"
developer93607dd2023-08-30 04:53:00 +0800727@@ -383,6 +393,24 @@ hostapd_common_add_bss_config() {
developer82408892023-03-27 15:09:00 +0800728 config_add_string fils_dhcp
729
730 config_add_int ocv
731+
732+ config_add_int disable_eht
733+ config_add_int disable_he
734+ config_add_int disable_vht
735+ config_add_int disable_ht
developer813f5d72023-03-28 17:44:38 +0800736+
developerf166f542023-05-25 14:40:30 +0800737+ config_add_boolean beacon_prot interworking
developer74503112023-06-29 17:34:49 +0800738+
739+ config_add_int unsol_bcast_probe_resp_interval
740+ config_add_int fils_discovery_min_interval
741+ config_add_int fils_discovery_max_interval
742+ config_add_boolean rnr
743+
744+ config_add_array sae_groups
745+ config_add_array owe_groups
746+ config_add_array pairwise
747+ config_add_string group_cipher
748+
developer82408892023-03-27 15:09:00 +0800749 }
750
751 hostapd_set_vlan_file() {
developer93607dd2023-08-30 04:53:00 +0800752@@ -447,11 +475,11 @@ append_iw_nai_realm() {
developerf166f542023-05-25 14:40:30 +0800753 }
754
755 append_iw_venue_name() {
756- append bss_conf "venue_name=$1" "$N"
757+ [ -n "$1" ] && append bss_conf "venue_name=$1" "$N"
758 }
759
760 append_iw_venue_url() {
761- append bss_conf "venue_url=$1" "$N"
762+ [ -n "$1" ] && append bss_conf "venue_url=$1" "$N"
763 }
764
765 append_hs20_oper_friendly_name() {
developer93607dd2023-08-30 04:53:00 +0800766@@ -569,7 +597,8 @@ hostapd_set_bss_options() {
developer74503112023-06-29 17:34:49 +0800767 ppsk airtime_bss_weight airtime_bss_limit airtime_sta_weight \
768 multicast_to_unicast_all proxy_arp per_sta_vif \
769 eap_server eap_user_file ca_cert server_cert private_key private_key_passwd server_id \
770- vendor_elements fils ocv
771+ vendor_elements fils ocv unsol_bcast_probe_resp_interval fils_discovery_min_interval \
772+ fils_discovery_max_interval rnr group_cipher
773
774 set_default fils 0
775 set_default isolate 0
developer37215362023-09-15 14:16:34 +0800776@@ -796,6 +825,35 @@ hostapd_set_bss_options() {
developer74503112023-06-29 17:34:49 +0800777 local auth_algs="$((($auth_mode_shared << 1) | $auth_mode_open))"
778 append bss_conf "auth_algs=${auth_algs:-1}" "$N"
779 append bss_conf "wpa=$wpa" "$N"
780+
781+ json_get_values pairwise pairwise
developer9097e5e2023-07-19 10:22:24 +0800782+ if [ -n "$pairwise" ]; then
783+ case "$pairwise" in
784+ *tkip+aes|*tkip+ccmp|*aes+tkip|*ccmp+tkip)
785+ wpa_cipher="CCMP TKIP"
786+ ;;
787+ *ccmp256)
788+ wpa_cipher="CCMP-256"
789+ ;;
790+ *aes|*ccmp)
791+ wpa_cipher="CCMP"
792+ ;;
793+ *tkip)
794+ wpa_cipher="TKIP"
795+ ;;
796+ *gcmp256)
797+ wpa_cipher="GCMP-256"
798+ ;;
799+ *gcmp)
800+ wpa_cipher="GCMP"
801+ ;;
802+ *)
803+ wpa_cipher=""
804+ ;;
805+ esac
806+ fi
developer74503112023-06-29 17:34:49 +0800807+ [ -n "$wpa_cipher" ] && wpa_pairwise="$wpa_cipher"
808+
809 [ -n "$wpa_pairwise" ] && append bss_conf "wpa_pairwise=$wpa_pairwise" "$N"
810
811 set_default wps_pushbutton 0
developer37215362023-09-15 14:16:34 +0800812@@ -847,7 +905,7 @@ hostapd_set_bss_options() {
developerda723192023-05-22 19:46:10 +0800813 }
814
815 append bss_conf "ssid=$ssid" "$N"
816- [ -n "$network_bridge" ] && append bss_conf "bridge=$network_bridge${N}wds_bridge=" "$N"
817+ [ -n "$network_bridge" ] && append bss_conf "bridge=$network_bridge${N}wds_bridge=$network_bridge" "$N"
818 [ -n "$network_ifname" ] && append bss_conf "snoop_iface=$network_ifname" "$N"
819 [ -n "$iapp_interface" ] && {
820 local ifname
developer37215362023-09-15 14:16:34 +0800821@@ -962,6 +1020,8 @@ hostapd_set_bss_options() {
developer74503112023-06-29 17:34:49 +0800822 fi
823
824 if [ "$wpa" -ge "2" ]; then
825+ json_get_values sae_groups sae_groups
826+ json_get_values owe_groups owe_groups
827 if [ -n "$network_bridge" -a "$rsn_preauth" = 1 ]; then
828 set_default auth_cache 1
829 append bss_conf "rsn_preauth=1" "$N"
developer37215362023-09-15 14:16:34 +0800830@@ -980,17 +1040,42 @@ hostapd_set_bss_options() {
developer74503112023-06-29 17:34:49 +0800831 append bss_conf "okc=$auth_cache" "$N"
832 [ "$auth_cache" = 0 -a "$fils" = 0 ] && append bss_conf "disable_pmksa_caching=1" "$N"
833
834+ [ -z "$group_cipher" ] && group_cipher="$wpa_cipher"
835+
836+ if [ -n "$sae_groups" -o -n "$owe_groups" ]; then
837+ case "$auth_type" in
838+ sae*)
839+ append bss_conf "sae_groups=$sae_groups" "$N"
840+ append bss_conf "group_cipher=$group_cipher" "$N"
841+ ;;
842+ owe)
843+ append bss_conf "owe_groups=$owe_groups" "$N"
844+ append bss_conf "group_cipher=$group_cipher" "$N"
845+ ;;
846+ esac
847+ fi
848+
developer813f5d72023-03-28 17:44:38 +0800849 # RSN -> allow management frame protection
850 case "$ieee80211w" in
851 [012])
852- json_get_vars ieee80211w_mgmt_cipher ieee80211w_max_timeout ieee80211w_retry_timeout
853+ json_get_vars ieee80211w_mgmt_cipher ieee80211w_max_timeout ieee80211w_retry_timeout beacon_prot
854 append bss_conf "ieee80211w=$ieee80211w" "$N"
855 [ "$ieee80211w" -gt "0" ] && {
developer74503112023-06-29 17:34:49 +0800856+ case "$group_cipher" in
857+ CCMP*)
858+ ieee80211w_mgmt_cipher="AES-128-CMAC"
859+ ;;
860+ GCMP-256)
861+ [[ "$encryption" != "*owe*" ]] && ieee80211w_mgmt_cipher="BIP-GMAC-256"
862+ ;;
863+ esac
developer813f5d72023-03-28 17:44:38 +0800864 if [ "$auth_type" = "eap192" ]; then
developer74503112023-06-29 17:34:49 +0800865 append bss_conf "group_mgmt_cipher=BIP-GMAC-256" "$N"
developer813f5d72023-03-28 17:44:38 +0800866 else
867 append bss_conf "group_mgmt_cipher=${ieee80211w_mgmt_cipher:-AES-128-CMAC}" "$N"
868 fi
869+ [ -n "$beacon_prot" ] && \
870+ append bss_conf "beacon_prot=$beacon_prot" "$N"
871 [ -n "$ieee80211w_max_timeout" ] && \
872 append bss_conf "assoc_sa_query_max_timeout=$ieee80211w_max_timeout" "$N"
873 [ -n "$ieee80211w_retry_timeout" ] && \
developer37215362023-09-15 14:16:34 +0800874@@ -1055,9 +1140,10 @@ hostapd_set_bss_options() {
developerf166f542023-05-25 14:40:30 +0800875 json_get_vars iw_roaming_consortium iw_domain_name iw_anqp_3gpp_cell_net iw_nai_realm
876 json_get_vars iw_anqp_elem iw_qos_map_set iw_ipaddr_type_availability iw_gas_address3
877 json_get_vars iw_venue_name iw_venue_url
878+ json_get_vars interworking
879
880 set_default iw_enabled 0
881- if [ "$iw_enabled" = "1" ]; then
882+ if [ "$iw_enabled" = "1" ] || [ "$interworking" = "1" ]; then
883 append bss_conf "interworking=1" "$N"
884 set_default iw_internet 1
885 set_default iw_asra 0
developer37215362023-09-15 14:16:34 +0800886@@ -1164,6 +1250,22 @@ hostapd_set_bss_options() {
developer74503112023-06-29 17:34:49 +0800887 append bss_conf "$val" "$N"
888 done
889
890+ if [ "$unsol_bcast_probe_resp_interval" -gt 0 ]; then
891+ append bss_conf "unsol_bcast_probe_resp_interval=$unsol_bcast_probe_resp_interval" "$N"
892+ fi
893+
894+ if [ -n "$fils_discovery_min_interval" ]; then
895+ append bss_conf "fils_discovery_min_interval=$fils_discovery_min_interval" "$N"
896+ fi
897+
898+ if [ -n "$fils_discovery_max_interval" ]; then
899+ append bss_conf "fils_discovery_max_interval=$fils_discovery_max_interval" "$N"
900+ fi
901+
902+ if [ -n "$rnr" ]; then
903+ append bss_conf "rnr=$rnr" "$N"
904+ fi
905+
developer5b3b7a92023-08-12 03:41:52 +0800906 append "$var" "$bss_conf" "$N"
907 return 0
908 }
developer37215362023-09-15 14:16:34 +0800909@@ -1251,6 +1353,7 @@ wpa_supplicant_prepare_interface() {
developer18015ad2023-07-13 13:18:19 +0800910 country_str="country=$country"
911 }
912
developer2cf3f4c2023-07-24 16:58:25 +0800913+ local tx_queue_data2_burst="tx_queue_data2_burst=0"
developer18015ad2023-07-13 13:18:19 +0800914 multiap_flag_file="${_config}.is_multiap"
915 if [ "$multi_ap" = "1" ]; then
916 touch "$multiap_flag_file"
developer37215362023-09-15 14:16:34 +0800917@@ -1262,6 +1365,7 @@ wpa_supplicant_prepare_interface() {
developer18015ad2023-07-13 13:18:19 +0800918 ${scan_list:+freq_list=$scan_list}
919 $ap_scan
920 $country_str
921+$tx_queue_data2_burst
922 EOF
923 return 0
924 }
developer37215362023-09-15 14:16:34 +0800925@@ -1533,12 +1637,38 @@ wpa_supplicant_add_network() {
developer74503112023-06-29 17:34:49 +0800926 ;;
927 esac
928
developerbb29b5e2023-07-25 20:41:04 +0800929- [ "$wpa_cipher" = GCMP ] && {
930- append network_data "pairwise=GCMP" "$N$T"
931- append network_data "group=GCMP" "$N$T"
932- }
developer74503112023-06-29 17:34:49 +0800933+ json_get_values pairwise pairwise
developer9097e5e2023-07-19 10:22:24 +0800934+ if [ -n "$pairwise" ]; then
935+ case "$pairwise" in
936+ *tkip+aes|*tkip+ccmp|*aes+tkip|*ccmp+tkip)
937+ wpa_cipher="CCMP TKIP"
938+ ;;
939+ *ccmp256)
940+ wpa_cipher="CCMP-256"
941+ ;;
942+ *aes|*ccmp)
943+ wpa_cipher="CCMP"
944+ ;;
945+ *tkip)
946+ wpa_cipher="TKIP"
947+ ;;
948+ *gcmp256)
949+ wpa_cipher="GCMP-256"
950+ ;;
951+ *gcmp)
952+ wpa_cipher="GCMP"
953+ ;;
954+ *)
955+ wpa_cipher=""
956+ ;;
957+ esac
958+ fi
developer74503112023-06-29 17:34:49 +0800959+ [ -n "$wpa_cipher" ] && wpa_pairwise="$wpa_cipher"
developer74503112023-06-29 17:34:49 +0800960
961 [ "$mode" = mesh ] || {
962+ json_get_values sae_groups sae_groups
963+ json_get_values owe_groups owe_groups
964+
965 case "$wpa" in
966 1)
967 append network_data "proto=WPA" "$N$T"
developer37215362023-09-15 14:16:34 +0800968@@ -1548,12 +1678,48 @@ wpa_supplicant_add_network() {
developer74503112023-06-29 17:34:49 +0800969 ;;
970 esac
971
972+ [ -n "$wpa_pairwise" ] && append network_data "pairwise=$wpa_pairwise" "$N$T"
973+ [ -z "$group_cipher" ] && group_cipher="$wpa_cipher"
974+
975+ if [ -n "$sae_groups" -o -n "$owe_groups" ]; then
976+ case "$auth_type" in
977+ sae*)
978+ echo "sae_groups=$sae_groups" >> "$_config"
979+ append network_data "group=$group_cipher" "$N$T"
980+ ;;
981+ owe)
982+ append network_data "owe_group=$owe_groups" "$N$T"
983+ append network_data "group=$group_cipher" "$N$T"
984+ ;;
985+ esac
986+ fi
987+
988+ # RSN -> allow management frame protection
989 case "$ieee80211w" in
990 [012])
991- [ "$wpa" -ge 2 ] && append network_data "ieee80211w=$ieee80211w" "$N$T"
992+ json_get_vars ieee80211w_mgmt_cipher ieee80211w_max_timeout ieee80211w_retry_timeout beacon_prot
993+ append network_data "ieee80211w=$ieee80211w" "$N$T"
994+ [ "$ieee80211w" -gt "0" ] && {
995+ case "$group_cipher" in
996+ CCMP*)
997+ ieee80211w_mgmt_cipher="AES-128-CMAC"
998+ ;;
999+ GCMP-256)
1000+ [[ "$encryption" != "*owe*" ]] && ieee80211w_mgmt_cipher="BIP-GMAC-256"
1001+ ;;
1002+ esac
1003+ if [ "$auth_type" = "eap192" ]; then
1004+ append network_data "group_mgmt=BIP-GMAC-256" "$N$T"
1005+ else
1006+ append network_data "group_mgmt=${ieee80211w_mgmt_cipher:-AES-128-CMAC}" "$N$T"
1007+ fi
1008+ [ -n "$beacon_prot" ] && \
1009+ append network_data "beacon_prot=$beacon_prot" "$N$T"
1010+ }
1011 ;;
1012 esac
1013 }
1014+
1015 [ -n "$bssid" ] && append network_data "bssid=$bssid" "$N$T"
1016 [ -n "$beacon_int" ] && append network_data "beacon_int=$beacon_int" "$N$T"
1017
developer37215362023-09-15 14:16:34 +08001018@@ -1564,6 +1730,20 @@ wpa_supplicant_add_network() {
developer82408892023-03-27 15:09:00 +08001019 [ -n "$bssid_blacklist" ] && append network_data "bssid_blacklist=$bssid_blacklist" "$N$T"
1020 [ -n "$bssid_whitelist" ] && append network_data "bssid_whitelist=$bssid_whitelist" "$N$T"
1021
1022+ local disable_eht
1023+ local disable_he
1024+ local disable_vht
1025+ local disable_ht
1026+ json_get_vars disable_eht
1027+ json_get_vars disable_he
1028+ json_get_vars disable_vht
1029+ json_get_vars disable_ht
1030+
1031+ [ -n "$disable_eht" ] && append network_data "disable_eht=$disable_eht" "$N$T"
1032+ [ -n "$disable_he" ] && append network_data "disable_he=$disable_he" "$N$T"
1033+ [ -n "$disable_vht" ] && append network_data "disable_vht=$disable_vht" "$N$T"
1034+ [ -n "$disable_ht" ] && append network_data "disable_ht=$disable_ht" "$N$T"
1035+
1036 [ -n "$basic_rate" ] && {
1037 local br rate_list=
1038 for br in $basic_rate; do
developer37215362023-09-15 14:16:34 +08001039@@ -1578,6 +1758,11 @@ wpa_supplicant_add_network() {
developer85839fe2023-02-23 10:32:51 +08001040 append network_data "mcast_rate=$mc_rate" "$N$T"
1041 }
1042
1043+ if [ "$auth_type" = "sae" ]; then
1044+ json_get_vars sae_pwe sae_pwe
1045+ [ -n "$sae_pwe" ] && echo "sae_pwe=$sae_pwe" >> "$_config"
1046+ fi
1047+
1048 if [ "$key_mgmt" = "WPS" ]; then
1049 echo "wps_cred_processing=1" >> "$_config"
1050 else