[rdkb][mt7986][app][Refactor hostapd service]
[Description]
Refactor hostapd service
1. move mac80211.sh from init-filogic to hostapd, and will run before hostapd.service
2. refactor hostapd-init.sh, it will accroding to uci wireless config to gen config and bring up interface
3. remove unused hostapd config, such like hostapd-bhaul2G.conf
4. separate init brlan0 part from hostapd-init.sh and create init-Lanbridge.service to handle
[Release-log]
diff --git a/recipes-connectivity/hostapd/files/hostapd-2G.conf b/recipes-connectivity/hostapd/files/hostapd-2G.conf
index 932e80d..a2fab4b 100644
--- a/recipes-connectivity/hostapd/files/hostapd-2G.conf
+++ b/recipes-connectivity/hostapd/files/hostapd-2G.conf
@@ -61,7 +61,7 @@
utf8_ssid=1
multi_ap=0
auth_algs=1
-ssid=Filogic
+ssid=Filogic_2g
bridge=brlan0
wds_bridge=
snoop_iface=brlan0
@@ -72,7 +72,7 @@
wpa=2
wpa_pairwise=CCMP
wpa_key_mgmt=WPA-PSK
-wpa_passphrase=rdk@1234
+wpa_passphrase=12345678
#WPS configuration lines, but WPS disabled by default
wps_state=0
ap_setup_locked=1
diff --git a/recipes-connectivity/hostapd/files/hostapd-5G-7916.conf b/recipes-connectivity/hostapd/files/hostapd-5G-7916.conf
new file mode 100644
index 0000000..e25080f
--- /dev/null
+++ b/recipes-connectivity/hostapd/files/hostapd-5G-7916.conf
@@ -0,0 +1,87 @@
+driver=nl80211
+logger_syslog=127
+logger_syslog_level=2
+logger_stdout=127
+logger_stdout_level=2
+hw_mode=a
+beacon_int=100
+dtim_period=2
+
+country_code=US
+ieee80211d=1
+channel=36
+
+tx_queue_data2_burst=2.0
+ieee80211n=1
+ht_coex=0
+ht_capab=[HT40+][LDPC][SHORT-GI-20][SHORT-GI-40][TX-STBC][RX-STBC1][MAX-AMSDU-7935]
+ieee80211ac=1
+vht_oper_chwidth=1
+vht_oper_centr_freq_seg0_idx=42
+vht_capab=[RXLDPC][SHORT-GI-80][SHORT-GI-160][TX-STBC-2BY1][SU-BEAMFORMER][SU-BEAMFORMEE][MU-BEAMFORMER][MU-BEAMFORMEE][RX-ANTENNA-PATTERN][TX-ANTENNA-PATTERN][RX-STBC-1][SOUNDING-DIMENSION-2][BF-ANTENNA-2][VHT160][MAX-MPDU-11454][MAX-A-MPDU-LEN-EXP7]
+
+ieee80211ax=1
+he_oper_chwidth=1
+he_oper_centr_freq_seg0_idx=42
+he_su_beamformer=1
+he_mu_beamformer=1
+he_default_pe_duration=4
+he_rts_threshold=1023
+he_mu_edca_qos_info_param_count=0
+he_mu_edca_qos_info_q_ack=0
+he_mu_edca_qos_info_queue_request=0
+he_mu_edca_qos_info_txop_request=0
+he_mu_edca_ac_be_aifsn=8
+he_mu_edca_ac_be_aci=0
+he_mu_edca_ac_be_ecwmin=9
+he_mu_edca_ac_be_ecwmax=10
+he_mu_edca_ac_be_timer=255
+he_mu_edca_ac_bk_aifsn=15
+he_mu_edca_ac_bk_aci=1
+he_mu_edca_ac_bk_ecwmin=9
+he_mu_edca_ac_bk_ecwmax=10
+he_mu_edca_ac_bk_timer=255
+he_mu_edca_ac_vi_ecwmin=5
+he_mu_edca_ac_vi_ecwmax=7
+he_mu_edca_ac_vi_aifsn=5
+he_mu_edca_ac_vi_aci=2
+he_mu_edca_ac_vi_timer=255
+he_mu_edca_ac_vo_aifsn=5
+he_mu_edca_ac_vo_aci=3
+he_mu_edca_ac_vo_ecwmin=5
+he_mu_edca_ac_vo_ecwmax=7
+he_mu_edca_ac_vo_timer=255
+
+interface=wifi1
+ctrl_interface=/var/run/hostapd
+ap_isolate=0
+bss_load_update_period=60
+chan_util_avg_period=600
+disassoc_low_ack=1
+skip_inactivity_poll=0
+preamble=1
+wmm_enabled=1
+ignore_broadcast_ssid=0
+uapsd_advertisement_enabled=1
+utf8_ssid=1
+multi_ap=0
+auth_algs=1
+ssid=Filogic_5g
+bridge=brlan0
+wds_bridge=
+snoop_iface=brlan0
+qos_map_set=0,0,2,16,1,1,255,255,18,22,24,38,40,40,44,46,48,56
+bssid=
+
+#Security parameters
+wpa=2
+wpa_pairwise=CCMP
+wpa_key_mgmt=WPA-PSK
+wpa_passphrase=12345678
+#WPS configuration lines, but WPS disabled by default
+wps_state=0
+ap_setup_locked=1
+config_methods=virtual_push_button keypad
+wps_pin_requests=/var/run/hostapd_wps_pin_requests.log
+eap_server=1
+
diff --git a/recipes-connectivity/hostapd/files/hostapd-5G.conf b/recipes-connectivity/hostapd/files/hostapd-5G.conf
index 59a2d07..cca996e 100644
--- a/recipes-connectivity/hostapd/files/hostapd-5G.conf
+++ b/recipes-connectivity/hostapd/files/hostapd-5G.conf
@@ -66,7 +66,7 @@
utf8_ssid=1
multi_ap=0
auth_algs=1
-ssid=Filogic_5
+ssid=Filogic_5g
bridge=brlan0
wds_bridge=
snoop_iface=brlan0
@@ -77,7 +77,7 @@
wpa=2
wpa_pairwise=CCMP
wpa_key_mgmt=WPA-PSK
-wpa_passphrase=rdk@1234
+wpa_passphrase=12345678
#WPS configuration lines, but WPS disabled by default
wps_state=0
ap_setup_locked=1
diff --git a/recipes-connectivity/hostapd/files/hostapd-6G.conf b/recipes-connectivity/hostapd/files/hostapd-6G.conf
new file mode 100644
index 0000000..874ef7e
--- /dev/null
+++ b/recipes-connectivity/hostapd/files/hostapd-6G.conf
@@ -0,0 +1,91 @@
+driver=nl80211
+logger_syslog=127
+logger_syslog_level=2
+logger_stdout=127
+logger_stdout_level=2
+hw_mode=a
+beacon_int=100
+dtim_period=2
+
+country_code=DE
+ieee80211d=1
+ieee80211h=1
+channel=37
+chanlist=37
+
+tx_queue_data2_burst=2.0
+ieee80211n=1
+ht_coex=0
+ht_capab=[HT40-]
+op_class=133
+ieee80211ac=1
+vht_oper_chwidth=1
+vht_oper_centr_freq_seg0_idx=39
+vht_capab=[MAX-A-MPDU-LEN-EXP0]
+ieee80211ax=1
+he_oper_chwidth=1
+he_oper_centr_freq_seg0_idx=39
+he_bss_color=128
+he_su_beamformer=1
+he_mu_beamformer=1
+he_default_pe_duration=4
+he_rts_threshold=1023
+he_mu_edca_qos_info_param_count=0
+he_mu_edca_qos_info_q_ack=0
+he_mu_edca_qos_info_queue_request=0
+he_mu_edca_qos_info_txop_request=0
+he_mu_edca_ac_be_aifsn=8
+he_mu_edca_ac_be_aci=0
+he_mu_edca_ac_be_ecwmin=9
+he_mu_edca_ac_be_ecwmax=10
+he_mu_edca_ac_be_timer=255
+he_mu_edca_ac_bk_aifsn=15
+he_mu_edca_ac_bk_aci=1
+he_mu_edca_ac_bk_ecwmin=9
+he_mu_edca_ac_bk_ecwmax=10
+he_mu_edca_ac_bk_timer=255
+he_mu_edca_ac_vi_ecwmin=5
+he_mu_edca_ac_vi_ecwmax=7
+he_mu_edca_ac_vi_aifsn=5
+he_mu_edca_ac_vi_aci=2
+he_mu_edca_ac_vi_timer=255
+he_mu_edca_ac_vo_aifsn=5
+he_mu_edca_ac_vo_aci=3
+he_mu_edca_ac_vo_ecwmin=5
+he_mu_edca_ac_vo_ecwmax=7
+he_mu_edca_ac_vo_timer=255
+
+interface=wifi2
+ctrl_interface=/var/run/hostapd
+ap_isolate=0
+bss_load_update_period=60
+chan_util_avg_period=600
+disassoc_low_ack=1
+skip_inactivity_poll=0
+preamble=1
+wmm_enabled=1
+ignore_broadcast_ssid=0
+uapsd_advertisement_enabled=1
+utf8_ssid=1
+multi_ap=0
+auth_algs=1
+ssid=Filogic_6g
+bridge=brlan0
+wds_bridge=
+snoop_iface=brlan0
+qos_map_set=0,0,2,16,1,1,255,255,18,22,24,38,40,40,44,46,48,56
+bssid=
+wpa=2
+wpa_pairwise=CCMP
+wpa_key_mgmt=SAE
+wpa_passphrase=12345678
+sae_require_mfp=1
+sae_pwe=2
+
+wpa_disable_eapol_key_retries=0
+
+okc=1
+ieee80211w=2
+group_mgmt_cipher=AES-128-CMAC
+
+
diff --git a/recipes-connectivity/hostapd/files/hostapd-bhaul2G.conf b/recipes-connectivity/hostapd/files/hostapd-bhaul2G.conf
deleted file mode 100644
index 38cafc5..0000000
--- a/recipes-connectivity/hostapd/files/hostapd-bhaul2G.conf
+++ /dev/null
@@ -1,35 +0,0 @@
-driver=nl80211
-logger_syslog=127
-logger_syslog_level=2
-logger_stdout=127
-logger_stdout_level=2
-country_code=US
-ieee80211d=1
-hw_mode=g
-beacon_int=100
-channel=11
-
-ieee80211n=1
-#ht_coex=0
-ht_capab=[SHORT-GI-20][SHORT-GI-40][TX-STBC][RX-STBC1][DSSS_CCK-40]
-
-interface=wifi2
-ctrl_interface=/var/run/hostapd
-ap_isolate=1
-bss_load_update_period=60
-#chan_util_avg_period=600
-disassoc_low_ack=1
-preamble=1
-wmm_enabled=1
-ignore_broadcast_ssid=1
-uapsd_advertisement_enabled=1
-auth_algs=1
-wpa=2
-bssid=
-wpa_pairwise=CCMP
-rrm_neighbor_report=1
-wpa_key_mgmt=WPA-PSK
-bss_transition=1
-
-macaddr_acl=1
-accept_mac_file=/tmp/hostapd-acl2
diff --git a/recipes-connectivity/hostapd/files/hostapd-bhaul5G.conf b/recipes-connectivity/hostapd/files/hostapd-bhaul5G.conf
deleted file mode 100644
index 8c5d9e0..0000000
--- a/recipes-connectivity/hostapd/files/hostapd-bhaul5G.conf
+++ /dev/null
@@ -1,35 +0,0 @@
-driver=nl80211
-logger_syslog=127
-logger_syslog_level=2
-logger_stdout=127
-logger_stdout_level=2
-country_code=US
-ieee80211d=1
-hw_mode=a
-beacon_int=100
-channel=36
-
-ieee80211n=1
-#ht_coex=0
-ht_capab=[SHORT-GI-20][SHORT-GI-40][TX-STBC][RX-STBC1][DSSS_CCK-40]
-
-interface=wifi3
-ctrl_interface=/var/run/hostapd
-ap_isolate=1
-bss_load_update_period=60
-#chan_util_avg_period=600
-disassoc_low_ack=1
-preamble=1
-wmm_enabled=1
-ignore_broadcast_ssid=1
-uapsd_advertisement_enabled=1
-auth_algs=1
-wpa=2
-bssid=
-wpa_pairwise=CCMP
-rrm_neighbor_report=1
-wpa_key_mgmt=WPA-PSK
-bss_transition=1
-
-macaddr_acl=1
-accept_mac_file=/tmp/hostapd-acl3
diff --git a/recipes-connectivity/hostapd/files/hostapd-init.sh b/recipes-connectivity/hostapd/files/hostapd-init.sh
index 831e0d3..f65152b 100644
--- a/recipes-connectivity/hostapd/files/hostapd-init.sh
+++ b/recipes-connectivity/hostapd/files/hostapd-init.sh
@@ -1,228 +1,76 @@
-# If not stated otherwise in this file or this component's LICENSE
-# file the following copyright and licenses apply:
-#
-#Copyright [2019] [RDK Management]
-#
-#Licensed under the Apache License, Version 2.0 (the "License");
-#you may not use this file except in compliance with the License.
-#You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-#Unless required by applicable law or agreed to in writing, software
-#distributed under the License is distributed on an "AS IS" BASIS,
-#WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-#See the License for the specific language governing permissions and
-#limitations under the License.
-
#!/bin/sh
-device_type=`cat /version.txt | grep imagename | cut -d':' -f2 | cut -d'-' -f3`
-echo "device_type: $device_type"
-if [ $device_type == "extender" ];
-then
-#Workaround: allowing devices initialization
-sleep 5;
-fi
+create_hostapdConf() {
+ devidx=0
+
-nvram_mounted=`mount | grep nvram -wc`
-if [ $nvram_mounted == 0 ]; then
- mkdir -p /nvram
- if [ -b /dev/mmcblk0p6 ]; then
- #for Older Turris Omnia
- mount /dev/mmcblk0p6 /nvram
- else
- #for Omnia2019 and Omnia2020
- mount /dev/mmcblk0p5 /nvram
- fi
-fi
+ for _dev in /sys/class/ieee80211/*; do
+ [ -e "$_dev" ] || continue
-WIFI0_MAC=`cat /sys/class/net/wlan0/address`
-WIFI1_MAC=`cat /sys/class/net/wlan1/address`
-echo "2.4GHz Radio MAC: $WIFI0_MAC"
-echo "5GHz Radio MAC: $WIFI1_MAC"
+ dev="${_dev##*/}"
-if [ ! -f /nvram/hostapd0.conf ]
-then
- cp /etc/hostapd-2G.conf /nvram/hostapd0.conf
- #Set bssid for wifi0
- NEW_MAC=$(echo 0x$WIFI0_MAC| awk -F: '{printf "%02x:%s:%s:%s:%s:%s", strtonum($1)+2, $2, $3, $4 ,$5, $6}')
- sed -i "/^bssid=/c\bssid=$NEW_MAC" /nvram/hostapd0.conf
- echo "wpa_psk_file=/tmp/hostapd0.psk" >> /nvram/hostapd0.conf
-fi
+ band="$(uci get wireless.radio${devidx}.band)"
+ channel="$(uci get wireless.radio${devidx}.channel)"
+ MAC="$(cat /sys/class/net/wlan${devidx}/address)"
+ NEW_MAC=$(echo 0x$MAC| awk -F: '{printf "%02x:%s:%s:%s:%s:%s", strtonum($1)+2, $2, $3, $4 ,$5, $6}')
+ chip="$(cat /sys/class/ieee80211/"$dev"/device/device)"
-if [ ! -f /nvram/hostapd1.conf ]
-then
- cp /etc/hostapd-5G.conf /nvram/hostapd1.conf
- #Set bssid for wifi1
- NEW_MAC=$(echo 0x$WIFI1_MAC| awk -F: '{printf "%02x:%s:%s:%s:%s:%s", strtonum($1)+2, $2, $3, $4 ,$5, $6}')
- sed -i "/^bssid=/c\bssid=$NEW_MAC" /nvram/hostapd1.conf
- echo "wpa_psk_file=/tmp/hostapd1.psk" >> /nvram/hostapd1.conf
-fi
+ if [ "$(uci get wireless.radio${devidx}.disabled)" == "1" ]; then
+ devidx=$(($devidx + 1))
+ continue
+ fi
-if [ ! -f /nvram/hostapd2.conf ]
-then
- cp /etc/hostapd-bhaul2G.conf /nvram/hostapd2.conf
- #Set bssid for wifi2
- NEW_MAC=$(echo 0x$WIFI0_MAC| awk -F: '{printf "%02x:%s:%s:%s:%s:%s", strtonum($1)+4, $2, $3, $4 ,$5, $6}')
- sed -i "/^bssid=/c\bssid=$NEW_MAC" /nvram/hostapd2.conf
- echo "wpa_psk_file=/tmp/hostapd2.psk" >> /nvram/hostapd2.conf
-fi
+ if [ ! -f /nvram/hostapd"$devidx".conf ]; then
+ touch /nvram/hostapd"$devidx".conf
+ else
+ iw dev wlan$devidx interface add wifi$devidx type __ap
+ touch /tmp/hostapd-acl$devidx
+ touch /tmp/hostapd$devidx.psk
+ hostapd_cli -i global raw ADD bss_config=$dev:/nvram/hostapd"$devidx".conf
+ devidx=$(($devidx + 1))
+ continue
+ fi
-if [ ! -f /nvram/hostapd3.conf ]
-then
- cp /etc/hostapd-bhaul5G.conf /nvram/hostapd3.conf
- #Set bssid for wifi3
- NEW_MAC=$(echo 0x$WIFI1_MAC| awk -F: '{printf "%02x:%s:%s:%s:%s:%s", strtonum($1)+4, $2, $3, $4 ,$5, $6}')
- sed -i "/^bssid=/c\bssid=$NEW_MAC" /nvram/hostapd3.conf
- echo "wpa_psk_file=/tmp/hostapd3.psk" >> /nvram/hostapd3.conf
-fi
-if [ ! -f /nvram/hostapd4.conf ]
-then
- cp /etc/hostapd-bhaul2G.conf /nvram/hostapd4.conf
- #Set bssid for wifi4
- NEW_MAC=$(echo 0x$WIFI0_MAC| awk -F: '{printf "%02x:%s:%s:%s:%s:%s", strtonum($1)+6, $2, $3, $4 ,$5, $6}')
- sed -i "/^bssid=/c\bssid=$NEW_MAC" /nvram/hostapd4.conf
- sed -i "/^interface=/c\interface=wifi4" /nvram/hostapd4.conf
- sed -i "/^accept_mac/c\accept_mac_file=/tmp/hostapd-acl4" /nvram/hostapd4.conf
- echo "wpa_psk_file=/tmp/hostapd4.psk" >> /nvram/hostapd4.conf
-fi
+ if [ "$band" == "2g" ]; then
+ cp -f /etc/hostapd-2G.conf /nvram/hostapd"$devidx".conf
+ fi
-if [ ! -f /nvram/hostapd5.conf ]
-then
- cp /etc/hostapd-bhaul5G.conf /nvram/hostapd5.conf
- #Set bssid for wifi5
- NEW_MAC=$(echo 0x$WIFI1_MAC| awk -F: '{printf "%02x:%s:%s:%s:%s:%s", strtonum($1)+6, $2, $3, $4 ,$5, $6}')
- sed -i "/^bssid=/c\bssid=$NEW_MAC" /nvram/hostapd5.conf
- sed -i "/^interface=/c\interface=wifi5" /nvram/hostapd5.conf
- sed -i "/^accept_mac/c\accept_mac_file=/tmp/hostapd-acl5" /nvram/hostapd5.conf
- echo "wpa_psk_file=/tmp/hostapd5.psk" >> /nvram/hostapd5.conf
-fi
+ if [ "$band" == "5g" ]; then
-if [ ! -f /nvram/hostapd6.conf ]
-then
- cp /etc/hostapd-bhaul2G.conf /nvram/hostapd6.conf
- #Set bssid for wifi6
- NEW_MAC=$(echo 0x$WIFI1_MAC| awk -F: '{printf "%02x:%s:%s:%s:%s:%s", strtonum($1)+8, $2, $3, $4 ,$5, $6}')
- sed -i "/^bssid=/c\bssid=$NEW_MAC" /nvram/hostapd6.conf
- sed -i "/^interface=/c\interface=wifi6" /nvram/hostapd6.conf
- sed -i "/^accept_mac/c\accept_mac_file=/tmp/hostapd-acl6" /nvram/hostapd6.conf
- echo "wpa_psk_file=/tmp/hostapd6.psk" >> /nvram/hostapd6.conf
-fi
+ if [ $chip == "0x7906" ]; then
+ cp -f /etc/hostapd-5G-7916.conf /nvram/hostapd"$devidx".conf
+ elif [ $chip == "0x7915" ]; then
+ cp -f /etc/hostapd-5G-7915.conf /nvram/hostapd"$devidx".conf
+ else
+ cp -f /etc/hostapd-5G.conf /nvram/hostapd"$devidx".conf
+ fi
+ fi
-if [ ! -f /nvram/hostapd7.conf ]
-then
- cp /etc/hostapd-bhaul5G.conf /nvram/hostapd7.conf
- #Set bssid for wifi7
- NEW_MAC=$(echo 0x$WIFI1_MAC| awk -F: '{printf "%02x:%s:%s:%s:%s:%s", strtonum($1)+8, $2, $3, $4 ,$5, $6}')
- sed -i "/^bssid=/c\bssid=$NEW_MAC" /nvram/hostapd7.conf
- sed -i "/^interface=/c\interface=wifi7" /nvram/hostapd7.conf
- sed -i "/^accept_mac/c\accept_mac_file=/tmp/hostapd-acl7" /nvram/hostapd7.conf
- echo "wpa_psk_file=/tmp/hostapd7.psk" >> /nvram/hostapd7.conf
-fi
+ if [ "$band" == "6g" ]; then
+ cp -f /etc/hostapd-6G.conf /nvram/hostapd"$devidx".conf
+ fi
-#Setting up VAP status file
+ sed -i "/^interface=.*/c\interface=wifi$devidx" /nvram/hostapd"$devidx".conf
+ sed -i "/^bssid=/c\bssid=$NEW_MAC" /nvram/hostapd"$devidx".conf
+ echo "wpa_psk_file=/tmp/hostapd$devidx.psk" >> /nvram/hostapd"$devidx".conf
+ iw dev wlan$devidx interface add wifi$devidx type __ap
+ touch /tmp/hostapd-acl$devidx
+ touch /tmp/hostapd$devidx.psk
+ hostapd_cli -i global raw ADD bss_config=$dev:/nvram/hostapd"$devidx".conf
+ devidx=$(($devidx + 1))
+
+ done
+}
echo -e "wifi0=1\nwifi1=1\nwifi2=0\nwifi3=0\nwifi4=0\nwifi5=0\nwifi6=0\nwifi7=0" >/tmp/vap-status
-
#Creating files for tracking AssociatedDevices
touch /tmp/AllAssociated_Devices_2G.txt
touch /tmp/AllAssociated_Devices_5G.txt
-if [ $device_type == "extender" ];
-then
- ifconfig wlan0 down
- ifconfig wlan1 down
- exit 0;
-fi
-
-#Creating virtual interfaces wifi0 and wifi1 for Home APs
-iw dev wlan0 interface add wifi0 type __ap
-iw dev wlan1 interface add wifi1 type __ap
-
-#2.4GHz Virtual Access Points for backhaul connection
-iw dev wlan0 interface add wifi2 type __ap
-ip addr add 169.254.0.1/25 dev wifi2
-ifconfig wifi2 mtu 1600
-
-#5GHz Virtual Access Points for backhaul connection
-iw dev wlan1 interface add wifi3 type __ap
-ip addr add 169.254.1.1/25 dev wifi3
-ifconfig wifi3 mtu 1600
-
-#Creating virtual interfaces wifi4 and wifi5 for Guest APs
-iw dev wlan0 interface add wifi4 type __ap
-iw dev wlan1 interface add wifi5 type __ap
-
-#2.4GHz Virtual Access Points for Secure Onboard connection
-iw dev wlan0 interface add wifi6 type __ap
-ip addr add 169.254.0.129/25 dev wifi6
-ifconfig wifi6 mtu 1600
-
-#5GHz Virtual Access Points for onboard connection
-iw dev wlan1 interface add wifi7 type __ap
-ip addr add 169.254.1.129/25 dev wifi7
-ifconfig wifi7 mtu 1600
-
-#Creating virtual interfaces wifi8 and wifi9 for Service APs
-iw dev wlan0 interface add wifi8 type __ap
-iw dev wlan1 interface add wifi9 type __ap
-
-#Create empty acl list for hostapd
-touch /tmp/hostapd-acl0
-touch /tmp/hostapd-acl1
-touch /tmp/hostapd-acl2
-touch /tmp/hostapd-acl3
-touch /tmp/hostapd-acl4
-touch /tmp/hostapd-acl5
-touch /tmp/hostapd-acl6
-touch /tmp/hostapd-acl7
-touch /tmp/hostapd-acl8
-touch /tmp/hostapd-acl9
-
-#create empty psk files
-touch /tmp/hostapd0.psk
-touch /tmp/hostapd1.psk
-touch /tmp/hostapd2.psk
-touch /tmp/hostapd3.psk
-touch /tmp/hostapd6.psk
-touch /tmp/hostapd7.psk
-touch /tmp/hostapd8.psk
-touch /tmp/hostapd9.psk
-
#Create wps pin request log file
touch /var/run/hostapd_wps_pin_requests.log
-#Setting brlan0 bridge
-if [ ! -d /sys/class/net/brlan0 ]
-then
- brctl addbr brlan0
- ip link set brlan0 address `cat /sys/class/net/eth1/address`
- ifconfig brlan0 10.0.0.1 netmask 255.255.255.0 up
-fi
-
-#Work around for Ethernet connected clients
-if [ ! -d /sys/class/net/lan0 ]
-then
-brctl addif brlan0 eth1
-else
-brctl addif brlan0 lan0
-brctl addif brlan0 lan1
-brctl addif brlan0 lan2
-brctl addif brlan0 lan3
-brctl addif brlan0 lan4
-ifconfig lan0 up
-ifconfig lan1 up
-ifconfig lan2 up
-ifconfig lan3 up
-ifconfig lan4 up
-fi
-ifconfig eth1 up
+create_hostapdConf
-
-#workaround: creating /opt/secure folder for ssh service
-mkdir /opt/secure
-
-exit 0
-
+exit 0
\ No newline at end of file
diff --git a/recipes-connectivity/hostapd/files/hostapd.service b/recipes-connectivity/hostapd/files/hostapd.service
index 7df478f..90d5364 100644
--- a/recipes-connectivity/hostapd/files/hostapd.service
+++ b/recipes-connectivity/hostapd/files/hostapd.service
@@ -5,13 +5,10 @@
[Service]
Type=forking
-ExecStartPre=/bin/sh -c '(/lib/rdk/hostapd-init.sh)'
PIDFile=/var/run/hostapd-global.pid
ExecStart=/usr/sbin/hostapd -g /var/run/hostapd/global -B -P /var/run/hostapd-global.pid
-ExecStartPost=hostapd_cli -i global raw ADD bss_config=phy0:/nvram/hostapd0.conf
-ExecStartPost=hostapd_cli -i global raw ADD bss_config=phy1:/nvram/hostapd1.conf
+ExecStartPost=/bin/sh -c '(/lib/rdk/hostapd-init.sh)'
Restart=always
-
[Install]
WantedBy=multi-user.target
diff --git a/recipes-connectivity/hostapd/files/init-uci-config.service b/recipes-connectivity/hostapd/files/init-uci-config.service
new file mode 100644
index 0000000..54677c8
--- /dev/null
+++ b/recipes-connectivity/hostapd/files/init-uci-config.service
@@ -0,0 +1,14 @@
+[Unit]
+Description=Init UCI wireless config
+DefaultDependencies=no
+Before=hostapd.service
+After=CcspPandMSsp.service
+
+[Service]
+Type=oneshot
+ExecStart=/bin/sh /usr/sbin/mac80211.sh
+RemainAfterExit=yes
+
+[Install]
+WantedBy=multi-user.target
+
diff --git a/recipes-connectivity/hostapd/files/mac80211.sh b/recipes-connectivity/hostapd/files/mac80211.sh
new file mode 100644
index 0000000..b83e7aa
--- /dev/null
+++ b/recipes-connectivity/hostapd/files/mac80211.sh
@@ -0,0 +1,228 @@
+#!/bin/sh
+
+#append DRIVERS "mac80211"
+
+lookup_phy() {
+ [ -n "$phy" ] && {
+ [ -d /sys/class/ieee80211/$phy ] && return
+ }
+
+ local devpath
+ config_get devpath "$device" path
+ [ -n "$devpath" ] && {
+ phy="$(iwinfo nl80211 phyname "path=$devpath")"
+ [ -n "$phy" ] && return
+ }
+
+ local macaddr="$(config_get "$device" macaddr | tr 'A-Z' 'a-z')"
+ [ -n "$macaddr" ] && {
+ for _phy in /sys/class/ieee80211/*; do
+ [ -e "$_phy" ] || continue
+
+ [ "$macaddr" = "$(cat ${_phy}/macaddress)" ] || continue
+ phy="${_phy##*/}"
+ return
+ done
+ }
+ phy=
+ return
+}
+
+find_mac80211_phy() {
+ local device="$1"
+
+ config_get phy "$device" phy
+ lookup_phy
+ [ -n "$phy" -a -d "/sys/class/ieee80211/$phy" ] || {
+ echo "PHY for wifi device $1 not found"
+ return 1
+ }
+ config_set "$device" phy "$phy"
+
+ config_get macaddr "$device" macaddr
+ [ -z "$macaddr" ] && {
+ config_set "$device" macaddr "$(cat /sys/class/ieee80211/${phy}/macaddress)"
+ }
+
+ return 0
+}
+
+check_mac80211_device() {
+ config_get phy "$1" phy
+ [ -z "$phy" ] && {
+ find_mac80211_phy "$1" >/dev/null || return 0
+ config_get phy "$1" phy
+ }
+ [ "$phy" = "$dev" ] && found=1
+}
+
+
+__get_band_defaults() {
+ local phy="$1"
+
+ ( iw phy "$phy" info; echo ) | awk '
+BEGIN {
+ bands = ""
+}
+
+($1 == "Band" || $1 == "") && band {
+ if (channel) {
+ mode="NOHT"
+ if (ht) mode="HT20"
+ if (vht && band != "1:") mode="VHT80"
+ if (he) mode="HE80"
+ if (he && band == "1:") mode="HE20"
+ sub("\\[", "", channel)
+ sub("\\]", "", channel)
+ bands = bands band channel ":" mode " "
+ }
+ band=""
+}
+
+$1 == "Band" {
+ band = $2
+ channel = ""
+ vht = ""
+ ht = ""
+ he = ""
+}
+
+$0 ~ "Capabilities:" {
+ ht=1
+}
+
+$0 ~ "VHT Capabilities" {
+ vht=1
+}
+
+$0 ~ "HE Iftypes" {
+ he=1
+}
+
+$1 == "*" && $3 == "MHz" && $0 !~ /disabled/ && band && !channel {
+ channel = $4
+}
+
+END {
+ print bands
+}'
+}
+
+get_band_defaults() {
+ local phy="$1"
+
+ for c in $(__get_band_defaults "$phy"); do
+ local band="${c%%:*}"
+ c="${c#*:}"
+ local chan="${c%%:*}"
+ c="${c#*:}"
+ local mode="${c%%:*}"
+
+ case "$band" in
+ 1) band=2g;;
+ 2) band=5g;;
+ 3) band=60g;;
+ 4) band=6g;;
+ *) band="";;
+ esac
+
+ [ -n "$band" ] || continue
+ [ -n "$mode_band" -a "$band" = "6g" ] && return
+
+ mode_band="$band"
+ channel="$chan"
+ htmode="$mode"
+ done
+}
+
+detect_mac80211() {
+ devidx=0
+ #config_load wireless
+ while :; do
+ #config_get type "radio$devidx" type
+ [ -n "$type" ] || break
+ devidx=$(($devidx + 1))
+ done
+
+ if [ ! -f /etc/config/wireless ]; then
+ mkdir -p /etc/config
+ echo -n > /etc/config/wireless
+ fi
+
+ pcieCheck="$(uci get wireless.radio1.path)"
+ checkpath="$(realpath /sys/class/ieee80211/phy1/device | cut -d/ -f4-)"
+
+ if [[ "$pcieCheck"* != "$checkpath"* ]]; then
+ echo -n > /etc/config/wireless
+ rm /nvram/hostapd*
+ fi
+
+ old_path=""
+ for _dev in /sys/class/ieee80211/*; do
+ [ -e "$_dev" ] || continue
+
+ dev="${_dev##*/}"
+
+ found="$(uci get wireless.radio${devidx})"
+
+
+ if [ "$found" == "wifi-device" ]; then
+ devidx=$(($devidx + 1))
+ continue
+ fi
+
+ mode_band=""
+ channel=""
+ htmode=""
+ ht_capab=""
+
+
+ get_band_defaults "$dev"
+
+ path="$(realpath /sys/class/ieee80211/"$dev"/device | cut -d/ -f4-)"
+ if [ -n "$path" ]; then
+ if [ "$path" == "$old_path" ]; then
+ dev_id="set wireless.radio${devidx}.path='$path'+1"
+ else
+ dev_id="set wireless.radio${devidx}.path='$path'"
+ fi
+ else
+ dev_id="set wireless.radio${devidx}.macaddr=$(cat /sys/class/ieee80211/${dev}/macaddress)"
+ fi
+
+ if [ "$(cat /sys/class/ieee80211/"$dev"/device/device)" == "0x7906" ]; then
+ isMerlin=1
+ fi
+
+ if [ "$mode_band" = "6g" ]; then
+ channel="37"
+ fi
+ setdisable="set wireless.radio${devidx}.disabled=0"
+
+
+ if [ "$isMerlin" == "1" ] && [ "$devidx" == "2" ] && [ "$mode_band" == "2g" ]; then
+ setdisable="set wireless.radio${devidx}.disabled=1"
+ fi
+
+ uci -q batch <<-EOF
+ set wireless.radio${devidx}=wifi-device
+ set wireless.radio${devidx}.type=mac80211
+ ${dev_id}
+ set wireless.radio${devidx}.channel=${channel}
+ set wireless.radio${devidx}.band=${mode_band}
+ set wireless.radio${devidx}.htmode=$htmode
+ ${setdisable}
+ set wireless.default_radio${devidx}=wifi-iface
+ set wireless.default_radio${devidx}.device=radio${devidx}
+ set wireless.default_radio${devidx}.network=lan
+ set wireless.default_radio${devidx}.mode=ap
+ set wireless.default_radio${devidx}.ssid=Filogic_${mode_band}
+ set wireless.default_radio${devidx}.encryption=none
+EOF
+ uci -q commit wireless
+
+ devidx=$(($devidx + 1))
+ old_path=$path
+ done
+}
+detect_mac80211
\ No newline at end of file