blob: 13bfc9d7fd71afb50f97d4df0844db8892aebd1e [file] [log] [blame]
developerce9e5092022-11-10 22:41:59 +08001diff --git a/package/kernel/mac80211/Makefile b/package/kernel/mac80211/Makefile
developer5ad89862023-08-24 08:17:27 +08002index 8ecbe30..44af0c7 100644
developerce9e5092022-11-10 22:41:59 +08003--- a/package/kernel/mac80211/Makefile
4+++ b/package/kernel/mac80211/Makefile
developer5ad89862023-08-24 08:17:27 +08005@@ -19,6 +19,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 = \
developer5ad89862023-08-24 08:17:27 +080013@@ -71,6 +72,11 @@ 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 \
developer5ad89862023-08-24 08:17:27 +080021+ MAC80211_PS_DEBUG \
developer6ec8e342022-11-21 18:47:15 +080022
23 config-$(call config_package,cfg80211) += CFG80211
24 config-$(CONFIG_PACKAGE_CFG80211_TESTMODE) += NL80211_TESTMODE
developer5ad89862023-08-24 08:17:27 +080025@@ -296,6 +302,8 @@ define Build/Prepare
developer356ecec2022-11-14 10:25:04 +080026 mkdir -p $(PKG_BUILD_DIR)
27 $(PKG_UNPACK)
28 $(Build/Patch)
29+ $(CP) $(SOURCE_PATH)/net $(PKG_BUILD_DIR) 2>/dev/null || :
30+ $(CP) $(SOURCE_PATH)/include $(PKG_BUILD_DIR) 2>/dev/null || :
31 rm -rf \
32 $(PKG_BUILD_DIR)/include/linux/ssb \
33 $(PKG_BUILD_DIR)/include/linux/bcma \
developer20d67712022-03-02 14:09:32 +080034diff --git a/package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh b/package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh
developer61604c82023-09-04 14:43:31 +080035index ed28052..e450e86 100644
developer20d67712022-03-02 14:09:32 +080036--- a/package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh
37+++ b/package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh
developer0ba09b62023-03-10 18:43:49 +080038@@ -27,6 +27,7 @@ drv_mac80211_init_device_config() {
39
40 config_add_string path phy 'macaddr:macaddr'
41 config_add_string tx_burst
developer61604c82023-09-04 14:43:31 +080042+ config_add_int mbssid mu_onoff sr_enable sr_enhanced rnr obss_interval
developer0ba09b62023-03-10 18:43:49 +080043 config_add_string distance
44 config_add_int beacon_int chanbw frag rts
45 config_add_int rxantenna txantenna antenna_gain txpower min_tx_power
developer785b6502023-04-19 18:31:11 +080046@@ -53,7 +54,10 @@ drv_mac80211_init_device_config() {
47 he_spr_sr_control \
48 he_spr_psr_enabled \
49 he_bss_color_enabled \
50- he_twt_required
51+ he_twt_required \
52+ he_twt_responder \
53+ etxbfen \
54+ itxbfen
55 config_add_int \
56 beamformer_antennas \
57 beamformee_antennas \
58@@ -140,13 +144,11 @@ mac80211_hostapd_setup_base() {
developer0ba09b62023-03-10 18:43:49 +080059 [ -n "$acs_exclude_dfs" ] && [ "$acs_exclude_dfs" -gt 0 ] &&
60 append base_cfg "acs_exclude_dfs=1" "$N"
61
62- json_get_vars noscan ht_coex min_tx_power:0 tx_burst
developer61604c82023-09-04 14:43:31 +080063+ json_get_vars noscan ht_coex min_tx_power:0 tx_burst mbssid mu_onoff rnr obss_interval
developer2c4f7e82023-05-11 19:56:55 +080064+ json_get_vars etxbfen:1 itxbfen:0
developer8d77be32022-10-20 15:08:25 +080065 json_get_values ht_capab_list ht_capab
developer20d67712022-03-02 14:09:32 +080066 json_get_values channel_list channels
67
68- [ "$auto_channel" = 0 ] && [ -z "$channel_list" ] && \
69- channel_list="$channel"
70-
developer9b3248d2022-07-06 00:44:05 +080071 [ "$min_tx_power" -gt 0 ] && append base_cfg "min_tx_power=$min_tx_power"
developer20d67712022-03-02 14:09:32 +080072
developer9b3248d2022-07-06 00:44:05 +080073 set_default noscan 0
developer785b6502023-04-19 18:31:11 +080074@@ -160,8 +162,8 @@ mac80211_hostapd_setup_base() {
75 ieee80211n=1
76 ht_capab=
77 case "$htmode" in
78- VHT20|HT20|HE20) ;;
79- HT40*|VHT40|VHT80|VHT160|HE40|HE80|HE160)
80+ VHT20|HT20|HE20|EHT20) ;;
developerbe3cf972023-04-27 09:58:26 +080081+ HT40*|VHT40|VHT80|VHT160|HE40*|HE80|HE160|EHT40*|EHT80|EHT160|EHT320*)
developer785b6502023-04-19 18:31:11 +080082 case "$hwmode" in
83 a)
84 case "$(( (($channel / 4) + $chan_ofs) % 2 ))" in
developerbe3cf972023-04-27 09:58:26 +080085@@ -171,8 +173,22 @@ mac80211_hostapd_setup_base() {
86 ;;
87 *)
88 case "$htmode" in
89- HT40+) ht_capab="[HT40+]";;
90- HT40-) ht_capab="[HT40-]";;
91+ HT40+|HE40+|EHT40+)
92+ if [ "$channel" -gt 9 ]; then
93+ echo "Could not set the center freq with this HT mode setting"
94+ return 1
95+ else
96+ ht_capab="[HT40+]"
97+ fi
98+ ;;
99+ HT40-|HE40-|EHT40-)
100+ if [ "$channel" -lt 5 ]; then
101+ echo "Could not set the center freq with this HT mode setting"
102+ return 1
103+ else
104+ ht_capab="[HT40-]"
105+ fi
106+ ;;
107 *)
108 if [ "$channel" -lt 7 ]; then
109 ht_capab="[HT40+]"
developer61604c82023-09-04 14:43:31 +0800110@@ -193,6 +209,10 @@ mac80211_hostapd_setup_base() {
111
112 set_default ht_coex 0
113 append base_cfg "ht_coex=$ht_coex" "$N"
114+ [ "$ht_coex" -eq 1 ] && {
115+ set_default obss_interval 300
116+ append base_cfg "obss_interval=$obss_interval" "$N"
117+ }
118
119 json_get_vars \
120 ldpc:1 \
121@@ -205,7 +225,7 @@ mac80211_hostapd_setup_base() {
developer785b6502023-04-19 18:31:11 +0800122 dsss_cck_40:1
123
124 ht_cap_mask=0
125- for cap in $(iw phy "$phy" info | grep 'Capabilities:' | cut -d: -f2); do
126+ for cap in $(iw phy "$phy" info | grep 'Capabilities: 0x' | cut -d: -f2); do
127 ht_cap_mask="$(($ht_cap_mask | $cap))"
128 done
129
developer61604c82023-09-04 14:43:31 +0800130@@ -236,8 +256,8 @@ mac80211_hostapd_setup_base() {
developer785b6502023-04-19 18:31:11 +0800131
132 idx="$channel"
133 case "$htmode" in
134- VHT20|HE20) enable_ac=1;;
135- VHT40|HE40)
136+ VHT20|HE20|EHT20) enable_ac=1;;
137+ VHT40|HE40|EHT40)
138 case "$(( (($channel / 4) + $chan_ofs) % 2 ))" in
139 1) idx=$(($channel + 2));;
140 0) idx=$(($channel - 2));;
developer61604c82023-09-04 14:43:31 +0800141@@ -245,7 +265,7 @@ mac80211_hostapd_setup_base() {
developer785b6502023-04-19 18:31:11 +0800142 enable_ac=1
143 vht_center_seg0=$idx
144 ;;
145- VHT80|HE80)
146+ VHT80|HE80|EHT80)
147 case "$(( (($channel / 4) + $chan_ofs) % 4 ))" in
148 1) idx=$(($channel + 6));;
149 2) idx=$(($channel + 2));;
developer61604c82023-09-04 14:43:31 +0800150@@ -256,7 +276,7 @@ mac80211_hostapd_setup_base() {
developer785b6502023-04-19 18:31:11 +0800151 vht_oper_chwidth=1
152 vht_center_seg0=$idx
153 ;;
154- VHT160|HE160)
155+ VHT160|HE160|EHT160)
156 if [ "$band" = "6g" ]; then
157 case "$channel" in
158 1|5|9|13|17|21|25|29) idx=15;;
developer61604c82023-09-04 14:43:31 +0800159@@ -271,12 +291,43 @@ mac80211_hostapd_setup_base() {
developeradd8de62023-05-02 16:25:52 +0800160 case "$channel" in
161 36|40|44|48|52|56|60|64) idx=50;;
162 100|104|108|112|116|120|124|128) idx=114;;
163+ 149|153|157|161|165|169|173|177) idx=163;;
164 esac
165 fi
166 enable_ac=1
developer785b6502023-04-19 18:31:11 +0800167 vht_oper_chwidth=2
168 vht_center_seg0=$idx
169 ;;
170+ EHT320*)
171+ case "$channel" in
172+ 1|5|9|13|17|21|25|29) idx=31;;
173+ 33|37|41|45|49|53|57|61| \
174+ 65|69|73|77|81|85|89|93) idx=63;;
175+ 97|101|105|109|113|117|121|125| \
176+ 129|133|137|141|145|149|153|157) idx=127;;
177+ 161|165|169|173|177|181|185|189| \
178+ 193|197|201|205|209|213|217|221) idx=191;;
179+ esac
180+ if [[ "$htmode" = "EHT320-1" && "$channel" -ge "193" ]] ||
181+ [[ "$htmode" = "EHT320-2" && "$channel" -le "29" ]]; then
182+ echo "Could not set the center freq with this EHT setting"
183+ return 1
184+ elif [[ "$htmode" = "EHT320-1" && "$channel" -ge "33" ]]; then
185+ if [ "$channel" -gt $idx ]; then
186+ idx=$(($idx + 32))
187+ else
188+ idx=$(($idx - 32))
189+ fi
190+ fi
191+ vht_oper_chwidth=2
192+ if [ "$channel" -gt $idx ]; then
193+ vht_center_seg0=$(($idx + 16))
194+ else
195+ vht_center_seg0=$(($idx - 16))
196+ fi
197+ eht_oper_chwidth=9
198+ eht_oper_centr_freq_seg0_idx=$idx
199+ ;;
200 esac
201 [ "$band" = "5g" ] && {
202 json_get_vars background_radar:0
developer61604c82023-09-04 14:43:31 +0800203@@ -286,8 +337,9 @@ mac80211_hostapd_setup_base() {
developer785b6502023-04-19 18:31:11 +0800204 [ "$band" = "6g" ] && {
205 op_class=
206 case "$htmode" in
207- HE20) op_class=131;;
208- HE*) op_class=$((132 + $vht_oper_chwidth))
209+ HE20|EHT20) op_class=131;;
210+ EHT320*) op_class=137;;
211+ HE*|EHT*) op_class=$((132 + $vht_oper_chwidth))
212 esac
213 [ -n "$op_class" ] && append base_cfg "op_class=$op_class" "$N"
214 }
developer61604c82023-09-04 14:43:31 +0800215@@ -315,7 +367,6 @@ mac80211_hostapd_setup_base() {
developer8b04dfd2022-12-07 16:29:19 +0800216 vht_link_adapt:3 \
217 vht160:2
218
219- set_default tx_burst 2.0
220 append base_cfg "ieee80211ac=1" "$N"
221 vht_cap=0
222 for cap in $(iw phy "$phy" info | awk -F "[()]" '/VHT Capabilities/ { print $2 }'); do
developer61604c82023-09-04 14:43:31 +0800223@@ -329,6 +380,12 @@ mac80211_hostapd_setup_base() {
developer785b6502023-04-19 18:31:11 +0800224 [ "$rx_stbc" -lt "$cap_rx_stbc" ] && cap_rx_stbc="$rx_stbc"
225 vht_cap="$(( ($vht_cap & ~(0x700)) | ($cap_rx_stbc << 8) ))"
226
227+ [ "$etxbfen" -eq 0 ] && {
228+ su_beamformer=0
229+ su_beamformee=0
230+ mu_beamformer=0
231+ }
232+
233 mac80211_add_capabilities vht_capab $vht_cap \
234 RXLDPC:0x10::$rxldpc \
235 SHORT-GI-80:0x20::$short_gi_80 \
developer61604c82023-09-04 14:43:31 +0800236@@ -410,7 +467,7 @@ mac80211_hostapd_setup_base() {
developer785b6502023-04-19 18:31:11 +0800237 # 802.11ax
238 enable_ax=0
239 case "$htmode" in
240- HE*) enable_ax=1 ;;
241+ HE*|EHT*) enable_ax=1 ;;
242 esac
243
244 if [ "$enable_ax" != "0" ]; then
developer61604c82023-09-04 14:43:31 +0800245@@ -419,10 +476,11 @@ mac80211_hostapd_setup_base() {
developer785b6502023-04-19 18:31:11 +0800246 he_su_beamformee:1 \
247 he_mu_beamformer:1 \
248 he_twt_required:0 \
249+ he_twt_responder \
250 he_spr_sr_control:3 \
251 he_spr_psr_enabled:0 \
252 he_spr_non_srg_obss_pd_max_offset:0 \
253- he_bss_color:128 \
254+ he_bss_color \
255 he_bss_color_enabled:1
256
257 he_phy_cap=$(iw phy "$phy" info | sed -n '/HE Iftypes: AP/,$p' | awk -F "[()]" '/HE PHY Capabilities/ { print $2 }' | head -1)
developer61604c82023-09-04 14:43:31 +0800258@@ -436,6 +494,11 @@ mac80211_hostapd_setup_base() {
developer785b6502023-04-19 18:31:11 +0800259 append base_cfg "he_oper_centr_freq_seg0_idx=$vht_center_seg0" "$N"
260 }
261
262+ [ "$etxbfen" -eq 0 ] && {
263+ he_su_beamformer=0
264+ he_mu_beamformer=0
265+ }
266+
267 mac80211_add_he_capabilities \
268 he_su_beamformer:${he_phy_cap:6:2}:0x80:$he_su_beamformer \
269 he_su_beamformee:${he_phy_cap:8:2}:0x1:$he_su_beamformee \
developer61604c82023-09-04 14:43:31 +0800270@@ -443,7 +506,14 @@ mac80211_hostapd_setup_base() {
developer785b6502023-04-19 18:31:11 +0800271 he_spr_psr_enabled:${he_phy_cap:14:2}:0x1:$he_spr_psr_enabled \
272 he_twt_required:${he_mac_cap:0:2}:0x6:$he_twt_required
273
274+ if [ -n "$he_twt_responder" ]; then
275+ append base_cfg "he_twt_responder=$he_twt_responder" "$N"
276+ fi
277 if [ "$he_bss_color_enabled" -gt 0 ]; then
developer830efa72023-05-18 19:32:48 +0800278+ if !([ "$he_bss_color" -gt 0 ] && [ "$he_bss_color" -le 64 ]); then
developer785b6502023-04-19 18:31:11 +0800279+ rand=$(head -n 1 /dev/urandom | tr -dc 0-9 | head -c 2)
280+ he_bss_color=$((rand % 63 + 1))
281+ fi
282 append base_cfg "he_bss_color=$he_bss_color" "$N"
283 [ "$he_spr_non_srg_obss_pd_max_offset" -gt 0 ] && { \
284 append base_cfg "he_spr_non_srg_obss_pd_max_offset=$he_spr_non_srg_obss_pd_max_offset" "$N"
developer61604c82023-09-04 14:43:31 +0800285@@ -484,12 +554,47 @@ mac80211_hostapd_setup_base() {
developer8b04dfd2022-12-07 16:29:19 +0800286 append base_cfg "he_mu_edca_ac_vo_timer=255" "$N"
287 fi
288
developer18015ad2023-07-13 13:18:19 +0800289+ set_default tx_burst 2
developer8b04dfd2022-12-07 16:29:19 +0800290+
developer785b6502023-04-19 18:31:11 +0800291+ # 802.11be
292+ enable_be=0
293+ case "$htmode" in
294+ EHT*) enable_be=1 ;;
295+ esac
296+
297+ if [ "$enable_be" != "0" ]; then
298+ append base_cfg "ieee80211be=1" "$N"
299+ if [ "$etxbfen" -eq 0 ]; then
300+ append base_cfg "eht_su_beamformee=1" "$N"
301+ else
302+ append base_cfg "eht_su_beamformer=1" "$N"
303+ append base_cfg "eht_su_beamformee=1" "$N"
304+ append base_cfg "eht_mu_beamformer=1" "$N"
305+ fi
306+ [ "$hwmode" = "a" ] && {
307+ case $htmode in
308+ EHT320*)
309+ append base_cfg "eht_oper_chwidth=$eht_oper_chwidth" "$N"
310+ append base_cfg "eht_oper_centr_freq_seg0_idx=$eht_oper_centr_freq_seg0_idx" "$N"
311+ ;;
312+ *)
313+ append base_cfg "eht_oper_chwidth=$vht_oper_chwidth" "$N"
314+ append base_cfg "eht_oper_centr_freq_seg0_idx=$vht_center_seg0" "$N"
315+ ;;
316+ esac
317+ }
318+ fi
319+
developer8b04dfd2022-12-07 16:29:19 +0800320 hostapd_prepare_device_config "$hostapd_conf_file" nl80211
321 cat >> "$hostapd_conf_file" <<EOF
322 ${channel:+channel=$channel}
developer0ba09b62023-03-10 18:43:49 +0800323 ${channel_list:+chanlist=$channel_list}
324 ${hostapd_noscan:+noscan=1}
325 ${tx_burst:+tx_queue_data2_burst=$tx_burst}
326+${mbssid:+mbssid=$mbssid}
developer785b6502023-04-19 18:31:11 +0800327+${mu_onoff:+mu_onoff=$mu_onoff}
328+${itxbfen:+ibf_enable=$itxbfen}
developer2c6592a2023-07-21 11:20:56 +0800329+${rnr:+rnr=$rnr}
developer0ba09b62023-03-10 18:43:49 +0800330 $base_cfg
331
332 EOF
developer61604c82023-09-04 14:43:31 +0800333@@ -517,7 +622,7 @@ mac80211_hostapd_setup_bss() {
developer093e1a32023-02-24 16:10:53 +0800334 append hostapd_cfg "wds_sta=1" "$N"
335 [ -n "$wds_bridge" ] && append hostapd_cfg "wds_bridge=$wds_bridge" "$N"
336 }
337- [ "$staidx" -gt 0 -o "$start_disabled" -eq 1 ] && append hostapd_cfg "start_disabled=1" "$N"
338+ [ "$start_disabled" -eq 1 ] && append hostapd_cfg "start_disabled=1" "$N"
339
340 cat >> /var/run/hostapd-$phy.conf <<EOF
341 $hostapd_cfg
developer61604c82023-09-04 14:43:31 +0800342@@ -527,6 +632,31 @@ ${max_listen_int:+max_listen_interval=$max_listen_int}
developer0ba09b62023-03-10 18:43:49 +0800343 EOF
344 }
345
346+mac80211_generate_mbssid_mac() {
347+ local phy="$1"
348+ local transmitted_bssid="$2"
developer1952bcd2023-06-20 20:14:37 +0800349+ local id="${mbssidx:-0}"
developer0ba09b62023-03-10 18:43:49 +0800350+
351+ local ref="$(cat /sys/class/ieee80211/${phy}/macaddress)"
developer0ba09b62023-03-10 18:43:49 +0800352+
353+ if [ -z "$transmitted_bssid" ]; then
354+ transmitted_bssid=$ref
355+ fi
356+
357+ if [ $id -eq 0 ]; then
358+ echo "$transmitted_bssid"
359+ return
360+ fi
361+
362+ local oIFS="$IFS"; IFS=":"; set -- $transmitted_bssid; IFS="$oIFS"
363+
364+ # Calculate nontransmitted bssid
developer0ba09b62023-03-10 18:43:49 +0800365+ b6="0x$6"
366+ ref_b6=$(($b6 % $max_mbssid))
developer1952bcd2023-06-20 20:14:37 +0800367+ b6=$(($b6 - $ref_b6 + ($ref_b6 + $id) % $max_mbssid))
developer0ba09b62023-03-10 18:43:49 +0800368+ printf "%s:%s:%s:%s:%s:%02x" $1 $2 $3 $4 $5 $b6
369+}
370+
371 mac80211_get_addr() {
372 local phy="$1"
373 local idx="$(($2 + 1))"
developer61604c82023-09-04 14:43:31 +0800374@@ -757,7 +887,19 @@ mac80211_prepare_vif() {
developer0ba09b62023-03-10 18:43:49 +0800375
376 json_select ..
377
378- if [ -z "$macaddr" ]; then
developerd2fbd572023-06-19 19:48:25 +0800379+ if [ "$mbssid" -gt 0 ] && [ "$mode" == "ap" ]; then
developer1952bcd2023-06-20 20:14:37 +0800380+ [ "$mbssidx" -eq 0 ] && {
381+ if [ -z $macaddr ]; then
382+ transmitted_bssid="$(mac80211_generate_mac $phy)"
383+ else
384+ # uci set mac address
385+ transmitted_bssid=$macaddr
386+ fi
387+ macidx="$(($macidx + 1))"
developer0ba09b62023-03-10 18:43:49 +0800388+ }
389+ macaddr="$(mac80211_generate_mbssid_mac $phy $transmitted_bssid)"
developer1952bcd2023-06-20 20:14:37 +0800390+ mbssidx="$(($mbssidx + 1))"
developer0ba09b62023-03-10 18:43:49 +0800391+ elif [ -z "$macaddr" ]; then
392 macaddr="$(mac80211_generate_mac $phy)"
393 macidx="$(($macidx + 1))"
394 elif [ "$macaddr" = 'random' ]; then
developer61604c82023-09-04 14:43:31 +0800395@@ -1058,6 +1200,9 @@ mac80211_setup_vif() {
developerf0de14b2022-12-14 23:07:34 +0800396
397 json_select ..
398 [ -n "$failed" ] || wireless_add_vif "$name" "$ifname"
399+
400+ echo "Setup SMP Affinity"
401+ /sbin/smp-mt76.sh
402 }
403
404 get_freq() {
developer61604c82023-09-04 14:43:31 +0800405@@ -1122,6 +1267,10 @@ drv_mac80211_cleanup() {
developer0ba09b62023-03-10 18:43:49 +0800406 hostapd_common_cleanup
407 }
408
409+mac80211_count_ap() {
410+ total_num_ap=$(($total_num_ap + 1))
411+}
412+
413 drv_mac80211_setup() {
414 json_select config
415 json_get_vars \
developer61604c82023-09-04 14:43:31 +0800416@@ -1129,7 +1278,8 @@ drv_mac80211_setup() {
developer74503112023-06-29 17:34:49 +0800417 country chanbw distance \
418 txpower antenna_gain \
419 rxantenna txantenna \
420- frag rts beacon_int:100 htmode
421+ frag rts beacon_int:100 htmode \
422+ sr_enable sr_enhanced
423 json_get_values basic_rate_list basic_rate
424 json_get_values scan_list scan_list
425 json_select ..
developer61604c82023-09-04 14:43:31 +0800426@@ -1180,6 +1330,7 @@ drv_mac80211_setup() {
developer1952bcd2023-06-20 20:14:37 +0800427 no_ap=1
428 macidx=0
429 staidx=0
430+ mbssidx=0
431
432 [ -n "$chanbw" ] && {
433 for file in /sys/kernel/debug/ieee80211/$phy/ath9k*/chanbw /sys/kernel/debug/ieee80211/$phy/ath5k/bwmode; do
developer61604c82023-09-04 14:43:31 +0800434@@ -1219,6 +1370,16 @@ drv_mac80211_setup() {
developer0ba09b62023-03-10 18:43:49 +0800435 for_each_interface "sta adhoc mesh" mac80211_set_noscan
436 [ -n "$has_ap" ] && mac80211_hostapd_setup_base "$phy"
437
438+ total_num_ap=0
439+ max_mbssid=1
440+ for_each_interface "ap" mac80211_count_ap
441+ total_num_ap=$(($total_num_ap - 1))
442+ while [ $total_num_ap -gt 0 ]
443+ do
444+ total_num_ap=$(($total_num_ap >> 1))
445+ max_mbssid=$(($max_mbssid << 1))
446+ done
447+
448 mac80211_prepare_iw_htmode
449 for_each_interface "sta adhoc mesh monitor" mac80211_prepare_vif
450 NEWAPLIST=
developer61604c82023-09-04 14:43:31 +0800451@@ -1251,6 +1412,14 @@ drv_mac80211_setup() {
developerad1f3172023-05-02 11:10:08 +0800452 if [ "$no_reload" != "0" ]; then
453 add_ap=1
454 ubus wait_for hostapd
455+
456+ # each phy sleeps different times to prevent for ubus race condition.
457+ if [ "$phy" = "phy1" ]; then
458+ sleep 1;
459+ elif [ "$phy" = "phy2" ]; then
460+ sleep 2;
461+ fi
462+
463 local hostapd_res="$(ubus call hostapd config_add "{\"iface\":\"$primary_ap\", \"config\":\"${hostapd_conf_file}\"}")"
464 ret="$?"
465 [ "$ret" != 0 -o -z "$hostapd_res" ] && {
developer61604c82023-09-04 14:43:31 +0800466@@ -1266,6 +1435,9 @@ drv_mac80211_setup() {
developer74503112023-06-29 17:34:49 +0800467 [ "${add_ap}" = 1 ] && sleep 1
468 for_each_interface "ap" mac80211_setup_vif
469
470+ [ -n "$sr_enable" ] && echo "$sr_enable" > /sys/kernel/debug/ieee80211/$phy/mt76/sr_enable
471+ [ -n "$sr_enhanced" ] && echo "$sr_enhanced" > /sys/kernel/debug/ieee80211/$phy/mt76/sr_enhanced_enable
472+
473 NEWSPLIST=
474 NEWUMLIST=
475
developer9b3248d2022-07-06 00:44:05 +0800476diff --git a/package/kernel/mac80211/files/lib/wifi/mac80211.sh b/package/kernel/mac80211/files/lib/wifi/mac80211.sh
developer5ad89862023-08-24 08:17:27 +0800477index 3ecd932..69ecbbf 100644
developere2597ba2022-06-24 13:09:16 +0800478--- a/package/kernel/mac80211/files/lib/wifi/mac80211.sh
479+++ b/package/kernel/mac80211/files/lib/wifi/mac80211.sh
developer20ce7bd2023-05-20 13:25:14 +0800480@@ -60,6 +60,9 @@ BEGIN {
developer785b6502023-04-19 18:31:11 +0800481 if (vht && band != "1:") mode="VHT80"
482 if (he) mode="HE80"
483 if (he && band == "1:") mode="HE20"
developer20ce7bd2023-05-20 13:25:14 +0800484+ if (eht && band == "2:") mode="EHT160"
485+ if (eht && band == "4:") mode="EHT320"
developer785b6502023-04-19 18:31:11 +0800486+ if (eht && band == "1:") mode="EHT20"
487 sub("\\[", "", channel)
488 sub("\\]", "", channel)
489 bands = bands band channel ":" mode " "
developer20ce7bd2023-05-20 13:25:14 +0800490@@ -73,6 +76,7 @@ $1 == "Band" {
developer785b6502023-04-19 18:31:11 +0800491 vht = ""
492 ht = ""
493 he = ""
494+ eht = ""
495 }
496
497 $0 ~ "Capabilities:" {
developer20ce7bd2023-05-20 13:25:14 +0800498@@ -87,6 +91,18 @@ $0 ~ "HE Iftypes" {
developer785b6502023-04-19 18:31:11 +0800499 he=1
500 }
501
502+$0 ~ "EHT Iftypes" {
503+ eht=1
504+}
505+
developer20ce7bd2023-05-20 13:25:14 +0800506+$0 ~ / *HE MAC Capabilities \(0x000000000000\)/ {
507+ he=0
508+}
509+
510+$0 ~ / *EHT MAC Capabilities \(0x0000\)/ {
511+ eht=0
512+}
513+
developer785b6502023-04-19 18:31:11 +0800514 $1 == "*" && $3 == "MHz" && $0 !~ /disabled/ && band && !channel {
515 channel = $4
516 }
developer2c6592a2023-07-21 11:20:56 +0800517@@ -120,6 +136,19 @@ get_band_defaults() {
developere2597ba2022-06-24 13:09:16 +0800518 mode_band="$band"
519 channel="$chan"
520 htmode="$mode"
521+ if [ "$band" = "6g" ]
522+ then
523+ encryption=sae
524+ key=12345678
developer20ce7bd2023-05-20 13:25:14 +0800525+ sae_pwe=2
526+ ieee80211w=2
developeradbb45b2023-06-09 14:43:01 +0800527+ channel=37
528+ mbssid=1
developere2597ba2022-06-24 13:09:16 +0800529+ else
developer659b07e2023-05-25 12:34:13 +0800530+ noscan=1
developere2597ba2022-06-24 13:09:16 +0800531+ encryption=none
developer2c6592a2023-07-21 11:20:56 +0800532+ rnr=1
developere2597ba2022-06-24 13:09:16 +0800533+ fi
534 done
535 }
536
developer2c6592a2023-07-21 11:20:56 +0800537@@ -153,6 +182,10 @@ detect_mac80211() {
developer785b6502023-04-19 18:31:11 +0800538
539 json_load_file /etc/board.json
540
541+ # generate random bytes for macaddr
542+ rand=$(hexdump -C /dev/urandom | head -n 1 &)
543+ killall hexdump
544+
545 for _dev in /sys/class/ieee80211/*; do
546 [ -e "$_dev" ] || continue
547
developer2c6592a2023-07-21 11:20:56 +0800548@@ -162,6 +195,13 @@ detect_mac80211() {
developere2597ba2022-06-24 13:09:16 +0800549 channel=""
550 htmode=""
551 ht_capab=""
552+ encryption=""
developer659b07e2023-05-25 12:34:13 +0800553+ noscan=""
developere2597ba2022-06-24 13:09:16 +0800554+ key=""
developer09257932023-05-09 13:41:30 +0800555+ sae_pwe=""
developer20ce7bd2023-05-20 13:25:14 +0800556+ ieee80211w=""
developeradbb45b2023-06-09 14:43:01 +0800557+ mbssid=""
developer2c6592a2023-07-21 11:20:56 +0800558+ rnr=""
developere2597ba2022-06-24 13:09:16 +0800559
560 get_band_defaults "$dev"
561
developer5ad89862023-08-24 08:17:27 +0800562@@ -192,6 +232,14 @@ detect_mac80211() {
developer785b6502023-04-19 18:31:11 +0800563 ;;
564 esac
565
developer212c0d82023-07-13 19:41:47 +0800566+ macaddr=""
developer1325ba72023-06-26 13:43:31 +0800567+ if (dmesg | grep -q "eeprom load fail"); then
developer1952bcd2023-06-20 20:14:37 +0800568+ for i in $(seq 2 3); do
569+ macaddr=${macaddr}:$(echo $rand | cut -d ' ' -f $i)
570+ done
571+ macaddr="00:0$(($devidx - 1)):55:66${macaddr}"
developer1952bcd2023-06-20 20:14:37 +0800572+ fi
developer785b6502023-04-19 18:31:11 +0800573+
574 uci -q batch <<-EOF
575 set wireless.${name}=wifi-device
576 set wireless.${name}.type=mac80211
developer5ad89862023-08-24 08:17:27 +0800577@@ -199,15 +247,40 @@ detect_mac80211() {
developer09257932023-05-09 13:41:30 +0800578 set wireless.${name}.channel=${channel}
579 set wireless.${name}.band=${mode_band}
580 set wireless.${name}.htmode=$htmode
581- set wireless.${name}.disabled=1
developer20ce7bd2023-05-20 13:25:14 +0800582+ set wireless.${name}.country='US'
developer659b07e2023-05-25 12:34:13 +0800583+ set wireless.${name}.noscan=${noscan}
developer09257932023-05-09 13:41:30 +0800584+ set wireless.${name}.disabled=0
developeradbb45b2023-06-09 14:43:01 +0800585+EOF
586+ [ -n "$mbssid" ] && {
587+ uci -q set wireless.${name}.mbssid=${mbssid}
588+ }
developer2c6592a2023-07-21 11:20:56 +0800589+ [ -n "$rnr" ] && {
590+ uci -q set wireless.${name}.rnr=${rnr}
591+ }
developer09257932023-05-09 13:41:30 +0800592
developeradbb45b2023-06-09 14:43:01 +0800593+ uci -q batch <<-EOF
developer09257932023-05-09 13:41:30 +0800594 set wireless.default_${name}=wifi-iface
595 set wireless.default_${name}.device=${name}
developer8d77be32022-10-20 15:08:25 +0800596 set wireless.default_${name}.network=lan
597 set wireless.default_${name}.mode=ap
developer09257932023-05-09 13:41:30 +0800598- set wireless.default_${name}.ssid=OpenWrt
developer8d77be32022-10-20 15:08:25 +0800599- set wireless.default_${name}.encryption=none
developer09257932023-05-09 13:41:30 +0800600+ set wireless.default_${name}.ssid=OpenWrt-${mode_band}
developer8d77be32022-10-20 15:08:25 +0800601+ set wireless.default_${name}.encryption=${encryption}
developere2597ba2022-06-24 13:09:16 +0800602 EOF
developer212c0d82023-07-13 19:41:47 +0800603+
604+ # calibrated board will use eeprom macaddress, not ramdom address
605+ [ -n "$macaddr" ] && {
606+ uci -q set wireless.default_${name}.macaddr=${macaddr}
607+ }
608+
developere2597ba2022-06-24 13:09:16 +0800609+ [ -n "$key" ] && {
developer8d77be32022-10-20 15:08:25 +0800610+ uci -q set wireless.default_${name}.key=${key}
developere2597ba2022-06-24 13:09:16 +0800611+ }
developer09257932023-05-09 13:41:30 +0800612+ [ -n "$sae_pwe" ] && {
613+ uci -q set wireless.default_${name}.sae_pwe=${sae_pwe}
614+ }
developer20ce7bd2023-05-20 13:25:14 +0800615+ [ -n "$ieee80211w" ] && {
616+ uci -q set wireless.default_${name}.ieee80211w=${ieee80211w}
617+ }
developere2597ba2022-06-24 13:09:16 +0800618 uci -q commit wireless
developer8d77be32022-10-20 15:08:25 +0800619 done
620 }
developer85839fe2023-02-23 10:32:51 +0800621diff --git a/package/network/services/hostapd/files/hostapd.sh b/package/network/services/hostapd/files/hostapd.sh
developer5ad89862023-08-24 08:17:27 +0800622index 28bd210..dc315da 100644
developer85839fe2023-02-23 10:32:51 +0800623--- a/package/network/services/hostapd/files/hostapd.sh
624+++ b/package/network/services/hostapd/files/hostapd.sh
developer74503112023-06-29 17:34:49 +0800625@@ -60,7 +60,14 @@ hostapd_append_wpa_key_mgmt() {
626 [ "${ieee80211w:-0}" -gt 0 ] && append wpa_key_mgmt "WPA-EAP-SHA256"
627 ;;
628 sae)
629- append wpa_key_mgmt "SAE"
630+ case "$encryption" in
631+ *sae-ext*)
632+ append wpa_key_mgmt "SAE-EXT-KEY"
633+ ;;
634+ *)
635+ append wpa_key_mgmt "SAE"
636+ ;;
637+ esac
638 [ "${ieee80211r:-0}" -gt 0 ] && append wpa_key_mgmt "FT-SAE"
639 ;;
640 psk-sae)
641@@ -115,6 +122,7 @@ hostapd_common_add_device_config() {
642 config_add_int rts_threshold
643 config_add_int rssi_reject_assoc_rssi
644 config_add_int rssi_ignore_probe_request
645+ config_add_int rssi_reject_assoc_timeout
646 config_add_int maxassoc
647
648 config_add_string acs_chan_bias
developer5ad89862023-08-24 08:17:27 +0800649@@ -225,8 +233,10 @@ hostapd_prepare_device_config() {
developer74503112023-06-29 17:34:49 +0800650 hostapd_add_rate brlist "$br"
651 done
652
653+ json_get_vars rssi_reject_assoc_timeout
654 [ -n "$rssi_reject_assoc_rssi" ] && append base_cfg "rssi_reject_assoc_rssi=$rssi_reject_assoc_rssi" "$N"
655 [ -n "$rssi_ignore_probe_request" ] && append base_cfg "rssi_ignore_probe_request=$rssi_ignore_probe_request" "$N"
656+ [ -n "$rssi_reject_assoc_timeout" ] && append base_cfg "rssi_reject_assoc_timeout=$rssi_reject_assoc_timeout" "$N"
657 [ -n "$beacon_rate" ] && append base_cfg "beacon_rate=$beacon_rate" "$N"
658 [ -n "$rlist" ] && append base_cfg "supported_rates=$rlist" "$N"
659 [ -n "$brlist" ] && append base_cfg "basic_rates=$brlist" "$N"
developer5ad89862023-08-24 08:17:27 +0800660@@ -376,6 +386,24 @@ hostapd_common_add_bss_config() {
developer82408892023-03-27 15:09:00 +0800661 config_add_string fils_dhcp
662
663 config_add_int ocv
664+
665+ config_add_int disable_eht
666+ config_add_int disable_he
667+ config_add_int disable_vht
668+ config_add_int disable_ht
developer813f5d72023-03-28 17:44:38 +0800669+
developerf166f542023-05-25 14:40:30 +0800670+ config_add_boolean beacon_prot interworking
developer74503112023-06-29 17:34:49 +0800671+
672+ config_add_int unsol_bcast_probe_resp_interval
673+ config_add_int fils_discovery_min_interval
674+ config_add_int fils_discovery_max_interval
675+ config_add_boolean rnr
676+
677+ config_add_array sae_groups
678+ config_add_array owe_groups
679+ config_add_array pairwise
680+ config_add_string group_cipher
681+
developer82408892023-03-27 15:09:00 +0800682 }
683
684 hostapd_set_vlan_file() {
developer5ad89862023-08-24 08:17:27 +0800685@@ -440,11 +468,11 @@ append_iw_nai_realm() {
developerf166f542023-05-25 14:40:30 +0800686 }
687
688 append_iw_venue_name() {
689- append bss_conf "venue_name=$1" "$N"
690+ [ -n "$1" ] && append bss_conf "venue_name=$1" "$N"
691 }
692
693 append_iw_venue_url() {
694- append bss_conf "venue_url=$1" "$N"
695+ [ -n "$1" ] && append bss_conf "venue_url=$1" "$N"
696 }
697
698 append_hs20_oper_friendly_name() {
developer5ad89862023-08-24 08:17:27 +0800699@@ -562,7 +590,8 @@ hostapd_set_bss_options() {
developer74503112023-06-29 17:34:49 +0800700 ppsk airtime_bss_weight airtime_bss_limit airtime_sta_weight \
701 multicast_to_unicast_all proxy_arp per_sta_vif \
702 eap_server eap_user_file ca_cert server_cert private_key private_key_passwd server_id \
703- vendor_elements fils ocv
704+ vendor_elements fils ocv unsol_bcast_probe_resp_interval fils_discovery_min_interval \
705+ fils_discovery_max_interval rnr group_cipher
706
707 set_default fils 0
708 set_default isolate 0
developer5ad89862023-08-24 08:17:27 +0800709@@ -790,6 +819,35 @@ hostapd_set_bss_options() {
developer74503112023-06-29 17:34:49 +0800710 local auth_algs="$((($auth_mode_shared << 1) | $auth_mode_open))"
711 append bss_conf "auth_algs=${auth_algs:-1}" "$N"
712 append bss_conf "wpa=$wpa" "$N"
713+
714+ json_get_values pairwise pairwise
developer9097e5e2023-07-19 10:22:24 +0800715+ if [ -n "$pairwise" ]; then
716+ case "$pairwise" in
717+ *tkip+aes|*tkip+ccmp|*aes+tkip|*ccmp+tkip)
718+ wpa_cipher="CCMP TKIP"
719+ ;;
720+ *ccmp256)
721+ wpa_cipher="CCMP-256"
722+ ;;
723+ *aes|*ccmp)
724+ wpa_cipher="CCMP"
725+ ;;
726+ *tkip)
727+ wpa_cipher="TKIP"
728+ ;;
729+ *gcmp256)
730+ wpa_cipher="GCMP-256"
731+ ;;
732+ *gcmp)
733+ wpa_cipher="GCMP"
734+ ;;
735+ *)
736+ wpa_cipher=""
737+ ;;
738+ esac
739+ fi
developer74503112023-06-29 17:34:49 +0800740+ [ -n "$wpa_cipher" ] && wpa_pairwise="$wpa_cipher"
741+
742 [ -n "$wpa_pairwise" ] && append bss_conf "wpa_pairwise=$wpa_pairwise" "$N"
743
744 set_default wps_pushbutton 0
developer5ad89862023-08-24 08:17:27 +0800745@@ -841,7 +899,7 @@ hostapd_set_bss_options() {
developerda723192023-05-22 19:46:10 +0800746 }
747
748 append bss_conf "ssid=$ssid" "$N"
749- [ -n "$network_bridge" ] && append bss_conf "bridge=$network_bridge${N}wds_bridge=" "$N"
750+ [ -n "$network_bridge" ] && append bss_conf "bridge=$network_bridge${N}wds_bridge=$network_bridge" "$N"
751 [ -n "$network_ifname" ] && append bss_conf "snoop_iface=$network_ifname" "$N"
752 [ -n "$iapp_interface" ] && {
753 local ifname
developer5ad89862023-08-24 08:17:27 +0800754@@ -954,6 +1012,8 @@ hostapd_set_bss_options() {
developer74503112023-06-29 17:34:49 +0800755 fi
756
757 if [ "$wpa" -ge "2" ]; then
758+ json_get_values sae_groups sae_groups
759+ json_get_values owe_groups owe_groups
760 if [ -n "$network_bridge" -a "$rsn_preauth" = 1 ]; then
761 set_default auth_cache 1
762 append bss_conf "rsn_preauth=1" "$N"
developer5ad89862023-08-24 08:17:27 +0800763@@ -972,17 +1032,42 @@ hostapd_set_bss_options() {
developer74503112023-06-29 17:34:49 +0800764 append bss_conf "okc=$auth_cache" "$N"
765 [ "$auth_cache" = 0 -a "$fils" = 0 ] && append bss_conf "disable_pmksa_caching=1" "$N"
766
767+ [ -z "$group_cipher" ] && group_cipher="$wpa_cipher"
768+
769+ if [ -n "$sae_groups" -o -n "$owe_groups" ]; then
770+ case "$auth_type" in
771+ sae*)
772+ append bss_conf "sae_groups=$sae_groups" "$N"
773+ append bss_conf "group_cipher=$group_cipher" "$N"
774+ ;;
775+ owe)
776+ append bss_conf "owe_groups=$owe_groups" "$N"
777+ append bss_conf "group_cipher=$group_cipher" "$N"
778+ ;;
779+ esac
780+ fi
781+
developer813f5d72023-03-28 17:44:38 +0800782 # RSN -> allow management frame protection
783 case "$ieee80211w" in
784 [012])
785- json_get_vars ieee80211w_mgmt_cipher ieee80211w_max_timeout ieee80211w_retry_timeout
786+ json_get_vars ieee80211w_mgmt_cipher ieee80211w_max_timeout ieee80211w_retry_timeout beacon_prot
787 append bss_conf "ieee80211w=$ieee80211w" "$N"
788 [ "$ieee80211w" -gt "0" ] && {
developer74503112023-06-29 17:34:49 +0800789+ case "$group_cipher" in
790+ CCMP*)
791+ ieee80211w_mgmt_cipher="AES-128-CMAC"
792+ ;;
793+ GCMP-256)
794+ [[ "$encryption" != "*owe*" ]] && ieee80211w_mgmt_cipher="BIP-GMAC-256"
795+ ;;
796+ esac
developer813f5d72023-03-28 17:44:38 +0800797 if [ "$auth_type" = "eap192" ]; then
developer74503112023-06-29 17:34:49 +0800798 append bss_conf "group_mgmt_cipher=BIP-GMAC-256" "$N"
developer813f5d72023-03-28 17:44:38 +0800799 else
800 append bss_conf "group_mgmt_cipher=${ieee80211w_mgmt_cipher:-AES-128-CMAC}" "$N"
801 fi
802+ [ -n "$beacon_prot" ] && \
803+ append bss_conf "beacon_prot=$beacon_prot" "$N"
804 [ -n "$ieee80211w_max_timeout" ] && \
805 append bss_conf "assoc_sa_query_max_timeout=$ieee80211w_max_timeout" "$N"
806 [ -n "$ieee80211w_retry_timeout" ] && \
developer5ad89862023-08-24 08:17:27 +0800807@@ -1047,9 +1132,10 @@ hostapd_set_bss_options() {
developerf166f542023-05-25 14:40:30 +0800808 json_get_vars iw_roaming_consortium iw_domain_name iw_anqp_3gpp_cell_net iw_nai_realm
809 json_get_vars iw_anqp_elem iw_qos_map_set iw_ipaddr_type_availability iw_gas_address3
810 json_get_vars iw_venue_name iw_venue_url
811+ json_get_vars interworking
812
813 set_default iw_enabled 0
814- if [ "$iw_enabled" = "1" ]; then
815+ if [ "$iw_enabled" = "1" ] || [ "$interworking" = "1" ]; then
816 append bss_conf "interworking=1" "$N"
817 set_default iw_internet 1
818 set_default iw_asra 0
developer5ad89862023-08-24 08:17:27 +0800819@@ -1156,6 +1242,22 @@ hostapd_set_bss_options() {
developer74503112023-06-29 17:34:49 +0800820 append bss_conf "$val" "$N"
821 done
822
823+ if [ "$unsol_bcast_probe_resp_interval" -gt 0 ]; then
824+ append bss_conf "unsol_bcast_probe_resp_interval=$unsol_bcast_probe_resp_interval" "$N"
825+ fi
826+
827+ if [ -n "$fils_discovery_min_interval" ]; then
828+ append bss_conf "fils_discovery_min_interval=$fils_discovery_min_interval" "$N"
829+ fi
830+
831+ if [ -n "$fils_discovery_max_interval" ]; then
832+ append bss_conf "fils_discovery_max_interval=$fils_discovery_max_interval" "$N"
833+ fi
834+
835+ if [ -n "$rnr" ]; then
836+ append bss_conf "rnr=$rnr" "$N"
837+ fi
838+
839 bss_md5sum="$(echo $bss_conf | md5sum | cut -d" " -f1)"
840 append bss_conf "config_id=$bss_md5sum" "$N"
841
developer5ad89862023-08-24 08:17:27 +0800842@@ -1246,6 +1348,7 @@ wpa_supplicant_prepare_interface() {
developer18015ad2023-07-13 13:18:19 +0800843 country_str="country=$country"
844 }
845
developer2cf3f4c2023-07-24 16:58:25 +0800846+ local tx_queue_data2_burst="tx_queue_data2_burst=0"
developer18015ad2023-07-13 13:18:19 +0800847 multiap_flag_file="${_config}.is_multiap"
848 if [ "$multi_ap" = "1" ]; then
849 touch "$multiap_flag_file"
developer5ad89862023-08-24 08:17:27 +0800850@@ -1257,6 +1360,7 @@ wpa_supplicant_prepare_interface() {
developer18015ad2023-07-13 13:18:19 +0800851 ${scan_list:+freq_list=$scan_list}
852 $ap_scan
853 $country_str
854+$tx_queue_data2_burst
855 EOF
856 return 0
857 }
developer5ad89862023-08-24 08:17:27 +0800858@@ -1528,12 +1632,38 @@ wpa_supplicant_add_network() {
developer74503112023-06-29 17:34:49 +0800859 ;;
860 esac
861
developerbb29b5e2023-07-25 20:41:04 +0800862- [ "$wpa_cipher" = GCMP ] && {
863- append network_data "pairwise=GCMP" "$N$T"
864- append network_data "group=GCMP" "$N$T"
865- }
developer74503112023-06-29 17:34:49 +0800866+ json_get_values pairwise pairwise
developer9097e5e2023-07-19 10:22:24 +0800867+ if [ -n "$pairwise" ]; then
868+ case "$pairwise" in
869+ *tkip+aes|*tkip+ccmp|*aes+tkip|*ccmp+tkip)
870+ wpa_cipher="CCMP TKIP"
871+ ;;
872+ *ccmp256)
873+ wpa_cipher="CCMP-256"
874+ ;;
875+ *aes|*ccmp)
876+ wpa_cipher="CCMP"
877+ ;;
878+ *tkip)
879+ wpa_cipher="TKIP"
880+ ;;
881+ *gcmp256)
882+ wpa_cipher="GCMP-256"
883+ ;;
884+ *gcmp)
885+ wpa_cipher="GCMP"
886+ ;;
887+ *)
888+ wpa_cipher=""
889+ ;;
890+ esac
891+ fi
developer74503112023-06-29 17:34:49 +0800892+ [ -n "$wpa_cipher" ] && wpa_pairwise="$wpa_cipher"
developer74503112023-06-29 17:34:49 +0800893
894 [ "$mode" = mesh ] || {
895+ json_get_values sae_groups sae_groups
896+ json_get_values owe_groups owe_groups
897+
898 case "$wpa" in
899 1)
900 append network_data "proto=WPA" "$N$T"
developer5ad89862023-08-24 08:17:27 +0800901@@ -1543,12 +1673,48 @@ wpa_supplicant_add_network() {
developer74503112023-06-29 17:34:49 +0800902 ;;
903 esac
904
905+ [ -n "$wpa_pairwise" ] && append network_data "pairwise=$wpa_pairwise" "$N$T"
906+ [ -z "$group_cipher" ] && group_cipher="$wpa_cipher"
907+
908+ if [ -n "$sae_groups" -o -n "$owe_groups" ]; then
909+ case "$auth_type" in
910+ sae*)
911+ echo "sae_groups=$sae_groups" >> "$_config"
912+ append network_data "group=$group_cipher" "$N$T"
913+ ;;
914+ owe)
915+ append network_data "owe_group=$owe_groups" "$N$T"
916+ append network_data "group=$group_cipher" "$N$T"
917+ ;;
918+ esac
919+ fi
920+
921+ # RSN -> allow management frame protection
922 case "$ieee80211w" in
923 [012])
924- [ "$wpa" -ge 2 ] && append network_data "ieee80211w=$ieee80211w" "$N$T"
925+ json_get_vars ieee80211w_mgmt_cipher ieee80211w_max_timeout ieee80211w_retry_timeout beacon_prot
926+ append network_data "ieee80211w=$ieee80211w" "$N$T"
927+ [ "$ieee80211w" -gt "0" ] && {
928+ case "$group_cipher" in
929+ CCMP*)
930+ ieee80211w_mgmt_cipher="AES-128-CMAC"
931+ ;;
932+ GCMP-256)
933+ [[ "$encryption" != "*owe*" ]] && ieee80211w_mgmt_cipher="BIP-GMAC-256"
934+ ;;
935+ esac
936+ if [ "$auth_type" = "eap192" ]; then
937+ append network_data "group_mgmt=BIP-GMAC-256" "$N$T"
938+ else
939+ append network_data "group_mgmt=${ieee80211w_mgmt_cipher:-AES-128-CMAC}" "$N$T"
940+ fi
941+ [ -n "$beacon_prot" ] && \
942+ append network_data "beacon_prot=$beacon_prot" "$N$T"
943+ }
944 ;;
945 esac
946 }
947+
948 [ -n "$bssid" ] && append network_data "bssid=$bssid" "$N$T"
949 [ -n "$beacon_int" ] && append network_data "beacon_int=$beacon_int" "$N$T"
950
developer5ad89862023-08-24 08:17:27 +0800951@@ -1559,6 +1725,20 @@ wpa_supplicant_add_network() {
developer82408892023-03-27 15:09:00 +0800952 [ -n "$bssid_blacklist" ] && append network_data "bssid_blacklist=$bssid_blacklist" "$N$T"
953 [ -n "$bssid_whitelist" ] && append network_data "bssid_whitelist=$bssid_whitelist" "$N$T"
954
955+ local disable_eht
956+ local disable_he
957+ local disable_vht
958+ local disable_ht
959+ json_get_vars disable_eht
960+ json_get_vars disable_he
961+ json_get_vars disable_vht
962+ json_get_vars disable_ht
963+
964+ [ -n "$disable_eht" ] && append network_data "disable_eht=$disable_eht" "$N$T"
965+ [ -n "$disable_he" ] && append network_data "disable_he=$disable_he" "$N$T"
966+ [ -n "$disable_vht" ] && append network_data "disable_vht=$disable_vht" "$N$T"
967+ [ -n "$disable_ht" ] && append network_data "disable_ht=$disable_ht" "$N$T"
968+
969 [ -n "$basic_rate" ] && {
970 local br rate_list=
971 for br in $basic_rate; do
developer5ad89862023-08-24 08:17:27 +0800972@@ -1573,6 +1753,11 @@ wpa_supplicant_add_network() {
developer85839fe2023-02-23 10:32:51 +0800973 append network_data "mcast_rate=$mc_rate" "$N$T"
974 }
975
976+ if [ "$auth_type" = "sae" ]; then
977+ json_get_vars sae_pwe sae_pwe
978+ [ -n "$sae_pwe" ] && echo "sae_pwe=$sae_pwe" >> "$_config"
979+ fi
980+
981 if [ "$key_mgmt" = "WPS" ]; then
982 echo "wps_cred_processing=1" >> "$_config"
983 else