mac80211: fix use of local variable
[openwrt/openwrt.git] / package / kernel / mac80211 / files / lib / netifd / wireless / mac80211.sh
index ab2c6ad38dd645623c874d7bb95d348b07020eb3..de003e3d2350475f00be5cfcb10efd6bc3700c1e 100644 (file)
@@ -28,8 +28,9 @@ drv_mac80211_init_device_config() {
        config_add_string path phy 'macaddr:macaddr'
        config_add_string hwmode
        config_add_string tx_burst
+       config_add_string distance
        config_add_int beacon_int chanbw frag rts
-       config_add_int rxantenna txantenna antenna_gain txpower distance
+       config_add_int rxantenna txantenna antenna_gain txpower
        config_add_boolean noscan ht_coex acs_exclude_dfs
        config_add_array ht_capab
        config_add_array channels
@@ -366,7 +367,7 @@ mac80211_get_addr() {
        local phy="$1"
        local idx="$(($2 + 1))"
 
-       head -n $(($macidx + 1)) /sys/class/ieee80211/${phy}/addresses | tail -n1
+       head -n $idx /sys/class/ieee80211/${phy}/addresses | tail -n1
 }
 
 mac80211_generate_mac() {
@@ -505,7 +506,7 @@ mac80211_iw_interface_add() {
 mac80211_prepare_vif() {
        json_select config
 
-       json_get_vars ifname mode ssid wds powersave macaddr enable
+       json_get_vars ifname mode ssid wds powersave macaddr enable wpa_psk_file vlan_file
 
        [ -n "$ifname" ] || ifname="wlan${phy#phy}${if_idx:+-$if_idx}"
        if_idx=$((${if_idx:-0} + 1))
@@ -523,6 +524,12 @@ mac80211_prepare_vif() {
        json_add_object data
        json_add_string ifname "$ifname"
        json_close_object
+
+       [ "$mode" == "ap" ] && {
+               [ -z "$wpa_psk_file" ] && hostapd_set_psk "$ifname"
+               [ -z "$vlan_file" ] && hostapd_set_vlan "$ifname"
+       }
+
        json_select config
 
        # It is far easier to delete and create the desired interface
@@ -781,6 +788,7 @@ mac80211_setup_vif() {
        case "$mode" in
                mesh)
                        wireless_vif_parse_encryption
+                       [ -z "$htmode" ] && htmode="NOHT";
                        freq="$(get_freq "$phy" "$channel")"
                        if [ "$wpa" -gt 0 -o "$auto_channel" -gt 0 ] || chan_is_dfs "$phy" "$channel"; then
                                mac80211_setup_supplicant $vif_enable || failed=1
@@ -1039,10 +1047,12 @@ list_phy_interfaces() {
 drv_mac80211_teardown() {
        wireless_process_kill_all
 
-       for phy in `ls /sys/class/ieee80211/`; do
-               mac80211_interface_cleanup "$phy"
-               uci -q -P /var/state revert wireless._${phy}
-       done
+       json_select data
+       json_get_vars phy
+       json_select ..
+
+       mac80211_interface_cleanup "$phy"
+       uci -q -P /var/state revert wireless._${phy}
 }
 
 add_driver mac80211