From: Stijn Tintel Date: Wed, 28 Dec 2016 04:22:00 +0000 (+0100) Subject: hostapd: add function to handle wpa_key_mgmt X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=30f14f61984591e7481a3fb568ad59dfb6c49ce7;p=openwrt%2Fstaging%2Fwigyori.git hostapd: add function to handle wpa_key_mgmt Now that wpa_key_mgmt handling for hostapd and wpa_supplicant are consistent, we can move parts of it to a dedicated function. Signed-off-by: Stijn Tintel Tested-by: Sebastian Kemper --- diff --git a/package/network/services/hostapd/files/netifd.sh b/package/network/services/hostapd/files/netifd.sh index b87672c4d7..a339e443ff 100644 --- a/package/network/services/hostapd/files/netifd.sh +++ b/package/network/services/hostapd/files/netifd.sh @@ -36,6 +36,13 @@ hostapd_append_wep_key() { esac } +hostapd_append_wpa_key_mgmt() { + local auth_type="$(echo $auth_type | tr 'a-z' 'A-Z')" + + append wpa_key_mgmt "WPA-$auth_type" + [ "$ieee80211r" -gt 0 ] && append wpa_key_mgmt "FT-${auth_type}" +} + hostapd_add_log_config() { config_add_boolean \ log_80211 \ @@ -256,7 +263,6 @@ hostapd_set_bss_options() { [ "$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 \ @@ -291,7 +297,6 @@ hostapd_set_bss_options() { [ -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" [ "$eapol_version" -ge "1" -a "$eapol_version" -le "2" ] && append bss_conf "eapol_version=$eapol_version" "$N" ;; @@ -376,11 +381,9 @@ hostapd_set_bss_options() { 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 + hostapd_append_wpa_key_mgmt [ -n "$wpa_key_mgmt" ] && append bss_conf "wpa_key_mgmt=$wpa_key_mgmt" "$N" fi @@ -614,8 +617,7 @@ wpa_supplicant_add_network() { psk) local passphrase - append wpa_key_mgmt "WPA-PSK" - [ "$ieee80211r" -gt 0 ] && append wpa_key_mgmt "FT-PSK" + hostapd_append_wpa_key_mgmt key_mgmt="$wpa_key_mgmt" if [ ${#key} -eq 64 ]; then @@ -626,8 +628,7 @@ wpa_supplicant_add_network() { append network_data "$passphrase" "$N$T" ;; eap) - append wpa_key_mgmt "WPA-EAP" - [ "$ieee80211r" -gt 0 ] && append wpa_key_mgmt "FT-EAP" + hostapd_append_wpa_key_mgmt key_mgmt="$wpa_key_mgmt" json_get_vars eap_type identity anonymous_identity ca_cert