blob: 8d161168e2af9c8b418d185256ea71e304e9f0a7 [file] [log] [blame]
developerce9e5092022-11-10 22:41:59 +08001diff --git a/package/kernel/mac80211/Makefile b/package/kernel/mac80211/Makefile
developer785b6502023-04-19 18:31:11 +08002index 02cf715d..d878cb2a 100644
developerce9e5092022-11-10 22:41:59 +08003--- a/package/kernel/mac80211/Makefile
4+++ b/package/kernel/mac80211/Makefile
developerf0de14b2022-12-14 23:07:34 +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 = \
developerf0de14b2022-12-14 23:07:34 +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
developerf0de14b2022-12-14 23:07:34 +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
developer785b6502023-04-19 18:31:11 +080034index 5aaba9af..ce30b61d 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
developer0ba09b62023-03-10 18:43:49 +080037@@ -27,6 +27,7 @@ drv_mac80211_init_device_config() {
38
39 config_add_string path phy 'macaddr:macaddr'
40 config_add_string tx_burst
developer785b6502023-04-19 18:31:11 +080041+ config_add_int mbssid mu_onoff
developer0ba09b62023-03-10 18:43:49 +080042 config_add_string distance
43 config_add_int beacon_int chanbw frag rts
44 config_add_int rxantenna txantenna antenna_gain txpower min_tx_power
developer785b6502023-04-19 18:31:11 +080045@@ -53,7 +54,10 @@ drv_mac80211_init_device_config() {
46 he_spr_sr_control \
47 he_spr_psr_enabled \
48 he_bss_color_enabled \
49- he_twt_required
50+ he_twt_required \
51+ he_twt_responder \
52+ etxbfen \
53+ itxbfen
54 config_add_int \
55 beamformer_antennas \
56 beamformee_antennas \
57@@ -140,13 +144,11 @@ mac80211_hostapd_setup_base() {
developer0ba09b62023-03-10 18:43:49 +080058 [ -n "$acs_exclude_dfs" ] && [ "$acs_exclude_dfs" -gt 0 ] &&
59 append base_cfg "acs_exclude_dfs=1" "$N"
60
61- json_get_vars noscan ht_coex min_tx_power:0 tx_burst
developer785b6502023-04-19 18:31:11 +080062+ json_get_vars noscan ht_coex min_tx_power:0 tx_burst mbssid mu_onoff
63+ json_get_vars etxbfen:1 itxbfen:1
developer8d77be32022-10-20 15:08:25 +080064 json_get_values ht_capab_list ht_capab
developer20d67712022-03-02 14:09:32 +080065 json_get_values channel_list channels
66
67- [ "$auto_channel" = 0 ] && [ -z "$channel_list" ] && \
68- channel_list="$channel"
69-
developer9b3248d2022-07-06 00:44:05 +080070 [ "$min_tx_power" -gt 0 ] && append base_cfg "min_tx_power=$min_tx_power"
developer20d67712022-03-02 14:09:32 +080071
developer9b3248d2022-07-06 00:44:05 +080072 set_default noscan 0
developer785b6502023-04-19 18:31:11 +080073@@ -160,8 +162,8 @@ mac80211_hostapd_setup_base() {
74 ieee80211n=1
75 ht_capab=
76 case "$htmode" in
77- VHT20|HT20|HE20) ;;
78- HT40*|VHT40|VHT80|VHT160|HE40|HE80|HE160)
79+ VHT20|HT20|HE20|EHT20) ;;
developerbe3cf972023-04-27 09:58:26 +080080+ HT40*|VHT40|VHT80|VHT160|HE40*|HE80|HE160|EHT40*|EHT80|EHT160|EHT320*)
developer785b6502023-04-19 18:31:11 +080081 case "$hwmode" in
82 a)
83 case "$(( (($channel / 4) + $chan_ofs) % 2 ))" in
developerbe3cf972023-04-27 09:58:26 +080084@@ -171,8 +173,22 @@ mac80211_hostapd_setup_base() {
85 ;;
86 *)
87 case "$htmode" in
88- HT40+) ht_capab="[HT40+]";;
89- HT40-) ht_capab="[HT40-]";;
90+ HT40+|HE40+|EHT40+)
91+ if [ "$channel" -gt 9 ]; then
92+ echo "Could not set the center freq with this HT mode setting"
93+ return 1
94+ else
95+ ht_capab="[HT40+]"
96+ fi
97+ ;;
98+ HT40-|HE40-|EHT40-)
99+ if [ "$channel" -lt 5 ]; then
100+ echo "Could not set the center freq with this HT mode setting"
101+ return 1
102+ else
103+ ht_capab="[HT40-]"
104+ fi
105+ ;;
106 *)
107 if [ "$channel" -lt 7 ]; then
108 ht_capab="[HT40+]"
109@@ -205,7 +221,7 @@ mac80211_hostapd_setup_base() {
developer785b6502023-04-19 18:31:11 +0800110 dsss_cck_40:1
111
112 ht_cap_mask=0
113- for cap in $(iw phy "$phy" info | grep 'Capabilities:' | cut -d: -f2); do
114+ for cap in $(iw phy "$phy" info | grep 'Capabilities: 0x' | cut -d: -f2); do
115 ht_cap_mask="$(($ht_cap_mask | $cap))"
116 done
117
developerbe3cf972023-04-27 09:58:26 +0800118@@ -236,8 +252,8 @@ mac80211_hostapd_setup_base() {
developer785b6502023-04-19 18:31:11 +0800119
120 idx="$channel"
121 case "$htmode" in
122- VHT20|HE20) enable_ac=1;;
123- VHT40|HE40)
124+ VHT20|HE20|EHT20) enable_ac=1;;
125+ VHT40|HE40|EHT40)
126 case "$(( (($channel / 4) + $chan_ofs) % 2 ))" in
127 1) idx=$(($channel + 2));;
128 0) idx=$(($channel - 2));;
developerbe3cf972023-04-27 09:58:26 +0800129@@ -245,7 +261,7 @@ mac80211_hostapd_setup_base() {
developer785b6502023-04-19 18:31:11 +0800130 enable_ac=1
131 vht_center_seg0=$idx
132 ;;
133- VHT80|HE80)
134+ VHT80|HE80|EHT80)
135 case "$(( (($channel / 4) + $chan_ofs) % 4 ))" in
136 1) idx=$(($channel + 6));;
137 2) idx=$(($channel + 2));;
developerbe3cf972023-04-27 09:58:26 +0800138@@ -256,7 +272,7 @@ mac80211_hostapd_setup_base() {
developer785b6502023-04-19 18:31:11 +0800139 vht_oper_chwidth=1
140 vht_center_seg0=$idx
141 ;;
142- VHT160|HE160)
143+ VHT160|HE160|EHT160)
144 if [ "$band" = "6g" ]; then
145 case "$channel" in
146 1|5|9|13|17|21|25|29) idx=15;;
developerbe3cf972023-04-27 09:58:26 +0800147@@ -277,6 +293,36 @@ mac80211_hostapd_setup_base() {
developer785b6502023-04-19 18:31:11 +0800148 vht_oper_chwidth=2
149 vht_center_seg0=$idx
150 ;;
151+ EHT320*)
152+ case "$channel" in
153+ 1|5|9|13|17|21|25|29) idx=31;;
154+ 33|37|41|45|49|53|57|61| \
155+ 65|69|73|77|81|85|89|93) idx=63;;
156+ 97|101|105|109|113|117|121|125| \
157+ 129|133|137|141|145|149|153|157) idx=127;;
158+ 161|165|169|173|177|181|185|189| \
159+ 193|197|201|205|209|213|217|221) idx=191;;
160+ esac
161+ if [[ "$htmode" = "EHT320-1" && "$channel" -ge "193" ]] ||
162+ [[ "$htmode" = "EHT320-2" && "$channel" -le "29" ]]; then
163+ echo "Could not set the center freq with this EHT setting"
164+ return 1
165+ elif [[ "$htmode" = "EHT320-1" && "$channel" -ge "33" ]]; then
166+ if [ "$channel" -gt $idx ]; then
167+ idx=$(($idx + 32))
168+ else
169+ idx=$(($idx - 32))
170+ fi
171+ fi
172+ vht_oper_chwidth=2
173+ if [ "$channel" -gt $idx ]; then
174+ vht_center_seg0=$(($idx + 16))
175+ else
176+ vht_center_seg0=$(($idx - 16))
177+ fi
178+ eht_oper_chwidth=9
179+ eht_oper_centr_freq_seg0_idx=$idx
180+ ;;
181 esac
182 [ "$band" = "5g" ] && {
183 json_get_vars background_radar:0
developerbe3cf972023-04-27 09:58:26 +0800184@@ -286,8 +332,9 @@ mac80211_hostapd_setup_base() {
developer785b6502023-04-19 18:31:11 +0800185 [ "$band" = "6g" ] && {
186 op_class=
187 case "$htmode" in
188- HE20) op_class=131;;
189- HE*) op_class=$((132 + $vht_oper_chwidth))
190+ HE20|EHT20) op_class=131;;
191+ EHT320*) op_class=137;;
192+ HE*|EHT*) op_class=$((132 + $vht_oper_chwidth))
193 esac
194 [ -n "$op_class" ] && append base_cfg "op_class=$op_class" "$N"
195 }
developerbe3cf972023-04-27 09:58:26 +0800196@@ -315,7 +362,6 @@ mac80211_hostapd_setup_base() {
developer8b04dfd2022-12-07 16:29:19 +0800197 vht_link_adapt:3 \
198 vht160:2
199
200- set_default tx_burst 2.0
201 append base_cfg "ieee80211ac=1" "$N"
202 vht_cap=0
203 for cap in $(iw phy "$phy" info | awk -F "[()]" '/VHT Capabilities/ { print $2 }'); do
developerbe3cf972023-04-27 09:58:26 +0800204@@ -329,6 +375,12 @@ mac80211_hostapd_setup_base() {
developer785b6502023-04-19 18:31:11 +0800205 [ "$rx_stbc" -lt "$cap_rx_stbc" ] && cap_rx_stbc="$rx_stbc"
206 vht_cap="$(( ($vht_cap & ~(0x700)) | ($cap_rx_stbc << 8) ))"
207
208+ [ "$etxbfen" -eq 0 ] && {
209+ su_beamformer=0
210+ su_beamformee=0
211+ mu_beamformer=0
212+ }
213+
214 mac80211_add_capabilities vht_capab $vht_cap \
215 RXLDPC:0x10::$rxldpc \
216 SHORT-GI-80:0x20::$short_gi_80 \
developerbe3cf972023-04-27 09:58:26 +0800217@@ -410,7 +462,7 @@ mac80211_hostapd_setup_base() {
developer785b6502023-04-19 18:31:11 +0800218 # 802.11ax
219 enable_ax=0
220 case "$htmode" in
221- HE*) enable_ax=1 ;;
222+ HE*|EHT*) enable_ax=1 ;;
223 esac
224
225 if [ "$enable_ax" != "0" ]; then
developerbe3cf972023-04-27 09:58:26 +0800226@@ -419,10 +471,11 @@ mac80211_hostapd_setup_base() {
developer785b6502023-04-19 18:31:11 +0800227 he_su_beamformee:1 \
228 he_mu_beamformer:1 \
229 he_twt_required:0 \
230+ he_twt_responder \
231 he_spr_sr_control:3 \
232 he_spr_psr_enabled:0 \
233 he_spr_non_srg_obss_pd_max_offset:0 \
234- he_bss_color:128 \
235+ he_bss_color \
236 he_bss_color_enabled:1
237
238 he_phy_cap=$(iw phy "$phy" info | sed -n '/HE Iftypes: AP/,$p' | awk -F "[()]" '/HE PHY Capabilities/ { print $2 }' | head -1)
developerbe3cf972023-04-27 09:58:26 +0800239@@ -436,6 +489,11 @@ mac80211_hostapd_setup_base() {
developer785b6502023-04-19 18:31:11 +0800240 append base_cfg "he_oper_centr_freq_seg0_idx=$vht_center_seg0" "$N"
241 }
242
243+ [ "$etxbfen" -eq 0 ] && {
244+ he_su_beamformer=0
245+ he_mu_beamformer=0
246+ }
247+
248 mac80211_add_he_capabilities \
249 he_su_beamformer:${he_phy_cap:6:2}:0x80:$he_su_beamformer \
250 he_su_beamformee:${he_phy_cap:8:2}:0x1:$he_su_beamformee \
developerbe3cf972023-04-27 09:58:26 +0800251@@ -443,7 +501,14 @@ mac80211_hostapd_setup_base() {
developer785b6502023-04-19 18:31:11 +0800252 he_spr_psr_enabled:${he_phy_cap:14:2}:0x1:$he_spr_psr_enabled \
253 he_twt_required:${he_mac_cap:0:2}:0x6:$he_twt_required
254
255+ if [ -n "$he_twt_responder" ]; then
256+ append base_cfg "he_twt_responder=$he_twt_responder" "$N"
257+ fi
258 if [ "$he_bss_color_enabled" -gt 0 ]; then
259+ if [ -z "$he_bss_color" ]; then
260+ rand=$(head -n 1 /dev/urandom | tr -dc 0-9 | head -c 2)
261+ he_bss_color=$((rand % 63 + 1))
262+ fi
263 append base_cfg "he_bss_color=$he_bss_color" "$N"
264 [ "$he_spr_non_srg_obss_pd_max_offset" -gt 0 ] && { \
265 append base_cfg "he_spr_non_srg_obss_pd_max_offset=$he_spr_non_srg_obss_pd_max_offset" "$N"
developerbe3cf972023-04-27 09:58:26 +0800266@@ -484,12 +549,46 @@ mac80211_hostapd_setup_base() {
developer8b04dfd2022-12-07 16:29:19 +0800267 append base_cfg "he_mu_edca_ac_vo_timer=255" "$N"
268 fi
269
developer9851a292022-12-15 17:33:43 +0800270+ set_default tx_burst 5.9
developer8b04dfd2022-12-07 16:29:19 +0800271+
developer785b6502023-04-19 18:31:11 +0800272+ # 802.11be
273+ enable_be=0
274+ case "$htmode" in
275+ EHT*) enable_be=1 ;;
276+ esac
277+
278+ if [ "$enable_be" != "0" ]; then
279+ append base_cfg "ieee80211be=1" "$N"
280+ if [ "$etxbfen" -eq 0 ]; then
281+ append base_cfg "eht_su_beamformee=1" "$N"
282+ else
283+ append base_cfg "eht_su_beamformer=1" "$N"
284+ append base_cfg "eht_su_beamformee=1" "$N"
285+ append base_cfg "eht_mu_beamformer=1" "$N"
286+ fi
287+ [ "$hwmode" = "a" ] && {
288+ case $htmode in
289+ EHT320*)
290+ append base_cfg "eht_oper_chwidth=$eht_oper_chwidth" "$N"
291+ append base_cfg "eht_oper_centr_freq_seg0_idx=$eht_oper_centr_freq_seg0_idx" "$N"
292+ ;;
293+ *)
294+ append base_cfg "eht_oper_chwidth=$vht_oper_chwidth" "$N"
295+ append base_cfg "eht_oper_centr_freq_seg0_idx=$vht_center_seg0" "$N"
296+ ;;
297+ esac
298+ }
299+ fi
300+
developer8b04dfd2022-12-07 16:29:19 +0800301 hostapd_prepare_device_config "$hostapd_conf_file" nl80211
302 cat >> "$hostapd_conf_file" <<EOF
303 ${channel:+channel=$channel}
developer0ba09b62023-03-10 18:43:49 +0800304 ${channel_list:+chanlist=$channel_list}
305 ${hostapd_noscan:+noscan=1}
306 ${tx_burst:+tx_queue_data2_burst=$tx_burst}
307+${mbssid:+mbssid=$mbssid}
developer785b6502023-04-19 18:31:11 +0800308+${mu_onoff:+mu_onoff=$mu_onoff}
309+${itxbfen:+ibf_enable=$itxbfen}
developer0ba09b62023-03-10 18:43:49 +0800310 $base_cfg
311
312 EOF
developerbe3cf972023-04-27 09:58:26 +0800313@@ -517,7 +616,7 @@ mac80211_hostapd_setup_bss() {
developer093e1a32023-02-24 16:10:53 +0800314 append hostapd_cfg "wds_sta=1" "$N"
315 [ -n "$wds_bridge" ] && append hostapd_cfg "wds_bridge=$wds_bridge" "$N"
316 }
317- [ "$staidx" -gt 0 -o "$start_disabled" -eq 1 ] && append hostapd_cfg "start_disabled=1" "$N"
318+ [ "$start_disabled" -eq 1 ] && append hostapd_cfg "start_disabled=1" "$N"
319
320 cat >> /var/run/hostapd-$phy.conf <<EOF
321 $hostapd_cfg
developerbe3cf972023-04-27 09:58:26 +0800322@@ -527,6 +626,34 @@ ${max_listen_int:+max_listen_interval=$m
developer0ba09b62023-03-10 18:43:49 +0800323 EOF
324 }
325
326+mac80211_generate_mbssid_mac() {
327+ local phy="$1"
328+ local transmitted_bssid="$2"
329+ local id="${macidx:-0}"
330+
331+ local ref="$(cat /sys/class/ieee80211/${phy}/macaddress)"
332+ local mask="$(cat /sys/class/ieee80211/${phy}/address_mask)"
333+
334+ if [ -z "$transmitted_bssid" ]; then
335+ transmitted_bssid=$ref
336+ fi
337+
338+ if [ $id -eq 0 ]; then
339+ echo "$transmitted_bssid"
340+ return
341+ fi
342+
343+ local oIFS="$IFS"; IFS=":"; set -- $transmitted_bssid; IFS="$oIFS"
344+
345+ # Calculate nontransmitted bssid
346+ macidx=$(($id + 1))
347+ mbssid_idx=$(($macidx - 1))
348+ b6="0x$6"
349+ ref_b6=$(($b6 % $max_mbssid))
350+ b6=$(($b6 - $ref_b6 + ($ref_b6 + $mbssid_idx) % $max_mbssid))
351+ printf "%s:%s:%s:%s:%s:%02x" $1 $2 $3 $4 $5 $b6
352+}
353+
354 mac80211_get_addr() {
355 local phy="$1"
356 local idx="$(($2 + 1))"
developerbe3cf972023-04-27 09:58:26 +0800357@@ -757,7 +884,13 @@ mac80211_prepare_vif() {
developer0ba09b62023-03-10 18:43:49 +0800358
359 json_select ..
360
361- if [ -z "$macaddr" ]; then
362+ if [ "$mbssid" -gt 0 ]; then
363+ [ "$macidx" -eq 0 ] && {
364+ transmitted_bssid=$macaddr
365+ }
366+ macaddr="$(mac80211_generate_mbssid_mac $phy $transmitted_bssid)"
367+ macidx="$(($macidx + 1))"
368+ elif [ -z "$macaddr" ]; then
369 macaddr="$(mac80211_generate_mac $phy)"
370 macidx="$(($macidx + 1))"
371 elif [ "$macaddr" = 'random' ]; then
developerbe3cf972023-04-27 09:58:26 +0800372@@ -1058,6 +1191,9 @@ mac80211_setup_vif() {
developerf0de14b2022-12-14 23:07:34 +0800373
374 json_select ..
375 [ -n "$failed" ] || wireless_add_vif "$name" "$ifname"
376+
377+ echo "Setup SMP Affinity"
378+ /sbin/smp-mt76.sh
379 }
380
381 get_freq() {
developerbe3cf972023-04-27 09:58:26 +0800382@@ -1122,6 +1258,10 @@ drv_mac80211_cleanup() {
developer0ba09b62023-03-10 18:43:49 +0800383 hostapd_common_cleanup
384 }
385
386+mac80211_count_ap() {
387+ total_num_ap=$(($total_num_ap + 1))
388+}
389+
390 drv_mac80211_setup() {
391 json_select config
392 json_get_vars \
developerbe3cf972023-04-27 09:58:26 +0800393@@ -1219,6 +1359,16 @@ drv_mac80211_setup() {
developer0ba09b62023-03-10 18:43:49 +0800394 for_each_interface "sta adhoc mesh" mac80211_set_noscan
395 [ -n "$has_ap" ] && mac80211_hostapd_setup_base "$phy"
396
397+ total_num_ap=0
398+ max_mbssid=1
399+ for_each_interface "ap" mac80211_count_ap
400+ total_num_ap=$(($total_num_ap - 1))
401+ while [ $total_num_ap -gt 0 ]
402+ do
403+ total_num_ap=$(($total_num_ap >> 1))
404+ max_mbssid=$(($max_mbssid << 1))
405+ done
406+
407 mac80211_prepare_iw_htmode
408 for_each_interface "sta adhoc mesh monitor" mac80211_prepare_vif
409 NEWAPLIST=
developer9b3248d2022-07-06 00:44:05 +0800410diff --git a/package/kernel/mac80211/files/lib/wifi/mac80211.sh b/package/kernel/mac80211/files/lib/wifi/mac80211.sh
developer785b6502023-04-19 18:31:11 +0800411index e24a2a63..80cd298c 100644
developere2597ba2022-06-24 13:09:16 +0800412--- a/package/kernel/mac80211/files/lib/wifi/mac80211.sh
413+++ b/package/kernel/mac80211/files/lib/wifi/mac80211.sh
developer785b6502023-04-19 18:31:11 +0800414@@ -60,6 +60,8 @@ BEGIN {
415 if (vht && band != "1:") mode="VHT80"
416 if (he) mode="HE80"
417 if (he && band == "1:") mode="HE20"
418+ if (eht) mode="EHT80"
419+ if (eht && band == "1:") mode="EHT20"
420 sub("\\[", "", channel)
421 sub("\\]", "", channel)
422 bands = bands band channel ":" mode " "
423@@ -73,6 +75,7 @@ $1 == "Band" {
424 vht = ""
425 ht = ""
426 he = ""
427+ eht = ""
428 }
429
430 $0 ~ "Capabilities:" {
431@@ -87,6 +90,10 @@ $0 ~ "HE Iftypes" {
432 he=1
433 }
434
435+$0 ~ "EHT Iftypes" {
436+ eht=1
437+}
438+
439 $1 == "*" && $3 == "MHz" && $0 !~ /disabled/ && band && !channel {
440 channel = $4
441 }
442@@ -120,6 +127,13 @@ get_band_defaults() {
developere2597ba2022-06-24 13:09:16 +0800443 mode_band="$band"
444 channel="$chan"
445 htmode="$mode"
446+ if [ "$band" = "6g" ]
447+ then
448+ encryption=sae
449+ key=12345678
450+ else
451+ encryption=none
452+ fi
453 done
454 }
455
developer785b6502023-04-19 18:31:11 +0800456@@ -153,6 +167,10 @@ detect_mac80211() {
457
458 json_load_file /etc/board.json
459
460+ # generate random bytes for macaddr
461+ rand=$(hexdump -C /dev/urandom | head -n 1 &)
462+ killall hexdump
463+
464 for _dev in /sys/class/ieee80211/*; do
465 [ -e "$_dev" ] || continue
466
467@@ -162,6 +180,8 @@ detect_mac80211() {
developere2597ba2022-06-24 13:09:16 +0800468 channel=""
469 htmode=""
470 ht_capab=""
471+ encryption=""
472+ key=""
473
474 get_band_defaults "$dev"
475
developer785b6502023-04-19 18:31:11 +0800476@@ -196,6 +216,11 @@ detect_mac80211() {
477 ;;
478 esac
479
480+ macaddr=""
481+ for i in $(seq 2 3); do
482+ macaddr=${macaddr}:$(echo $rand | cut -d ' ' -f $i)
483+ done
484+
485 uci -q batch <<-EOF
486 set wireless.${name}=wifi-device
487 set wireless.${name}.type=mac80211
488@@ -210,8 +235,14 @@ detect_mac80211() {
developer8d77be32022-10-20 15:08:25 +0800489 set wireless.default_${name}.network=lan
490 set wireless.default_${name}.mode=ap
491 set wireless.default_${name}.ssid=OpenWrt
492- set wireless.default_${name}.encryption=none
493+ set wireless.default_${name}.encryption=${encryption}
494+
developer785b6502023-04-19 18:31:11 +0800495+ set wireless.default_${name}.macaddr=00:0$(($devidx - 1)):55:66${macaddr}
496+
developere2597ba2022-06-24 13:09:16 +0800497 EOF
498+ [ -n "$key" ] && {
developer8d77be32022-10-20 15:08:25 +0800499+ uci -q set wireless.default_${name}.key=${key}
developere2597ba2022-06-24 13:09:16 +0800500+ }
501 uci -q commit wireless
developer8d77be32022-10-20 15:08:25 +0800502 done
503 }
developer85839fe2023-02-23 10:32:51 +0800504diff --git a/package/network/services/hostapd/files/hostapd.sh b/package/network/services/hostapd/files/hostapd.sh
developer813f5d72023-03-28 17:44:38 +0800505index 28bd2106..5e21d0d6 100644
developer85839fe2023-02-23 10:32:51 +0800506--- a/package/network/services/hostapd/files/hostapd.sh
507+++ b/package/network/services/hostapd/files/hostapd.sh
developer813f5d72023-03-28 17:44:38 +0800508@@ -376,6 +376,13 @@ hostapd_common_add_bss_config() {
developer82408892023-03-27 15:09:00 +0800509 config_add_string fils_dhcp
510
511 config_add_int ocv
512+
513+ config_add_int disable_eht
514+ config_add_int disable_he
515+ config_add_int disable_vht
516+ config_add_int disable_ht
developer813f5d72023-03-28 17:44:38 +0800517+
518+ config_add_boolean beacon_prot
developer82408892023-03-27 15:09:00 +0800519 }
520
521 hostapd_set_vlan_file() {
developer813f5d72023-03-28 17:44:38 +0800522@@ -975,7 +982,7 @@ hostapd_set_bss_options() {
523 # RSN -> allow management frame protection
524 case "$ieee80211w" in
525 [012])
526- json_get_vars ieee80211w_mgmt_cipher ieee80211w_max_timeout ieee80211w_retry_timeout
527+ json_get_vars ieee80211w_mgmt_cipher ieee80211w_max_timeout ieee80211w_retry_timeout beacon_prot
528 append bss_conf "ieee80211w=$ieee80211w" "$N"
529 [ "$ieee80211w" -gt "0" ] && {
530 if [ "$auth_type" = "eap192" ]; then
531@@ -983,6 +990,8 @@ hostapd_set_bss_options() {
532 else
533 append bss_conf "group_mgmt_cipher=${ieee80211w_mgmt_cipher:-AES-128-CMAC}" "$N"
534 fi
535+ [ -n "$beacon_prot" ] && \
536+ append bss_conf "beacon_prot=$beacon_prot" "$N"
537 [ -n "$ieee80211w_max_timeout" ] && \
538 append bss_conf "assoc_sa_query_max_timeout=$ieee80211w_max_timeout" "$N"
539 [ -n "$ieee80211w_retry_timeout" ] && \
540@@ -1559,6 +1568,20 @@ wpa_supplicant_add_network() {
developer82408892023-03-27 15:09:00 +0800541 [ -n "$bssid_blacklist" ] && append network_data "bssid_blacklist=$bssid_blacklist" "$N$T"
542 [ -n "$bssid_whitelist" ] && append network_data "bssid_whitelist=$bssid_whitelist" "$N$T"
543
544+ local disable_eht
545+ local disable_he
546+ local disable_vht
547+ local disable_ht
548+ json_get_vars disable_eht
549+ json_get_vars disable_he
550+ json_get_vars disable_vht
551+ json_get_vars disable_ht
552+
553+ [ -n "$disable_eht" ] && append network_data "disable_eht=$disable_eht" "$N$T"
554+ [ -n "$disable_he" ] && append network_data "disable_he=$disable_he" "$N$T"
555+ [ -n "$disable_vht" ] && append network_data "disable_vht=$disable_vht" "$N$T"
556+ [ -n "$disable_ht" ] && append network_data "disable_ht=$disable_ht" "$N$T"
557+
558 [ -n "$basic_rate" ] && {
559 local br rate_list=
560 for br in $basic_rate; do
developer813f5d72023-03-28 17:44:38 +0800561@@ -1573,6 +1596,11 @@ wpa_supplicant_add_network() {
developer85839fe2023-02-23 10:32:51 +0800562 append network_data "mcast_rate=$mc_rate" "$N$T"
563 }
564
565+ if [ "$auth_type" = "sae" ]; then
566+ json_get_vars sae_pwe sae_pwe
567+ [ -n "$sae_pwe" ] && echo "sae_pwe=$sae_pwe" >> "$_config"
568+ fi
569+
570 if [ "$key_mgmt" = "WPS" ]; then
571 echo "wps_cred_processing=1" >> "$_config"
572 else