[OpenWrt-Devel] [PATCH] Add u-APSD and WPA-PSK-file options to hostapd

Vittorio G (VittGam) openwrt at vittgam.net
Mon Oct 13 19:11:28 EDT 2014


This patch adds uapsd and wpa_psk_file options to hostapd.

It also fixes the hostapd_set_bss_options call in mac80211.sh.

The uapsd option sets the uapsd_advertisement_enabled flag in hostapd, only if the adapter actually supports the option.

The wpa_psk_file offers the possibility to use a different WPA-PSK key for each client. The directive points to a file with the following syntax:

> 00:11:22:33:44:55 passphrase_for_client_1
> 00:11:22:33:44:67 passphrase_for_client_2
> 00:11:22:33:44:89 0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef

So it is possible to specify both ASCII passphrases and raw 64-chars hex keys.

Signed-off-by: Vittorio Gambaletta <openwrt at vittgam.net>

diff -aur /rom/lib/netifd/hostapd.sh /overlay/lib/netifd/hostapd.sh
--- /rom/lib/netifd/hostapd.sh	2014-10-12 12:59:38.000000000 +0200
+++ /overlay/lib/netifd/hostapd.sh	2014-10-14 00:03:52.000000000 +0200
@@ -100,7 +100,7 @@
 
 hostapd_common_add_bss_config() {
 	config_add_string 'bssid:macaddr' 'ssid:string'
-	config_add_boolean wds wmm hidden
+	config_add_boolean wds wmm uapsd hidden
 
 	config_add_int maxassoc max_inactivity
 	config_add_boolean disassoc_low_ack isolate short_preamble
@@ -134,6 +134,8 @@
 
 	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
 
@@ -161,7 +163,7 @@
 		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 hidden short_preamble rsn_preauth
+		macfilter ssid wmm uapsd hidden short_preamble rsn_preauth
 
 	set_default isolate 0
 	set_default maxassoc 0
@@ -170,6 +172,7 @@
 	set_default disassoc_low_ack 1
 	set_default hidden 0
 	set_default wmm 1
+	set_default uapsd 1
 
 	append bss_conf "ctrl_interface=/var/run/hostapd"
 	if [ "$isolate" -gt 0 ]; then
@@ -187,6 +190,10 @@
 	append bss_conf "wmm_enabled=$wmm" "$N"
 	append bss_conf "ignore_broadcast_ssid=$hidden" "$N"
 
+	[ -n "$phy" ] && iw phy "$phy" info 2>/dev/null | grep -q 'Device supports AP-side u-APSD.' && {
+		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"
@@ -201,7 +208,7 @@
 			wps_not_configured=1
 		;;
 		psk)
-			json_get_vars key
+			json_get_vars key wpa_psk_file
 			if [ ${#key} -lt 8 ]; then
 				wireless_setup_vif_failed INVALID_WPA_PSK
 				return 1
@@ -210,6 +217,10 @@
 			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"
+			}
 			wps_possible=1
 		;;
 		eap)
diff -aur /rom/lib/netifd/wireless/mac80211.sh /overlay/lib/netifd/wireless/mac80211.sh
--- /rom/lib/netifd/wireless/mac80211.sh	2014-10-12 23:44:53.000000000 +0200
+++ /overlay/lib/netifd/wireless/mac80211.sh	2014-10-13 23:59:39.000000000 +0200
@@ -310,7 +310,7 @@
 	hostapd_cfg=
 	append hostapd_cfg "$type=$ifname" "$N"
 
-	hostapd_set_bss_options hostapd_cfg "$vif" || return 1
+	hostapd_set_bss_options hostapd_cfg "$phy" "$ifname" || return 1
 	json_get_vars wds dtim_period max_listen_int
 
 	set_default wds 0
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel



More information about the openwrt-devel mailing list