hostapd: Use network_get_device instead of uci_get_state
[openwrt.git] / package / network / services / hostapd / files / netifd.sh
index 3647b29..1c91bbf 100644 (file)
@@ -1,3 +1,5 @@
+. /lib/functions/network.sh
+
 wpa_supplicant_add_rate() {
        local var="$1"
        local val="$(($2 / 1000))"
@@ -52,7 +54,7 @@ hostapd_common_add_device_config() {
        config_add_array supported_rates
 
        config_add_string country
-       config_add_boolean country_ie doth ht_coex
+       config_add_boolean country_ie doth
        config_add_string require_mode
 
        hostapd_add_log_config
@@ -65,15 +67,13 @@ hostapd_prepare_device_config() {
        local base="${config%%.conf}"
        local base_cfg=
 
-       json_get_vars country country_ie beacon_int doth require_mode ht_coex
+       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
-       set_default ht_coex 0
 
-       append base_cfg "ht_coex=$ht_coex" "$N"
        [ -n "$country" ] && {
                append base_cfg "country_code=$country" "$N"
 
@@ -122,6 +122,7 @@ hostapd_common_add_bss_config() {
 
        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
@@ -142,6 +143,7 @@ hostapd_common_add_bss_config() {
 
        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'
 
@@ -184,7 +186,7 @@ hostapd_set_bss_options() {
                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
+               iapp_interface eapol_version
 
        set_default isolate 0
        set_default maxassoc 0
@@ -194,6 +196,7 @@ hostapd_set_bss_options() {
        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
@@ -239,6 +242,8 @@ hostapd_set_bss_options() {
                                [ -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"
                ;;
@@ -250,7 +255,7 @@ hostapd_set_bss_options() {
                                ownip \
                                eap_reauth_period dynamic_vlan \
                                vlan_naming vlan_tagged_interface \
-                               vlan_bridge
+                               vlan_bridge vlan_file
 
                        # legacy compatibility
                        [ -n "$auth_server" ] || json_get_var auth_server server
@@ -293,7 +298,13 @@ hostapd_set_bss_options() {
                                        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
@@ -342,8 +353,9 @@ hostapd_set_bss_options() {
        append bss_conf "ssid=$ssid" "$N"
        [ -n "$network_bridge" ] && append bss_conf "bridge=$network_bridge" "$N"
        [ -n "$iapp_interface" ] && {
-               iapp_interface="$(uci_get_state network "$iapp_interface" ifname "$iapp_interface")"
-               [ -n "$iapp_interface" ] && append bss_conf "iapp_interface=$iapp_interface" "$N"
+               local ifname
+               network_get_device ifname "$iapp_interface" || ifname = "$iapp_interface"
+               append bss_conf "iapp_interface=$ifname" "$N"
        }
 
        if [ "$wpa" -ge "1" ]; then
@@ -540,7 +552,9 @@ wpa_supplicant_add_network() {
        json_get_vars \
                ssid bssid key \
                basic_rate mcast_rate \
-               ieee80211w
+               ieee80211w ieee80211r
+
+       set_default ieee80211r 0
 
        local key_mgmt='NONE'
        local enc_str=
@@ -551,6 +565,8 @@ wpa_supplicant_add_network() {
        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" ] && {
@@ -596,6 +612,7 @@ wpa_supplicant_add_network() {
                ;;
                eap)
                        key_mgmt='WPA-EAP'
+                       [ "$ieee80211r" -gt 0 ] && key_mgmt="FT-EAP $key_mgmt"
 
                        json_get_vars eap_type identity ca_cert
                        [ -n "$ca_cert" ] && append network_data "ca_cert=\"$ca_cert\"" "$N$T"