Sync overlay.
This commit is contained in:
@@ -11,17 +11,15 @@ boot() {
|
||||
echo "Reset the Device Name to Factory."
|
||||
mkdir -p /mnt/user/UserSettings/
|
||||
rm /mnt/user/UserSettings/*
|
||||
/usr/local/bin/Device_Name mediaCTRLRenderer.ini mediaCTRLServer.ini SlavePlayer.ini
|
||||
/usr/local/bin/devicename mediaCTRLRenderer.ini mediaCTRLServer.ini SlavePlayer.ini
|
||||
mkdir -p /mnt/user/uci/
|
||||
rm /mnt/user/uci/*
|
||||
fw_setenv is_configured 1
|
||||
fi
|
||||
# Set our device Hostname using the friendlyName
|
||||
friendlyname=`cat /usr/local/configs/mediaCTRLRenderer.ini | grep friendlyname | cut -f2 -d'='`
|
||||
friendlyname=`cat /usr/local/configs/mediaCTRLRenderer.i
|
||||
ni | grep friendlyname | cut -f2 -d'='`
|
||||
mac=`fw_printenv ethaddr | cut -f4-6 -d':' | sed s/://g`
|
||||
hostname $friendlyname-$mac
|
||||
echo Device hostname is `hostname`
|
||||
|
||||
# Temporary Hack
|
||||
#ifconfig lo up
|
||||
#ifconfig eth0 up
|
||||
#udhcpc -i eth0
|
||||
}
|
||||
|
||||
24
bsp/board/domo/ovl/etc/init.d/logd
Normal file
24
bsp/board/domo/ovl/etc/init.d/logd
Normal file
@@ -0,0 +1,24 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
#
|
||||
# Start Log Daemon
|
||||
|
||||
START=20
|
||||
STOP=50
|
||||
|
||||
NAME=logd
|
||||
|
||||
PROG=/usr/sbin/$NAME
|
||||
PIDFILE=/var/run/$NAME.pid
|
||||
|
||||
USE_PROCD=1
|
||||
|
||||
# PROCD_DEBUG=1
|
||||
|
||||
start_service () {
|
||||
|
||||
procd_open_instance
|
||||
procd_set_param command "$PROG"
|
||||
procd_set_param pidfile "$PIDFILE"
|
||||
procd_set_param respawn
|
||||
procd_close_instance
|
||||
}
|
||||
22
bsp/board/domo/ovl/etc/init.d/mountd
Normal file
22
bsp/board/domo/ovl/etc/init.d/mountd
Normal file
@@ -0,0 +1,22 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
|
||||
START=80
|
||||
|
||||
SERVICE_DAEMONIZE=1
|
||||
SERVICE_WRITE_PID=1
|
||||
SERVICE_PID_FILE=/var/run/mountd.pid
|
||||
|
||||
MOUNTD_BIN=/sbin/mountd
|
||||
|
||||
start()
|
||||
{
|
||||
P="$(uci get mountd.mountd.path)"
|
||||
[ -n "$P" -a ! -f "$P" ] && mkdir -p $P
|
||||
|
||||
service_start $MOUNTD_BIN -f
|
||||
}
|
||||
|
||||
stop()
|
||||
{
|
||||
service_stop $MOUNTD_BIN
|
||||
}
|
||||
11
bsp/board/domo/ovl/etc/init.d/usergo
Normal file
11
bsp/board/domo/ovl/etc/init.d/usergo
Normal file
@@ -0,0 +1,11 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
#
|
||||
|
||||
START=11
|
||||
|
||||
boot() {
|
||||
if [ -e "/mnt/user/usergo.sh" ]; then
|
||||
echo "starting user script before launching apps..."
|
||||
/mnt/user/usergo.sh
|
||||
fi
|
||||
}
|
||||
@@ -1,3 +1,6 @@
|
||||
# now run any rc scripts
|
||||
::sysinit:/etc/init.d/rcS S boot
|
||||
# Put a getty on the serial port
|
||||
console::respawn:/sbin/getty -L console 0 vt102 # GENERIC_SERIAL
|
||||
# Stuff to do before rebooting
|
||||
::shutdown:/etc/init.d/rcS K shutdown
|
||||
::respawn:/sbin/getty -L 115200 console vt100
|
||||
|
||||
30
bsp/board/domo/ovl/etc/sysctl.conf
Normal file
30
bsp/board/domo/ovl/etc/sysctl.conf
Normal file
@@ -0,0 +1,30 @@
|
||||
kernel.panic=3
|
||||
kernel.core_pattern=/tmp/%e.%t.%p.%s.core
|
||||
|
||||
net.ipv4.conf.default.arp_ignore=1
|
||||
net.ipv4.conf.all.arp_ignore=1
|
||||
net.ipv4.ip_forward=1
|
||||
net.ipv4.icmp_echo_ignore_broadcasts=1
|
||||
net.ipv4.icmp_ignore_bogus_error_responses=1
|
||||
net.ipv4.igmp_max_memberships=100
|
||||
net.ipv4.tcp_fin_timeout=30
|
||||
net.ipv4.tcp_keepalive_time=120
|
||||
net.ipv4.tcp_syncookies=1
|
||||
net.ipv4.tcp_timestamps=1
|
||||
net.ipv4.tcp_sack=1
|
||||
net.ipv4.tcp_dsack=1
|
||||
|
||||
net.ipv6.conf.default.forwarding=1
|
||||
net.ipv6.conf.all.forwarding=1
|
||||
|
||||
net.netfilter.nf_conntrack_acct=1
|
||||
net.netfilter.nf_conntrack_checksum=0
|
||||
net.netfilter.nf_conntrack_max=16384
|
||||
net.netfilter.nf_conntrack_tcp_timeout_established=7440
|
||||
net.netfilter.nf_conntrack_udp_timeout=60
|
||||
net.netfilter.nf_conntrack_udp_timeout_stream=180
|
||||
|
||||
# disable bridge firewalling by default
|
||||
net.bridge.bridge-nf-call-arptables=0
|
||||
net.bridge.bridge-nf-call-ip6tables=0
|
||||
net.bridge.bridge-nf-call-iptables=0
|
||||
749
bsp/board/domo/ovl/lib/netifd/hostapd.sh
Normal file
749
bsp/board/domo/ovl/lib/netifd/hostapd.sh
Normal file
@@ -0,0 +1,749 @@
|
||||
. /lib/functions/network.sh
|
||||
|
||||
wpa_supplicant_add_rate() {
|
||||
local var="$1"
|
||||
local val="$(($2 / 1000))"
|
||||
local sub="$((($2 / 100) % 10))"
|
||||
append $var "$val" ","
|
||||
[ $sub -gt 0 ] && append $var "."
|
||||
}
|
||||
|
||||
hostapd_add_rate() {
|
||||
local var="$1"
|
||||
local val="$(($2 / 100))"
|
||||
append $var "$val" " "
|
||||
}
|
||||
|
||||
hostapd_append_wep_key() {
|
||||
local var="$1"
|
||||
|
||||
wep_keyidx=0
|
||||
set_default key 1
|
||||
case "$key" in
|
||||
[1234])
|
||||
for idx in 1 2 3 4; do
|
||||
local zidx
|
||||
zidx=$(($idx - 1))
|
||||
json_get_var ckey "key${idx}"
|
||||
[ -n "$ckey" ] && \
|
||||
append $var "wep_key${zidx}=$(prepare_key_wep "$ckey")" "$N$T"
|
||||
done
|
||||
wep_keyidx=$((key - 1))
|
||||
;;
|
||||
*)
|
||||
append $var "wep_key0=$(prepare_key_wep "$key")" "$N$T"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
hostapd_add_log_config() {
|
||||
config_add_boolean \
|
||||
log_80211 \
|
||||
log_8021x \
|
||||
log_radius \
|
||||
log_wpa \
|
||||
log_driver \
|
||||
log_iapp \
|
||||
log_mlme
|
||||
|
||||
config_add_int log_level
|
||||
}
|
||||
|
||||
hostapd_common_add_device_config() {
|
||||
config_add_array basic_rate
|
||||
config_add_array supported_rates
|
||||
|
||||
config_add_string country
|
||||
config_add_boolean country_ie doth
|
||||
config_add_string require_mode
|
||||
|
||||
hostapd_add_log_config
|
||||
}
|
||||
|
||||
hostapd_prepare_device_config() {
|
||||
local config="$1"
|
||||
local driver="$2"
|
||||
|
||||
local base="${config%%.conf}"
|
||||
local base_cfg=
|
||||
|
||||
json_get_vars country country_ie beacon_int doth require_mode
|
||||
|
||||
hostapd_set_log_options base_cfg
|
||||
|
||||
set_default country_ie 1
|
||||
set_default doth 1
|
||||
|
||||
[ -n "$country" ] && {
|
||||
append base_cfg "country_code=$country" "$N"
|
||||
|
||||
[ "$country_ie" -gt 0 ] && append base_cfg "ieee80211d=1" "$N"
|
||||
[ "$hwmode" = "a" -a "$doth" -gt 0 ] && append base_cfg "ieee80211h=1" "$N"
|
||||
}
|
||||
[ -n "$hwmode" ] && append base_cfg "hw_mode=$hwmode" "$N"
|
||||
|
||||
local brlist= br
|
||||
json_get_values basic_rate_list basic_rate
|
||||
for br in $basic_rate_list; do
|
||||
hostapd_add_rate brlist "$br"
|
||||
done
|
||||
case "$require_mode" in
|
||||
g) brlist="60 120 240" ;;
|
||||
n) append base_cfg "require_ht=1" "$N";;
|
||||
ac) append base_cfg "require_vht=1" "$N";;
|
||||
esac
|
||||
|
||||
local rlist= r
|
||||
json_get_values rate_list supported_rates
|
||||
for r in $rate_list; do
|
||||
hostapd_add_rate rlist "$r"
|
||||
done
|
||||
|
||||
[ -n "$rlist" ] && append base_cfg "supported_rates=$rlist" "$N"
|
||||
[ -n "$brlist" ] && append base_cfg "basic_rates=$brlist" "$N"
|
||||
[ -n "$beacon_int" ] && append base_cfg "beacon_int=$beacon_int" "$N"
|
||||
|
||||
cat > "$config" <<EOF
|
||||
driver=$driver
|
||||
$base_cfg
|
||||
EOF
|
||||
}
|
||||
|
||||
hostapd_common_add_bss_config() {
|
||||
config_add_string 'bssid:macaddr' 'ssid:string'
|
||||
config_add_boolean wds wmm uapsd hidden
|
||||
|
||||
config_add_int maxassoc max_inactivity
|
||||
config_add_boolean disassoc_low_ack isolate short_preamble
|
||||
|
||||
config_add_int \
|
||||
wep_rekey eap_reauth_period \
|
||||
wpa_group_rekey wpa_pair_rekey wpa_master_rekey
|
||||
|
||||
config_add_boolean rsn_preauth auth_cache
|
||||
config_add_int ieee80211w
|
||||
config_add_int eapol_version
|
||||
|
||||
config_add_string 'auth_server:host' 'server:host'
|
||||
config_add_string auth_secret
|
||||
config_add_int 'auth_port:port' 'port:port'
|
||||
|
||||
config_add_string acct_server
|
||||
config_add_string acct_secret
|
||||
config_add_int acct_port
|
||||
|
||||
config_add_string dae_client
|
||||
config_add_string dae_secret
|
||||
config_add_int dae_port
|
||||
|
||||
config_add_string nasid
|
||||
config_add_string ownip
|
||||
config_add_string iapp_interface
|
||||
config_add_string eap_type ca_cert client_cert identity anonymous_identity auth priv_key priv_key_pwd
|
||||
|
||||
config_add_int dynamic_vlan vlan_naming
|
||||
config_add_string vlan_tagged_interface vlan_bridge
|
||||
config_add_string vlan_file
|
||||
|
||||
config_add_string 'key1:wepkey' 'key2:wepkey' 'key3:wepkey' 'key4:wepkey' 'password:wpakey'
|
||||
|
||||
config_add_string wpa_psk_file
|
||||
|
||||
config_add_boolean wps_pushbutton wps_label ext_registrar wps_pbc_in_m1
|
||||
config_add_string wps_device_type wps_device_name wps_manufacturer wps_pin
|
||||
|
||||
config_add_boolean ieee80211r pmk_r1_push
|
||||
config_add_int r0_key_lifetime reassociation_deadline
|
||||
config_add_string mobility_domain r1_key_holder
|
||||
config_add_array r0kh r1kh
|
||||
|
||||
config_add_int ieee80211w_max_timeout ieee80211w_retry_timeout
|
||||
|
||||
config_add_string macfilter 'macfile:file'
|
||||
config_add_array 'maclist:list(macaddr)'
|
||||
|
||||
config_add_array bssid_blacklist
|
||||
config_add_array bssid_whitelist
|
||||
|
||||
config_add_int mcast_rate
|
||||
config_add_array basic_rate
|
||||
config_add_array supported_rates
|
||||
}
|
||||
|
||||
hostapd_set_bss_options() {
|
||||
local var="$1"
|
||||
local phy="$2"
|
||||
local vif="$3"
|
||||
|
||||
wireless_vif_parse_encryption
|
||||
|
||||
local bss_conf
|
||||
local wep_rekey wpa_group_rekey wpa_pair_rekey wpa_master_rekey wpa_key_mgmt
|
||||
|
||||
json_get_vars \
|
||||
wep_rekey wpa_group_rekey wpa_pair_rekey wpa_master_rekey \
|
||||
maxassoc max_inactivity disassoc_low_ack isolate auth_cache \
|
||||
wps_pushbutton wps_label ext_registrar wps_pbc_in_m1 \
|
||||
wps_device_type wps_device_name wps_manufacturer wps_pin \
|
||||
macfilter ssid wmm uapsd hidden short_preamble rsn_preauth \
|
||||
iapp_interface eapol_version
|
||||
|
||||
set_default isolate 0
|
||||
set_default maxassoc 0
|
||||
set_default max_inactivity 0
|
||||
set_default short_preamble 1
|
||||
set_default disassoc_low_ack 1
|
||||
set_default hidden 0
|
||||
set_default wmm 1
|
||||
set_default uapsd 1
|
||||
set_default eapol_version 0
|
||||
|
||||
append bss_conf "ctrl_interface=/var/run/hostapd"
|
||||
if [ "$isolate" -gt 0 ]; then
|
||||
append bss_conf "ap_isolate=$isolate" "$N"
|
||||
fi
|
||||
if [ "$maxassoc" -gt 0 ]; then
|
||||
append bss_conf "max_num_sta=$maxassoc" "$N"
|
||||
fi
|
||||
if [ "$max_inactivity" -gt 0 ]; then
|
||||
append bss_conf "ap_max_inactivity=$max_inactivity" "$N"
|
||||
fi
|
||||
|
||||
append bss_conf "disassoc_low_ack=$disassoc_low_ack" "$N"
|
||||
append bss_conf "preamble=$short_preamble" "$N"
|
||||
append bss_conf "wmm_enabled=$wmm" "$N"
|
||||
append bss_conf "ignore_broadcast_ssid=$hidden" "$N"
|
||||
append bss_conf "uapsd_advertisement_enabled=$uapsd" "$N"
|
||||
|
||||
[ "$wpa" -gt 0 ] && {
|
||||
[ -n "$wpa_group_rekey" ] && append bss_conf "wpa_group_rekey=$wpa_group_rekey" "$N"
|
||||
[ -n "$wpa_pair_rekey" ] && append bss_conf "wpa_ptk_rekey=$wpa_pair_rekey" "$N"
|
||||
[ -n "$wpa_master_rekey" ] && append bss_conf "wpa_gmk_rekey=$wpa_master_rekey" "$N"
|
||||
}
|
||||
|
||||
case "$auth_type" in
|
||||
none)
|
||||
wps_possible=1
|
||||
# Here we make the assumption that if we're in open mode
|
||||
# with WPS enabled, we got to be in unconfigured state.
|
||||
wps_not_configured=1
|
||||
;;
|
||||
psk)
|
||||
json_get_vars key wpa_psk_file
|
||||
if [ ${#key} -lt 8 ]; then
|
||||
wireless_setup_vif_failed INVALID_WPA_PSK
|
||||
return 1
|
||||
elif [ ${#key} -eq 64 ]; then
|
||||
append bss_conf "wpa_psk=$key" "$N"
|
||||
else
|
||||
append bss_conf "wpa_passphrase=$key" "$N"
|
||||
fi
|
||||
[ -n "$wpa_psk_file" ] && {
|
||||
[ -e "$wpa_psk_file" ] || touch "$wpa_psk_file"
|
||||
append bss_conf "wpa_psk_file=$wpa_psk_file" "$N"
|
||||
}
|
||||
[ "$eapol_version" -ge "1" -a "$eapol_version" -le "2" ] && append bss_conf "eapol_version=$eapol_version" "$N"
|
||||
|
||||
wps_possible=1
|
||||
append wpa_key_mgmt "WPA-PSK"
|
||||
;;
|
||||
eap)
|
||||
json_get_vars \
|
||||
auth_server auth_secret auth_port \
|
||||
acct_server acct_secret acct_port \
|
||||
dae_client dae_secret dae_port \
|
||||
ownip \
|
||||
eap_reauth_period dynamic_vlan \
|
||||
vlan_naming vlan_tagged_interface \
|
||||
vlan_bridge vlan_file
|
||||
|
||||
# legacy compatibility
|
||||
[ -n "$auth_server" ] || json_get_var auth_server server
|
||||
[ -n "$auth_port" ] || json_get_var auth_port port
|
||||
[ -n "$auth_secret" ] || json_get_var auth_secret key
|
||||
|
||||
set_default auth_port 1812
|
||||
set_default acct_port 1813
|
||||
set_default dae_port 3799
|
||||
|
||||
set_default vlan_naming 1
|
||||
|
||||
append bss_conf "auth_server_addr=$auth_server" "$N"
|
||||
append bss_conf "auth_server_port=$auth_port" "$N"
|
||||
append bss_conf "auth_server_shared_secret=$auth_secret" "$N"
|
||||
|
||||
[ -n "$acct_server" ] && {
|
||||
append bss_conf "acct_server_addr=$acct_server" "$N"
|
||||
append bss_conf "acct_server_port=$acct_port" "$N"
|
||||
[ -n "$acct_secret" ] && \
|
||||
append bss_conf "acct_server_shared_secret=$acct_secret" "$N"
|
||||
}
|
||||
|
||||
[ -n "$eap_reauth_period" ] && append bss_conf "eap_reauth_period=$eap_reauth_period" "$N"
|
||||
|
||||
[ -n "$dae_client" -a -n "$dae_secret" ] && {
|
||||
append bss_conf "radius_das_port=$dae_port" "$N"
|
||||
append bss_conf "radius_das_client=$dae_client $dae_secret" "$N"
|
||||
}
|
||||
|
||||
[ -n "$ownip" ] && append bss_conf "own_ip_addr=$ownip" "$N"
|
||||
append bss_conf "eapol_key_index_workaround=1" "$N"
|
||||
append bss_conf "ieee8021x=1" "$N"
|
||||
append wpa_key_mgmt "WPA-EAP"
|
||||
|
||||
[ -n "$dynamic_vlan" ] && {
|
||||
append bss_conf "dynamic_vlan=$dynamic_vlan" "$N"
|
||||
append bss_conf "vlan_naming=$vlan_naming" "$N"
|
||||
[ -n "$vlan_bridge" ] && \
|
||||
append bss_conf "vlan_bridge=$vlan_bridge" "$N"
|
||||
[ -n "$vlan_tagged_interface" ] && \
|
||||
append bss_conf "vlan_tagged_interface=$vlan_tagged_interface" "$N"
|
||||
[ -n "$vlan_file" ] && {
|
||||
[ -e "$vlan_file" ] || touch "$vlan_file"
|
||||
append bss_conf "vlan_file=$vlan_file" "$N"
|
||||
}
|
||||
}
|
||||
|
||||
[ "$eapol_version" -ge "1" -a "$eapol_version" -le "2" ] && append bss_conf "eapol_version=$eapol_version" "$N"
|
||||
;;
|
||||
wep)
|
||||
local wep_keyidx=0
|
||||
json_get_vars key
|
||||
hostapd_append_wep_key bss_conf
|
||||
append bss_conf "wep_default_key=$wep_keyidx" "$N"
|
||||
[ -n "$wep_rekey" ] && append bss_conf "wep_rekey_period=$wep_rekey" "$N"
|
||||
;;
|
||||
esac
|
||||
|
||||
local auth_algs=$((($auth_mode_shared << 1) | $auth_mode_open))
|
||||
append bss_conf "auth_algs=${auth_algs:-1}" "$N"
|
||||
append bss_conf "wpa=$wpa" "$N"
|
||||
[ -n "$wpa_pairwise" ] && append bss_conf "wpa_pairwise=$wpa_pairwise" "$N"
|
||||
|
||||
set_default wps_pushbutton 0
|
||||
set_default wps_label 0
|
||||
set_default wps_pbc_in_m1 0
|
||||
|
||||
config_methods=
|
||||
[ "$wps_pushbutton" -gt 0 ] && append config_methods push_button
|
||||
[ "$wps_label" -gt 0 ] && append config_methods label
|
||||
|
||||
[ -n "$wps_possible" -a -n "$config_methods" ] && {
|
||||
set_default ext_registrar 0
|
||||
set_default wps_device_type "6-0050F204-1"
|
||||
set_default wps_device_name "OpenWrt AP"
|
||||
set_default wps_manufacturer "openwrt.org"
|
||||
|
||||
wps_state=2
|
||||
[ -n "$wps_configured" ] && wps_state=1
|
||||
|
||||
[ "$ext_registrar" -gt 0 -a -n "$network_bridge" ] && append bss_conf "upnp_iface=$network_bridge" "$N"
|
||||
|
||||
append bss_conf "eap_server=1" "$N"
|
||||
[ -n "$wps_pin" ] && append bss_conf "ap_pin=$wps_pin" "$N"
|
||||
append bss_conf "wps_state=$wps_state" "$N"
|
||||
append bss_conf "ap_setup_locked=0" "$N"
|
||||
append bss_conf "device_type=$wps_device_type" "$N"
|
||||
append bss_conf "device_name=$wps_device_name" "$N"
|
||||
append bss_conf "manufacturer=$wps_manufacturer" "$N"
|
||||
append bss_conf "config_methods=$config_methods" "$N"
|
||||
[ "$wps_pbc_in_m1" -gt 0 ] && append bss_conf "pbc_in_m1=$wps_pbc_in_m1" "$N"
|
||||
}
|
||||
|
||||
append bss_conf "ssid=$ssid" "$N"
|
||||
[ -n "$network_bridge" ] && append bss_conf "bridge=$network_bridge" "$N"
|
||||
[ -n "$iapp_interface" ] && {
|
||||
local ifname
|
||||
network_get_device ifname "$iapp_interface" || ifname = "$iapp_interface"
|
||||
append bss_conf "iapp_interface=$ifname" "$N"
|
||||
}
|
||||
|
||||
if [ "$wpa" -ge "1" ]; then
|
||||
json_get_vars nasid ieee80211r
|
||||
set_default ieee80211r 0
|
||||
[ -n "$nasid" ] && append bss_conf "nas_identifier=$nasid" "$N"
|
||||
|
||||
if [ "$ieee80211r" -gt "0" ]; then
|
||||
json_get_vars mobility_domain r0_key_lifetime r1_key_holder \
|
||||
reassociation_deadline pmk_r1_push
|
||||
json_get_values r0kh r0kh
|
||||
json_get_values r1kh r1kh
|
||||
|
||||
set_default mobility_domain "4f57"
|
||||
set_default r0_key_lifetime 10000
|
||||
set_default r1_key_holder "00004f577274"
|
||||
set_default reassociation_deadline 1000
|
||||
set_default pmk_r1_push 0
|
||||
|
||||
append bss_conf "mobility_domain=$mobility_domain" "$N"
|
||||
append bss_conf "r0_key_lifetime=$r0_key_lifetime" "$N"
|
||||
append bss_conf "r1_key_holder=$r1_key_holder" "$N"
|
||||
append bss_conf "reassociation_deadline=$reassociation_deadline" "$N"
|
||||
append bss_conf "pmk_r1_push=$pmk_r1_push" "$N"
|
||||
|
||||
for kh in $r0kh; do
|
||||
append bss_conf "r0kh=${kh//,/ }" "$N"
|
||||
done
|
||||
for kh in $r1kh; do
|
||||
append bss_conf "r1kh=${kh//,/ }" "$N"
|
||||
done
|
||||
|
||||
[ "$wpa_key_mgmt" != "${wpa_key_mgmt/EAP/}" ] && append wpa_key_mgmt "FT-EAP"
|
||||
[ "$wpa_key_mgmt" != "${wpa_key_mgmt/PSK/}" ] && append wpa_key_mgmt "FT-PSK"
|
||||
fi
|
||||
|
||||
[ -n "$wpa_key_mgmt" ] && append bss_conf "wpa_key_mgmt=$wpa_key_mgmt" "$N"
|
||||
fi
|
||||
|
||||
if [ "$wpa" -ge "2" ]; then
|
||||
if [ -n "$network_bridge" -a "$rsn_preauth" = 1 ]; then
|
||||
set_default auth_cache 1
|
||||
append bss_conf "rsn_preauth=1" "$N"
|
||||
append bss_conf "rsn_preauth_interfaces=$network_bridge" "$N"
|
||||
else
|
||||
set_default auth_cache 0
|
||||
fi
|
||||
|
||||
append bss_conf "okc=$auth_cache" "$N"
|
||||
[ "$auth_cache" = 0 ] && append bss_conf "disable_pmksa_caching=1" "$N"
|
||||
|
||||
# RSN -> allow management frame protection
|
||||
json_get_var ieee80211w ieee80211w
|
||||
case "$ieee80211w" in
|
||||
[012])
|
||||
json_get_vars ieee80211w_max_timeout ieee80211w_retry_timeout
|
||||
append bss_conf "ieee80211w=$ieee80211w" "$N"
|
||||
[ "$ieee80211w" -gt "0" ] && {
|
||||
[ -n "$ieee80211w_max_timeout" ] && \
|
||||
append bss_conf "assoc_sa_query_max_timeout=$ieee80211w_max_timeout" "$N"
|
||||
[ -n "$ieee80211w_retry_timeout" ] && \
|
||||
append bss_conf "assoc_sa_query_retry_timeout=$ieee80211w_retry_timeout" "$N"
|
||||
}
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
_macfile="/var/run/hostapd-$ifname.maclist"
|
||||
case "$macfilter" in
|
||||
allow)
|
||||
append bss_conf "macaddr_acl=1" "$N"
|
||||
append bss_conf "accept_mac_file=$_macfile" "$N"
|
||||
;;
|
||||
deny)
|
||||
append bss_conf "macaddr_acl=0" "$N"
|
||||
append bss_conf "deny_mac_file=$_macfile" "$N"
|
||||
;;
|
||||
*)
|
||||
_macfile=""
|
||||
;;
|
||||
esac
|
||||
|
||||
[ -n "$_macfile" ] && {
|
||||
json_get_vars macfile
|
||||
json_get_values maclist maclist
|
||||
|
||||
rm -f "$_macfile"
|
||||
(
|
||||
for mac in $maclist; do
|
||||
echo "$mac"
|
||||
done
|
||||
[ -n "$macfile" -a -f "$macfile" ] && cat "$macfile"
|
||||
) > "$_macfile"
|
||||
}
|
||||
|
||||
append "$var" "$bss_conf" "$N"
|
||||
return 0
|
||||
}
|
||||
|
||||
hostapd_set_log_options() {
|
||||
local var="$1"
|
||||
|
||||
local log_level log_80211 log_8021x log_radius log_wpa log_driver log_iapp log_mlme
|
||||
json_get_vars log_level log_80211 log_8021x log_radius log_wpa log_driver log_iapp log_mlme
|
||||
|
||||
set_default log_level 2
|
||||
set_default log_80211 1
|
||||
set_default log_8021x 1
|
||||
set_default log_radius 1
|
||||
set_default log_wpa 1
|
||||
set_default log_driver 1
|
||||
set_default log_iapp 1
|
||||
set_default log_mlme 1
|
||||
|
||||
local log_mask=$(( \
|
||||
($log_80211 << 0) | \
|
||||
($log_8021x << 1) | \
|
||||
($log_radius << 2) | \
|
||||
($log_wpa << 3) | \
|
||||
($log_driver << 4) | \
|
||||
($log_iapp << 5) | \
|
||||
($log_mlme << 6) \
|
||||
))
|
||||
|
||||
append "$var" "logger_syslog=$log_mask" "$N"
|
||||
append "$var" "logger_syslog_level=$log_level" "$N"
|
||||
append "$var" "logger_stdout=$log_mask" "$N"
|
||||
append "$var" "logger_stdout_level=$log_level" "$N"
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
_wpa_supplicant_common() {
|
||||
local ifname="$1"
|
||||
|
||||
_rpath="/var/run/wpa_supplicant"
|
||||
_config="${_rpath}-$ifname.conf"
|
||||
}
|
||||
|
||||
wpa_supplicant_teardown_interface() {
|
||||
_wpa_supplicant_common "$1"
|
||||
rm -rf "$_rpath/$1" "$_config"
|
||||
}
|
||||
|
||||
wpa_supplicant_prepare_interface() {
|
||||
local ifname="$1"
|
||||
_w_driver="$2"
|
||||
|
||||
_wpa_supplicant_common "$1"
|
||||
|
||||
json_get_vars mode wds
|
||||
|
||||
[ -n "$network_bridge" ] && {
|
||||
fail=
|
||||
case "$mode" in
|
||||
adhoc)
|
||||
fail=1
|
||||
;;
|
||||
sta)
|
||||
[ "$wds" = 1 ] || fail=1
|
||||
;;
|
||||
esac
|
||||
|
||||
[ -n "$fail" ] && {
|
||||
wireless_setup_vif_failed BRIDGE_NOT_ALLOWED
|
||||
return 1
|
||||
}
|
||||
}
|
||||
|
||||
local ap_scan=
|
||||
|
||||
_w_mode="$mode"
|
||||
_w_modestr=
|
||||
|
||||
[[ "$mode" = adhoc ]] && {
|
||||
ap_scan="ap_scan=2"
|
||||
|
||||
_w_modestr="mode=1"
|
||||
}
|
||||
|
||||
local country_str=
|
||||
[ -n "$country" ] && {
|
||||
country_str="country=$country"
|
||||
}
|
||||
|
||||
wpa_supplicant_teardown_interface "$ifname"
|
||||
cat > "$_config" <<EOF
|
||||
$ap_scan
|
||||
$country_str
|
||||
EOF
|
||||
return 0
|
||||
}
|
||||
|
||||
wpa_supplicant_add_network() {
|
||||
local ifname="$1"
|
||||
|
||||
_wpa_supplicant_common "$1"
|
||||
wireless_vif_parse_encryption
|
||||
|
||||
json_get_vars \
|
||||
ssid bssid key \
|
||||
basic_rate mcast_rate \
|
||||
ieee80211w ieee80211r
|
||||
|
||||
set_default ieee80211r 0
|
||||
|
||||
local key_mgmt='NONE'
|
||||
local enc_str=
|
||||
local network_data=
|
||||
local T=" "
|
||||
|
||||
local wpa_key_mgmt="WPA-PSK"
|
||||
local scan_ssid="scan_ssid=1"
|
||||
local freq
|
||||
|
||||
[ "$ieee80211r" -gt 0 ] && wpa_key_mgmt="FT-PSK $wpa_key_mgmt"
|
||||
|
||||
[[ "$_w_mode" = "adhoc" ]] && {
|
||||
append network_data "mode=1" "$N$T"
|
||||
[ -n "$channel" ] && {
|
||||
freq="$(get_freq "$phy" "$channel")"
|
||||
append network_data "fixed_freq=1" "$N$T"
|
||||
append network_data "frequency=$freq" "$N$T"
|
||||
}
|
||||
|
||||
scan_ssid="scan_ssid=0"
|
||||
|
||||
[ "$_w_driver" = "nl80211" ] || wpa_key_mgmt="WPA-NONE"
|
||||
}
|
||||
|
||||
[[ "$_w_mode" = "mesh" ]] && {
|
||||
json_get_vars mesh_id
|
||||
ssid="${mesh_id}"
|
||||
|
||||
append network_data "mode=5" "$N$T"
|
||||
[ -n "$channel" ] && {
|
||||
freq="$(get_freq "$phy" "$channel")"
|
||||
append network_data "frequency=$freq" "$N$T"
|
||||
}
|
||||
wpa_key_mgmt="SAE"
|
||||
scan_ssid=""
|
||||
}
|
||||
|
||||
[[ "$_w_mode" = "adhoc" -o "$_w_mode" = "mesh" ]] && append network_data "$_w_modestr" "$N$T"
|
||||
|
||||
case "$auth_type" in
|
||||
none) ;;
|
||||
wep)
|
||||
local wep_keyidx=0
|
||||
hostapd_append_wep_key network_data
|
||||
append network_data "wep_tx_keyidx=$wep_keyidx" "$N$T"
|
||||
;;
|
||||
psk)
|
||||
local passphrase
|
||||
|
||||
key_mgmt="$wpa_key_mgmt"
|
||||
if [ ${#key} -eq 64 ]; then
|
||||
passphrase="psk=${key}"
|
||||
else
|
||||
passphrase="psk=\"${key}\""
|
||||
fi
|
||||
append network_data "$passphrase" "$N$T"
|
||||
;;
|
||||
eap)
|
||||
key_mgmt='WPA-EAP'
|
||||
[ "$ieee80211r" -gt 0 ] && key_mgmt="FT-EAP $key_mgmt"
|
||||
|
||||
json_get_vars eap_type identity anonymous_identity ca_cert
|
||||
[ -n "$ca_cert" ] && append network_data "ca_cert=\"$ca_cert\"" "$N$T"
|
||||
[ -n "$identity" ] && append network_data "identity=\"$identity\"" "$N$T"
|
||||
[ -n "$anonymous_identity" ] && append network_data "anonymous_identity=\"$anonymous_identity\"" "$N$T"
|
||||
case "$eap_type" in
|
||||
tls)
|
||||
json_get_vars client_cert priv_key priv_key_pwd
|
||||
append network_data "client_cert=\"$client_cert\"" "$N$T"
|
||||
append network_data "private_key=\"$priv_key\"" "$N$T"
|
||||
append network_data "private_key_passwd=\"$priv_key_pwd\"" "$N$T"
|
||||
;;
|
||||
fast|peap|ttls)
|
||||
json_get_vars auth password ca_cert2 client_cert2 priv_key2 priv_key2_pwd
|
||||
set_default auth MSCHAPV2
|
||||
|
||||
if [ "$auth" = "EAP-TLS" ]; then
|
||||
[ -n "$ca_cert2" ] &&
|
||||
append network_data "ca_cert2=\"$ca_cert2\"" "$N$T"
|
||||
append network_data "client_cert2=\"$client_cert2\"" "$N$T"
|
||||
append network_data "private_key2=\"$priv_key2\"" "$N$T"
|
||||
append network_data "private_key2_passwd=\"$priv_key2_pwd\"" "$N$T"
|
||||
else
|
||||
append network_data "password=\"$password\"" "$N$T"
|
||||
fi
|
||||
|
||||
phase2proto="auth="
|
||||
case "$auth" in
|
||||
"auth"*)
|
||||
phase2proto=""
|
||||
;;
|
||||
"EAP-"*)
|
||||
auth="$(echo $auth | cut -b 5- )"
|
||||
[ "$eap_type" = "ttls" ] &&
|
||||
phase2proto="autheap="
|
||||
;;
|
||||
esac
|
||||
append network_data "phase2=\"$phase2proto$auth\"" "$N$T"
|
||||
;;
|
||||
esac
|
||||
append network_data "eap=$(echo $eap_type | tr 'a-z' 'A-Z')" "$N$T"
|
||||
;;
|
||||
esac
|
||||
|
||||
[ "$mode" = mesh ] || {
|
||||
case "$wpa" in
|
||||
1)
|
||||
append network_data "proto=WPA" "$N$T"
|
||||
;;
|
||||
2)
|
||||
append network_data "proto=RSN" "$N$T"
|
||||
;;
|
||||
esac
|
||||
|
||||
case "$ieee80211w" in
|
||||
[012])
|
||||
[ "$wpa" -ge 2 ] && append network_data "ieee80211w=$ieee80211w" "$N$T"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
local beacon_int brates mrate
|
||||
[ -n "$bssid" ] && append network_data "bssid=$bssid" "$N$T"
|
||||
[ -n "$beacon_int" ] && append network_data "beacon_int=$beacon_int" "$N$T"
|
||||
|
||||
local bssid_blacklist bssid_whitelist
|
||||
json_get_values bssid_blacklist bssid_blacklist
|
||||
json_get_values bssid_whitelist bssid_whitelist
|
||||
|
||||
[ -n "$bssid_blacklist" ] && append network_data "bssid_blacklist=$bssid_blacklist" "$N$T"
|
||||
[ -n "$bssid_whitelist" ] && append network_data "bssid_whitelist=$bssid_whitelist" "$N$T"
|
||||
|
||||
[ -n "$basic_rate" ] && {
|
||||
local br rate_list=
|
||||
for br in $basic_rate; do
|
||||
wpa_supplicant_add_rate rate_list "$br"
|
||||
done
|
||||
[ -n "$rate_list" ] && append network_data "rates=$rate_list" "$N$T"
|
||||
}
|
||||
|
||||
[ -n "$mcast_rate" ] && {
|
||||
local mc_rate=
|
||||
wpa_supplicant_add_rate mc_rate "$mcast_rate"
|
||||
append network_data "mcast_rate=$mc_rate" "$N$T"
|
||||
}
|
||||
|
||||
local ht_str
|
||||
[[ "$_w_mode" = adhoc ]] || ibss_htmode=
|
||||
[ -n "$ibss_htmode" ] && append network_data "htmode=$ibss_htmode" "$N$T"
|
||||
|
||||
cat >> "$_config" <<EOF
|
||||
network={
|
||||
$scan_ssid
|
||||
ssid="$ssid"
|
||||
key_mgmt=$key_mgmt
|
||||
$network_data
|
||||
}
|
||||
EOF
|
||||
return 0
|
||||
}
|
||||
|
||||
wpa_supplicant_run() {
|
||||
local ifname="$1"; shift
|
||||
|
||||
_wpa_supplicant_common "$ifname"
|
||||
|
||||
/usr/sbin/wpa_supplicant -B \
|
||||
${network_bridge:+-b $network_bridge} \
|
||||
-P "/var/run/wpa_supplicant-${ifname}.pid" \
|
||||
-D ${_w_driver:-wext} \
|
||||
-i "$ifname" \
|
||||
-c "$_config" \
|
||||
-C "$_rpath" \
|
||||
"$@"
|
||||
|
||||
ret="$?"
|
||||
wireless_add_process "$(cat "/var/run/wpa_supplicant-${ifname}.pid")" /usr/sbin/wpa_supplicant 1
|
||||
|
||||
[ "$ret" != 0 ] && wireless_setup_vif_failed WPA_SUPPLICANT_FAILED
|
||||
|
||||
return $ret
|
||||
}
|
||||
|
||||
hostapd_common_cleanup() {
|
||||
killall hostapd wpa_supplicant meshd-nl80211
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
NETIFD_MAIN_DIR="${NETIFD_MAIN_DIR:-/lib/netifd}"
|
||||
PROTO_DEFAULT_OPTIONS="defaultroute peerdns metric"
|
||||
|
||||
. /usr/share/libubox/jshn.sh
|
||||
. $NETIFD_MAIN_DIR/utils.sh
|
||||
@@ -15,6 +16,18 @@ proto_config_add_boolean() {
|
||||
config_add_boolean "$@"
|
||||
}
|
||||
|
||||
proto_config_add_defaults() {
|
||||
proto_config_add_boolean "defaultroute"
|
||||
proto_config_add_boolean "peerdns"
|
||||
proto_config_add_int "metric"
|
||||
}
|
||||
|
||||
proto_add_dynamic_defaults() {
|
||||
[ -n "$defaultroute" ] && json_add_boolean defaultroute "$defaultroute"
|
||||
[ -n "$peerdns" ] && json_add_boolean peerdns "$peerdns"
|
||||
[ -n "$metric" ] && json_add_int metric "$metric"
|
||||
}
|
||||
|
||||
_proto_do_teardown() {
|
||||
json_load "$data"
|
||||
eval "proto_$1_teardown \"$interface\" \"$ifname\""
|
||||
@@ -365,6 +378,7 @@ init_proto() {
|
||||
no_proto_task=0
|
||||
available=0
|
||||
renew_handler=0
|
||||
teardown_on_l3_link_down=0
|
||||
|
||||
add_default_handler "proto_$1_init_config"
|
||||
|
||||
@@ -378,6 +392,7 @@ init_proto() {
|
||||
json_add_boolean available "$available"
|
||||
json_add_boolean renew-handler "$renew_handler"
|
||||
json_add_boolean lasterror "$lasterror"
|
||||
json_add_boolean teardown-on-l3-link-down "$teardown_on_l3_link_down"
|
||||
json_dump
|
||||
}
|
||||
;;
|
||||
|
||||
@@ -21,14 +21,15 @@ proto_dhcp_init_config() {
|
||||
proto_config_add_string zone
|
||||
proto_config_add_string mtu6rd
|
||||
proto_config_add_string customroutes
|
||||
proto_config_add_boolean classlessroute
|
||||
}
|
||||
|
||||
proto_dhcp_setup() {
|
||||
local config="$1"
|
||||
local iface="$2"
|
||||
|
||||
local ipaddr hostname clientid vendorid broadcast release reqopts iface6rd sendopts delegate zone6rd zone mtu6rd customroutes
|
||||
json_get_vars ipaddr hostname clientid vendorid broadcast release reqopts iface6rd sendopts delegate zone6rd zone mtu6rd customroutes
|
||||
local ipaddr hostname clientid vendorid broadcast release reqopts iface6rd sendopts delegate zone6rd zone mtu6rd customroutes classlessroute
|
||||
json_get_vars ipaddr hostname clientid vendorid broadcast release reqopts iface6rd sendopts delegate zone6rd zone mtu6rd customroutes classlessroute
|
||||
|
||||
local opt dhcpopts
|
||||
for opt in $reqopts; do
|
||||
@@ -49,6 +50,8 @@ proto_dhcp_setup() {
|
||||
[ -n "$mtu6rd" ] && proto_export "MTU6RD=$mtu6rd"
|
||||
[ -n "$customroutes" ] && proto_export "CUSTOMROUTES=$customroutes"
|
||||
[ "$delegate" = "0" ] && proto_export "IFACE6RD_DELEGATE=0"
|
||||
# Request classless route option (see RFC 3442) by default
|
||||
[ "$classlessroute" = "0" ] || append dhcpopts "-O 121"
|
||||
|
||||
proto_export "INTERFACE=$config"
|
||||
proto_run_command "$config" udhcpc \
|
||||
|
||||
@@ -1,66 +1,758 @@
|
||||
#!/bin/sh
|
||||
NETIFD_MAIN_DIR=../
|
||||
. $NETIFD_MAIN_DIR/netifd-wireless.sh
|
||||
. /lib/netifd/netifd-wireless.sh
|
||||
. /lib/netifd/hostapd.sh
|
||||
|
||||
init_wireless_driver "$@"
|
||||
|
||||
MP_CONFIG_INT="mesh_retry_timeout mesh_confirm_timeout mesh_holding_timeout mesh_max_peer_links
|
||||
mesh_max_retries mesh_ttl mesh_element_ttl mesh_hwmp_max_preq_retries
|
||||
mesh_path_refresh_time mesh_min_discovery_timeout mesh_hwmp_active_path_timeout
|
||||
mesh_hwmp_preq_min_interval mesh_hwmp_net_diameter_traversal_time mesh_hwmp_rootmode
|
||||
mesh_hwmp_rann_interval mesh_gate_announcements mesh_sync_offset_max_neighor
|
||||
mesh_rssi_threshold mesh_hwmp_active_path_to_root_timeout mesh_hwmp_root_interval
|
||||
mesh_hwmp_confirmation_interval mesh_awake_window mesh_plink_timeout"
|
||||
MP_CONFIG_BOOL="mesh_auto_open_plinks mesh_fwding"
|
||||
MP_CONFIG_STRING="mesh_power_mode"
|
||||
|
||||
drv_mac80211_init_device_config() {
|
||||
# identifiers
|
||||
config_add_string macaddr
|
||||
config_add_string path
|
||||
config_add_string phy
|
||||
hostapd_common_add_device_config
|
||||
|
||||
# config
|
||||
config_add_int channel
|
||||
config_add_string path phy 'macaddr:macaddr'
|
||||
config_add_string hwmode
|
||||
config_add_int beacon_int chanbw frag rts
|
||||
config_add_int rxantenna txantenna antenna_gain txpower distance
|
||||
config_add_boolean noscan ht_coex
|
||||
config_add_array ht_capab
|
||||
|
||||
config_add_int chanbw
|
||||
config_add_array channels
|
||||
config_add_boolean \
|
||||
rxldpc \
|
||||
short_gi_80 \
|
||||
short_gi_160 \
|
||||
tx_stbc_2by1 \
|
||||
su_beamformer \
|
||||
su_beamformee \
|
||||
mu_beamformer \
|
||||
mu_beamformee \
|
||||
vht_txop_ps \
|
||||
htc_vht \
|
||||
rx_antenna_pattern \
|
||||
tx_antenna_pattern
|
||||
config_add_int vht_max_a_mpdu_len_exp vht_max_mpdu vht_link_adapt vht160 rx_stbc tx_stbc
|
||||
config_add_boolean \
|
||||
ldpc \
|
||||
greenfield \
|
||||
short_gi_20 \
|
||||
short_gi_40 \
|
||||
max_amsdu \
|
||||
dsss_cck_40
|
||||
}
|
||||
|
||||
drv_mac80211_init_iface_config() {
|
||||
config_add_string macaddr
|
||||
hostapd_common_add_bss_config
|
||||
|
||||
config_add_boolean wds
|
||||
config_add_string 'macaddr:macaddr' ifname
|
||||
|
||||
config_add_boolean wds powersave
|
||||
config_add_int maxassoc
|
||||
config_add_int dtim_period
|
||||
|
||||
config_add_int max_listen_int
|
||||
config_add_int dtim_period
|
||||
config_add_int start_disabled
|
||||
|
||||
config_add_boolean hidden
|
||||
config_add_boolean wmm
|
||||
# mesh
|
||||
config_add_string mesh_id
|
||||
config_add_int $MP_CONFIG_INT
|
||||
config_add_boolean $MP_CONFIG_BOOL
|
||||
config_add_string $MP_CONFIG_STRING
|
||||
}
|
||||
|
||||
setup_vif() {
|
||||
local name="$1"
|
||||
mac80211_add_capabilities() {
|
||||
local __var="$1"; shift
|
||||
local __mask="$1"; shift
|
||||
local __out= oifs
|
||||
|
||||
oifs="$IFS"
|
||||
IFS=:
|
||||
for capab in "$@"; do
|
||||
set -- $capab
|
||||
|
||||
[ "$(($4))" -gt 0 ] || continue
|
||||
[ "$(($__mask & $2))" -eq "$((${3:-$2}))" ] || continue
|
||||
__out="$__out[$1]"
|
||||
done
|
||||
IFS="$oifs"
|
||||
|
||||
export -n -- "$__var=$__out"
|
||||
}
|
||||
|
||||
mac80211_hostapd_setup_base() {
|
||||
local phy="$1"
|
||||
|
||||
json_select config
|
||||
json_get_var ssid ssid
|
||||
|
||||
[ "$auto_channel" -gt 0 ] && channel=acs_survey
|
||||
[ "$auto_channel" -gt 0 ] && json_get_values channel_list channels
|
||||
|
||||
json_get_vars noscan ht_coex
|
||||
json_get_values ht_capab_list ht_capab
|
||||
|
||||
ieee80211n=1
|
||||
ht_capab=
|
||||
case "$htmode" in
|
||||
VHT20|HT20) ;;
|
||||
HT40*|VHT40|VHT80|VHT160)
|
||||
case "$hwmode" in
|
||||
a)
|
||||
case "$(( ($channel / 4) % 2 ))" in
|
||||
1) ht_capab="[HT40+]";;
|
||||
0) ht_capab="[HT40-]";;
|
||||
esac
|
||||
;;
|
||||
*)
|
||||
case "$htmode" in
|
||||
HT40+) ht_capab="[HT40+]";;
|
||||
HT40-) ht_capab="[HT40-]";;
|
||||
*)
|
||||
if [ "$channel" -lt 7 ]; then
|
||||
ht_capab="[HT40+]"
|
||||
else
|
||||
ht_capab="[HT40-]"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
[ "$auto_channel" -gt 0 ] && ht_capab="[HT40+]"
|
||||
;;
|
||||
*) ieee80211n= ;;
|
||||
esac
|
||||
|
||||
[ -n "$ieee80211n" ] && {
|
||||
append base_cfg "ieee80211n=1" "$N"
|
||||
|
||||
set_default ht_coex 0
|
||||
append base_cfg "ht_coex=$ht_coex" "$N"
|
||||
|
||||
json_get_vars \
|
||||
ldpc:1 \
|
||||
greenfield:0 \
|
||||
short_gi_20:1 \
|
||||
short_gi_40:1 \
|
||||
tx_stbc:1 \
|
||||
rx_stbc:3 \
|
||||
max_amsdu:1 \
|
||||
dsss_cck_40:1
|
||||
|
||||
ht_cap_mask=0
|
||||
for cap in $(iw phy "$phy" info | grep 'Capabilities:' | cut -d: -f2); do
|
||||
ht_cap_mask="$(($ht_cap_mask | $cap))"
|
||||
done
|
||||
|
||||
cap_rx_stbc=$((($ht_cap_mask >> 8) & 3))
|
||||
[ "$rx_stbc" -lt "$cap_rx_stbc" ] && cap_rx_stbc="$rx_stbc"
|
||||
ht_cap_mask="$(( ($ht_cap_mask & ~(0x300)) | ($cap_rx_stbc << 8) ))"
|
||||
|
||||
mac80211_add_capabilities ht_capab_flags $ht_cap_mask \
|
||||
LDPC:0x1::$ldpc \
|
||||
GF:0x10::$greenfield \
|
||||
SHORT-GI-20:0x20::$short_gi_20 \
|
||||
SHORT-GI-40:0x40::$short_gi_40 \
|
||||
TX-STBC:0x80::$tx_stbc \
|
||||
RX-STBC1:0x300:0x100:1 \
|
||||
RX-STBC12:0x300:0x200:1 \
|
||||
RX-STBC123:0x300:0x300:1 \
|
||||
MAX-AMSDU-7935:0x800::$max_amsdu \
|
||||
DSSS_CCK-40:0x1000::$dsss_cck_40
|
||||
|
||||
ht_capab="$ht_capab$ht_capab_flags"
|
||||
[ -n "$ht_capab" ] && append base_cfg "ht_capab=$ht_capab" "$N"
|
||||
}
|
||||
|
||||
# 802.11ac
|
||||
enable_ac=0
|
||||
idx="$channel"
|
||||
case "$htmode" in
|
||||
VHT20) enable_ac=1;;
|
||||
VHT40)
|
||||
case "$(( ($channel / 4) % 2 ))" in
|
||||
1) idx=$(($channel + 2));;
|
||||
0) idx=$(($channel - 2));;
|
||||
esac
|
||||
enable_ac=1
|
||||
append base_cfg "vht_oper_chwidth=0" "$N"
|
||||
append base_cfg "vht_oper_centr_freq_seg0_idx=$idx" "$N"
|
||||
;;
|
||||
VHT80)
|
||||
case "$(( ($channel / 4) % 4 ))" in
|
||||
1) idx=$(($channel + 6));;
|
||||
2) idx=$(($channel + 2));;
|
||||
3) idx=$(($channel - 2));;
|
||||
0) idx=$(($channel - 6));;
|
||||
esac
|
||||
enable_ac=1
|
||||
append base_cfg "vht_oper_chwidth=1" "$N"
|
||||
append base_cfg "vht_oper_centr_freq_seg0_idx=$idx" "$N"
|
||||
;;
|
||||
VHT160)
|
||||
case "$channel" in
|
||||
36|40|44|48|52|56|60|64) idx=50;;
|
||||
100|104|108|112|116|120|124|128) idx=114;;
|
||||
esac
|
||||
enable_ac=1
|
||||
append base_cfg "vht_oper_chwidth=2" "$N"
|
||||
append base_cfg "vht_oper_centr_freq_seg0_idx=$idx" "$N"
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ "$enable_ac" != "0" ]; then
|
||||
json_get_vars \
|
||||
rxldpc:1 \
|
||||
short_gi_80:1 \
|
||||
short_gi_160:1 \
|
||||
tx_stbc_2by1:1 \
|
||||
su_beamformer:1 \
|
||||
su_beamformee:1 \
|
||||
mu_beamformer:1 \
|
||||
mu_beamformee:1 \
|
||||
vht_txop_ps:1 \
|
||||
htc_vht:1 \
|
||||
rx_antenna_pattern:1 \
|
||||
tx_antenna_pattern:1 \
|
||||
vht_max_a_mpdu_len_exp:7 \
|
||||
vht_max_mpdu:11454 \
|
||||
rx_stbc:4 \
|
||||
tx_stbc:4 \
|
||||
vht_link_adapt:3 \
|
||||
vht160:2
|
||||
|
||||
append base_cfg "ieee80211ac=1" "$N"
|
||||
vht_cap=0
|
||||
for cap in $(iw phy "$phy" info | awk -F "[()]" '/VHT Capabilities/ { print $2 }'); do
|
||||
vht_cap="$(($vht_cap | $cap))"
|
||||
done
|
||||
|
||||
cap_rx_stbc=$((($vht_cap >> 8) & 7))
|
||||
[ "$rx_stbc" -lt "$cap_rx_stbc" ] && cap_rx_stbc="$rx_stbc"
|
||||
ht_cap_mask="$(( ($vht_cap & ~(0x700)) | ($cap_rx_stbc << 8) ))"
|
||||
|
||||
mac80211_add_capabilities vht_capab $vht_cap \
|
||||
RXLDPC:0x10::$rxldpc \
|
||||
SHORT-GI-80:0x20::$short_gi_80 \
|
||||
SHORT-GI-160:0x40::$short_gi_160 \
|
||||
TX-STBC-2BY1:0x80::$tx_stbc \
|
||||
SU-BEAMFORMER:0x800::$su_beamformer \
|
||||
SU-BEAMFORMEE:0x1000::$su_beamformee \
|
||||
MU-BEAMFORMER:0x80000::$mu_beamformer \
|
||||
MU-BEAMFORMEE:0x100000::$mu_beamformee \
|
||||
VHT-TXOP-PS:0x200000::$vht_txop_ps \
|
||||
HTC-VHT:0x400000::$htc_vht \
|
||||
RX-ANTENNA-PATTERN:0x10000000::$rx_antenna_pattern \
|
||||
TX-ANTENNA-PATTERN:0x20000000::$tx_antenna_pattern \
|
||||
RX-STBC1:0x700:0x100:1 \
|
||||
RX-STBC12:0x700:0x200:1 \
|
||||
RX-STBC123:0x700:0x300:1 \
|
||||
RX-STBC1234:0x700:0x400:1 \
|
||||
|
||||
# supported Channel widths
|
||||
vht160_hw=0
|
||||
[ "$(($vht_cap & 12))" -eq 4 -a 1 -le "$vht160" ] && \
|
||||
vht160_hw=1
|
||||
[ "$(($vht_cap & 12))" -eq 8 -a 2 -le "$vht160" ] && \
|
||||
vht160_hw=2
|
||||
[ "$vht160_hw" = 1 ] && vht_capab="$vht_capab[VHT160]"
|
||||
[ "$vht160_hw" = 2 ] && vht_capab="$vht_capab[VHT160-80PLUS80]"
|
||||
|
||||
# maximum MPDU length
|
||||
vht_max_mpdu_hw=3895
|
||||
[ "$(($vht_cap & 3))" -ge 1 -a 7991 -le "$vht_max_mpdu" ] && \
|
||||
vht_max_mpdu_hw=7991
|
||||
[ "$(($vht_cap & 3))" -ge 2 -a 11454 -le "$vht_max_mpdu" ] && \
|
||||
vht_max_mpdu_hw=11454
|
||||
[ "$vht_max_mpdu_hw" != 3895 ] && \
|
||||
vht_capab="$vht_capab[MAX-MPDU-$vht_max_mpdu_hw]"
|
||||
|
||||
# maximum A-MPDU length exponent
|
||||
vht_max_a_mpdu_len_exp_hw=0
|
||||
[ "$(($vht_cap & 58720256))" -ge 8388608 -a 1 -le "$vht_max_a_mpdu_len_exp" ] && \
|
||||
vht_max_a_mpdu_len_exp_hw=1
|
||||
[ "$(($vht_cap & 58720256))" -ge 16777216 -a 2 -le "$vht_max_a_mpdu_len_exp" ] && \
|
||||
vht_max_a_mpdu_len_exp_hw=2
|
||||
[ "$(($vht_cap & 58720256))" -ge 25165824 -a 3 -le "$vht_max_a_mpdu_len_exp" ] && \
|
||||
vht_max_a_mpdu_len_exp_hw=3
|
||||
[ "$(($vht_cap & 58720256))" -ge 33554432 -a 4 -le "$vht_max_a_mpdu_len_exp" ] && \
|
||||
vht_max_a_mpdu_len_exp_hw=4
|
||||
[ "$(($vht_cap & 58720256))" -ge 41943040 -a 5 -le "$vht_max_a_mpdu_len_exp" ] && \
|
||||
vht_max_a_mpdu_len_exp_hw=5
|
||||
[ "$(($vht_cap & 58720256))" -ge 50331648 -a 6 -le "$vht_max_a_mpdu_len_exp" ] && \
|
||||
vht_max_a_mpdu_len_exp_hw=6
|
||||
[ "$(($vht_cap & 58720256))" -ge 58720256 -a 7 -le "$vht_max_a_mpdu_len_exp" ] && \
|
||||
vht_max_a_mpdu_len_exp_hw=7
|
||||
vht_capab="$vht_capab[MAX-A-MPDU-LEN-EXP$vht_max_a_mpdu_len_exp_hw]"
|
||||
|
||||
# whether or not the STA supports link adaptation using VHT variant
|
||||
vht_link_adapt_hw=0
|
||||
[ "$(($vht_cap & 201326592))" -ge 134217728 -a 2 -le "$vht_link_adapt" ] && \
|
||||
vht_link_adapt_hw=2
|
||||
[ "$(($vht_cap & 201326592))" -ge 201326592 -a 3 -le "$vht_link_adapt" ] && \
|
||||
vht_link_adapt_hw=3
|
||||
[ "$vht_link_adapt_hw" != 0 ] && \
|
||||
vht_capab="$vht_capab[VHT-LINK-ADAPT-$vht_link_adapt_hw]"
|
||||
|
||||
[ -n "$vht_capab" ] && append base_cfg "vht_capab=$vht_capab" "$N"
|
||||
fi
|
||||
|
||||
hostapd_prepare_device_config "$hostapd_conf_file" nl80211
|
||||
cat >> "$hostapd_conf_file" <<EOF
|
||||
${channel:+channel=$channel}
|
||||
${channel_list:+chanlist=$channel_list}
|
||||
${noscan:+noscan=$noscan}
|
||||
$base_cfg
|
||||
|
||||
EOF
|
||||
json_select ..
|
||||
}
|
||||
|
||||
mac80211_hostapd_setup_bss() {
|
||||
local phy="$1"
|
||||
local ifname="$2"
|
||||
local macaddr="$3"
|
||||
local type="$4"
|
||||
|
||||
hostapd_cfg=
|
||||
append hostapd_cfg "$type=$ifname" "$N"
|
||||
|
||||
hostapd_set_bss_options hostapd_cfg "$vif" || return 1
|
||||
json_get_vars wds dtim_period max_listen_int start_disabled
|
||||
|
||||
set_default wds 0
|
||||
set_default start_disabled 0
|
||||
|
||||
[ "$wds" -gt 0 ] && append hostapd_cfg "wds_sta=1" "$N"
|
||||
[ "$staidx" -gt 0 -o "$start_disabled" -eq 1 ] && append hostapd_cfg "start_disabled=1" "$N"
|
||||
|
||||
cat >> /var/run/hostapd-$phy.conf <<EOF
|
||||
$hostapd_cfg
|
||||
bssid=$macaddr
|
||||
${dtim_period:+dtim_period=$dtim_period}
|
||||
${max_listen_int:+max_listen_interval=$max_listen_int}
|
||||
EOF
|
||||
}
|
||||
|
||||
mac80211_get_addr() {
|
||||
local phy="$1"
|
||||
local idx="$(($2 + 1))"
|
||||
|
||||
head -n $(($macidx + 1)) /sys/class/ieee80211/${phy}/addresses | tail -n1
|
||||
}
|
||||
|
||||
mac80211_generate_mac() {
|
||||
local phy="$1"
|
||||
local id="${macidx:-0}"
|
||||
|
||||
local ref="$(cat /sys/class/ieee80211/${phy}/macaddress)"
|
||||
local mask="$(cat /sys/class/ieee80211/${phy}/address_mask)"
|
||||
|
||||
[ "$mask" = "00:00:00:00:00:00" ] && {
|
||||
mask="ff:ff:ff:ff:ff:ff";
|
||||
|
||||
[ "$(wc -l < /sys/class/ieee80211/${phy}/addresses)" -gt 1 ] && {
|
||||
addr="$(mac80211_get_addr "$phy" "$id")"
|
||||
[ -n "$addr" ] && {
|
||||
echo "$addr"
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
local oIFS="$IFS"; IFS=":"; set -- $mask; IFS="$oIFS"
|
||||
|
||||
local mask1=$1
|
||||
local mask6=$6
|
||||
|
||||
local oIFS="$IFS"; IFS=":"; set -- $ref; IFS="$oIFS"
|
||||
|
||||
macidx=$(($id + 1))
|
||||
[ "$((0x$mask1))" -gt 0 ] && {
|
||||
b1="0x$1"
|
||||
[ "$id" -gt 0 ] && \
|
||||
b1=$(($b1 ^ ((($id - 1) << 2) | 0x2)))
|
||||
printf "%02x:%s:%s:%s:%s:%s" $b1 $2 $3 $4 $5 $6
|
||||
return
|
||||
}
|
||||
|
||||
[ "$((0x$mask6))" -lt 255 ] && {
|
||||
printf "%s:%s:%s:%s:%s:%02x" $1 $2 $3 $4 $5 $(( 0x$6 ^ $id ))
|
||||
return
|
||||
}
|
||||
|
||||
off2=$(( (0x$6 + $id) / 0x100 ))
|
||||
printf "%s:%s:%s:%s:%02x:%02x" \
|
||||
$1 $2 $3 $4 \
|
||||
$(( (0x$5 + $off2) % 0x100 )) \
|
||||
$(( (0x$6 + $id) % 0x100 ))
|
||||
}
|
||||
|
||||
find_phy() {
|
||||
[ -n "$phy" -a -d /sys/class/ieee80211/$phy ] && return 0
|
||||
[ -n "$path" ] && {
|
||||
for phy in $(ls /sys/class/ieee80211 2>/dev/null); do
|
||||
case "$(readlink -f /sys/class/ieee80211/$phy/device)" in
|
||||
*$path) return 0;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
[ -n "$macaddr" ] && {
|
||||
for phy in $(ls /sys/class/ieee80211 2>/dev/null); do
|
||||
grep -i -q "$macaddr" "/sys/class/ieee80211/${phy}/macaddress" && return 0
|
||||
done
|
||||
}
|
||||
return 1
|
||||
}
|
||||
|
||||
mac80211_check_ap() {
|
||||
has_ap=1
|
||||
}
|
||||
|
||||
mac80211_prepare_vif() {
|
||||
json_select config
|
||||
|
||||
json_get_vars ifname mode ssid wds powersave macaddr
|
||||
|
||||
[ -n "$ifname" ] || ifname="wlan${phy#phy}${if_idx:+-$if_idx}"
|
||||
if_idx=$((${if_idx:-0} + 1))
|
||||
|
||||
set_default wds 0
|
||||
set_default powersave 0
|
||||
|
||||
json_select ..
|
||||
|
||||
wireless_add_vif "$name" "dummy-$ssid"
|
||||
/bin/sleep 10 &
|
||||
wireless_add_process "$!" /bin/sleep 1
|
||||
[ -n "$macaddr" ] || {
|
||||
macaddr="$(mac80211_generate_mac $phy)"
|
||||
macidx="$(($macidx + 1))"
|
||||
}
|
||||
|
||||
json_add_object data
|
||||
json_add_string ifname "$ifname"
|
||||
json_close_object
|
||||
json_select config
|
||||
|
||||
# It is far easier to delete and create the desired interface
|
||||
case "$mode" in
|
||||
adhoc)
|
||||
iw phy "$phy" interface add "$ifname" type adhoc
|
||||
;;
|
||||
ap)
|
||||
# Hostapd will handle recreating the interface and
|
||||
# subsequent virtual APs belonging to the same PHY
|
||||
if [ -n "$hostapd_ctrl" ]; then
|
||||
type=bss
|
||||
else
|
||||
type=interface
|
||||
fi
|
||||
|
||||
mac80211_hostapd_setup_bss "$phy" "$ifname" "$macaddr" "$type" || return
|
||||
|
||||
[ -n "$hostapd_ctrl" ] || {
|
||||
iw phy "$phy" interface add "$ifname" type __ap
|
||||
hostapd_ctrl="${hostapd_ctrl:-/var/run/hostapd/$ifname}"
|
||||
}
|
||||
;;
|
||||
mesh)
|
||||
iw phy "$phy" interface add "$ifname" type mp
|
||||
;;
|
||||
monitor)
|
||||
iw phy "$phy" interface add "$ifname" type monitor
|
||||
;;
|
||||
sta)
|
||||
local wdsflag=
|
||||
staidx="$(($staidx + 1))"
|
||||
[ "$wds" -gt 0 ] && wdsflag="4addr on"
|
||||
iw phy "$phy" interface add "$ifname" type managed $wdsflag
|
||||
[ "$powersave" -gt 0 ] && powersave="on" || powersave="off"
|
||||
iw "$ifname" set power_save "$powersave"
|
||||
;;
|
||||
esac
|
||||
|
||||
case "$mode" in
|
||||
monitor|mesh)
|
||||
[ "$auto_channel" -gt 0 ] || iw dev "$ifname" set channel "$channel" $htmode
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ "$mode" != "ap" ]; then
|
||||
# ALL ap functionality will be passed to hostapd
|
||||
# All interfaces must have unique mac addresses
|
||||
# which can either be explicitly set in the device
|
||||
# section, or automatically generated
|
||||
ip link set dev "$ifname" address "$macaddr"
|
||||
fi
|
||||
|
||||
json_select ..
|
||||
}
|
||||
|
||||
mac80211_setup_supplicant() {
|
||||
wpa_supplicant_prepare_interface "$ifname" nl80211 || return 1
|
||||
wpa_supplicant_add_network "$ifname"
|
||||
wpa_supplicant_run "$ifname" ${hostapd_ctrl:+-H $hostapd_ctrl}
|
||||
}
|
||||
|
||||
mac80211_setup_adhoc_htmode() {
|
||||
case "$htmode" in
|
||||
VHT20|HT20) ibss_htmode=HT20;;
|
||||
HT40*|VHT40|VHT160)
|
||||
case "$hwmode" in
|
||||
a)
|
||||
case "$(( ($channel / 4) % 2 ))" in
|
||||
1) ibss_htmode="HT40+" ;;
|
||||
0) ibss_htmode="HT40-";;
|
||||
esac
|
||||
;;
|
||||
*)
|
||||
case "$htmode" in
|
||||
HT40+) ibss_htmode="HT40+";;
|
||||
HT40-) ibss_htmode="HT40-";;
|
||||
*)
|
||||
if [ "$channel" -lt 7 ]; then
|
||||
ibss_htmode="HT40+"
|
||||
else
|
||||
ibss_htmode="HT40-"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
[ "$auto_channel" -gt 0 ] && ibss_htmode="HT40+"
|
||||
;;
|
||||
VHT80)
|
||||
ibss_htmode="80MHZ"
|
||||
;;
|
||||
NONE|NOHT)
|
||||
ibss_htmode="NOHT"
|
||||
;;
|
||||
*) ibss_htmode="" ;;
|
||||
esac
|
||||
|
||||
}
|
||||
|
||||
mac80211_setup_adhoc() {
|
||||
json_get_vars bssid ssid key mcast_rate
|
||||
|
||||
keyspec=
|
||||
[ "$auth_type" = "wep" ] && {
|
||||
set_default key 1
|
||||
case "$key" in
|
||||
[1234])
|
||||
local idx
|
||||
for idx in 1 2 3 4; do
|
||||
json_get_var ikey "key$idx"
|
||||
|
||||
[ -n "$ikey" ] && {
|
||||
ikey="$(($idx - 1)):$(prepare_key_wep "$ikey")"
|
||||
[ $idx -eq $key ] && ikey="d:$ikey"
|
||||
append keyspec "$ikey"
|
||||
}
|
||||
done
|
||||
;;
|
||||
*)
|
||||
append keyspec "d:0:$(prepare_key_wep "$key")"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
brstr=
|
||||
for br in $basic_rate_list; do
|
||||
wpa_supplicant_add_rate brstr "$br"
|
||||
done
|
||||
|
||||
mcval=
|
||||
[ -n "$mcast_rate" ] && wpa_supplicant_add_rate mcval "$mcast_rate"
|
||||
|
||||
iw dev "$ifname" ibss join "$ssid" $freq $ibss_htmode fixed-freq $bssid \
|
||||
${beacon_int:+beacon-interval $beacon_int} \
|
||||
${brstr:+basic-rates $brstr} \
|
||||
${mcval:+mcast-rate $mcval} \
|
||||
${keyspec:+keys $keyspec}
|
||||
}
|
||||
|
||||
mac80211_setup_vif() {
|
||||
local name="$1"
|
||||
local failed
|
||||
|
||||
json_select data
|
||||
json_get_vars ifname
|
||||
json_select ..
|
||||
|
||||
json_select config
|
||||
json_get_vars mode
|
||||
json_get_var vif_txpower txpower
|
||||
|
||||
ip link set dev "$ifname" up || {
|
||||
wireless_setup_vif_failed IFUP_ERROR
|
||||
json_select ..
|
||||
return
|
||||
}
|
||||
|
||||
set_default vif_txpower "$txpower"
|
||||
[ -z "$vif_txpower" ] || iw dev "$ifname" set txpower fixed "${vif_txpower%%.*}00"
|
||||
|
||||
case "$mode" in
|
||||
mesh)
|
||||
# authsae or wpa_supplicant
|
||||
json_get_vars key
|
||||
if [ -n "$key" ]; then
|
||||
if [ -e "/lib/wifi/authsae.sh" ]; then
|
||||
. /lib/wifi/authsae.sh
|
||||
authsae_start_interface || failed=1
|
||||
else
|
||||
wireless_vif_parse_encryption
|
||||
mac80211_setup_supplicant || failed=1
|
||||
fi
|
||||
else
|
||||
json_get_vars mesh_id mcast_rate
|
||||
|
||||
mcval=
|
||||
[ -n "$mcast_rate" ] && wpa_supplicant_add_rate mcval "$mcast_rate"
|
||||
|
||||
iw dev "$ifname" mesh join "$mesh_id" ${mcval:+mcast-rate $mcval}
|
||||
fi
|
||||
|
||||
for var in $MP_CONFIG_INT $MP_CONFIG_BOOL $MP_CONFIG_STRING; do
|
||||
json_get_var mp_val "$var"
|
||||
[ -n "$mp_val" ] && iw dev "$ifname" set mesh_param "$var" "$mp_val"
|
||||
done
|
||||
;;
|
||||
adhoc)
|
||||
wireless_vif_parse_encryption
|
||||
mac80211_setup_adhoc_htmode
|
||||
if [ "$wpa" -gt 0 -o "$auto_channel" -gt 0 ]; then
|
||||
mac80211_setup_supplicant || failed=1
|
||||
else
|
||||
mac80211_setup_adhoc
|
||||
fi
|
||||
;;
|
||||
sta)
|
||||
mac80211_setup_supplicant || failed=1
|
||||
;;
|
||||
esac
|
||||
|
||||
json_select ..
|
||||
[ -n "$failed" ] || wireless_add_vif "$name" "$ifname"
|
||||
}
|
||||
|
||||
get_freq() {
|
||||
local phy="$1"
|
||||
local chan="$2"
|
||||
iw "$phy" info | grep -E -m1 "(\* ${chan:-....} MHz${chan:+|\\[$chan\\]})" | grep MHz | awk '{print $2}'
|
||||
}
|
||||
|
||||
mac80211_interface_cleanup() {
|
||||
local phy="$1"
|
||||
|
||||
for wdev in $(list_phy_interfaces "$phy"); do
|
||||
ip link set dev "$wdev" down 2>/dev/null
|
||||
iw dev "$wdev" del
|
||||
done
|
||||
}
|
||||
|
||||
drv_mac80211_cleanup() {
|
||||
echo "mac80211 cleanup"
|
||||
hostapd_common_cleanup
|
||||
}
|
||||
|
||||
drv_mac80211_setup() {
|
||||
echo "mac80211 setup: $1"
|
||||
json_dump
|
||||
for_each_interface "sta ap adhoc" setup_vif
|
||||
wireless_set_data phy=phy0
|
||||
json_select config
|
||||
json_get_vars \
|
||||
phy macaddr path \
|
||||
country chanbw distance \
|
||||
txpower antenna_gain \
|
||||
rxantenna txantenna \
|
||||
frag rts beacon_int htmode
|
||||
json_get_values basic_rate_list basic_rate
|
||||
json_select ..
|
||||
|
||||
find_phy || {
|
||||
echo "Could not find PHY for device '$1'"
|
||||
wireless_set_retry 0
|
||||
return 1
|
||||
}
|
||||
|
||||
wireless_set_data phy="$phy"
|
||||
mac80211_interface_cleanup "$phy"
|
||||
|
||||
# convert channel to frequency
|
||||
[ "$auto_channel" -gt 0 ] || freq="$(get_freq "$phy" "$channel")"
|
||||
|
||||
[ -n "$country" ] && {
|
||||
iw reg get | grep -q "^country $country:" || {
|
||||
iw reg set "$country"
|
||||
sleep 1
|
||||
}
|
||||
}
|
||||
|
||||
hostapd_conf_file="/var/run/hostapd-$phy.conf"
|
||||
|
||||
no_ap=1
|
||||
macidx=0
|
||||
staidx=0
|
||||
|
||||
[ -n "$chanbw" ] && {
|
||||
for file in /sys/kernel/debug/ieee80211/$phy/ath9k/chanbw /sys/kernel/debug/ieee80211/$phy/ath5k/bwmode; do
|
||||
[ -f "$file" ] && echo "$chanbw" > "$file"
|
||||
done
|
||||
}
|
||||
|
||||
set_default rxantenna all
|
||||
set_default txantenna all
|
||||
set_default distance 0
|
||||
set_default antenna_gain 0
|
||||
|
||||
iw phy "$phy" set antenna $txantenna $rxantenna >/dev/null 2>&1
|
||||
iw phy "$phy" set antenna_gain $antenna_gain
|
||||
iw phy "$phy" set distance "$distance"
|
||||
|
||||
[ -n "$frag" ] && iw phy "$phy" set frag "${frag%%.*}"
|
||||
[ -n "$rts" ] && iw phy "$phy" set rts "${rts%%.*}"
|
||||
|
||||
has_ap=
|
||||
hostapd_ctrl=
|
||||
for_each_interface "ap" mac80211_check_ap
|
||||
|
||||
rm -f "$hostapd_conf_file"
|
||||
[ -n "$has_ap" ] && mac80211_hostapd_setup_base "$phy"
|
||||
|
||||
for_each_interface "sta adhoc mesh monitor" mac80211_prepare_vif
|
||||
for_each_interface "ap" mac80211_prepare_vif
|
||||
|
||||
[ -n "$hostapd_ctrl" ] && {
|
||||
/usr/sbin/hostapd -P /var/run/wifi-$phy.pid -B "$hostapd_conf_file"
|
||||
ret="$?"
|
||||
wireless_add_process "$(cat /var/run/wifi-$phy.pid)" "/usr/sbin/hostapd" 1
|
||||
[ "$ret" != 0 ] && {
|
||||
wireless_setup_failed HOSTAPD_START_FAILED
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
for_each_interface "ap sta adhoc mesh monitor" mac80211_setup_vif
|
||||
|
||||
wireless_set_up
|
||||
}
|
||||
|
||||
list_phy_interfaces() {
|
||||
local phy="$1"
|
||||
if [ -d "/sys/class/ieee80211/${phy}/device/net" ]; then
|
||||
ls "/sys/class/ieee80211/${phy}/device/net" 2>/dev/null;
|
||||
else
|
||||
ls "/sys/class/ieee80211/${phy}/device" 2>/dev/null | grep net: | sed -e 's,net:,,g'
|
||||
fi
|
||||
}
|
||||
|
||||
drv_mac80211_teardown() {
|
||||
wireless_process_kill_all
|
||||
|
||||
json_select data
|
||||
json_get_var phy phy
|
||||
json_get_vars phy
|
||||
json_select ..
|
||||
echo "mac80211 teardown: $1 ($phy)"
|
||||
json_dump
|
||||
|
||||
mac80211_interface_cleanup "$phy"
|
||||
}
|
||||
|
||||
add_driver mac80211
|
||||
|
||||
Reference in New Issue
Block a user