[LEDE-DEV] [PATCH 2/3] hostapd: add function to handle wpa_key_mgmt

Stijn Tintel stijn at linux-ipv6.be
Wed Dec 28 05:16:02 PST 2016


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 <stijn at linux-ipv6.be>
---
 package/network/services/hostapd/files/netifd.sh | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/package/network/services/hostapd/files/netifd.sh b/package/network/services/hostapd/files/netifd.sh
index b87672c..a339e44 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
-- 
2.10.2




More information about the Lede-dev mailing list