From: Daniel Albers Date: Sun, 12 Feb 2017 19:23:20 +0000 (+0100) Subject: hostapd: mv netifd.sh hostapd.sh X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=8aa92deaf6da29bc2c95f8823257ec451da9c136;p=openwrt%2Fstaging%2Fhauke.git hostapd: mv netifd.sh hostapd.sh same name for the file on the host and target Signed-off-by: Daniel Albers --- diff --git a/package/network/services/hostapd/Makefile b/package/network/services/hostapd/Makefile index e210457551..f3aa94b6ea 100644 --- a/package/network/services/hostapd/Makefile +++ b/package/network/services/hostapd/Makefile @@ -350,7 +350,7 @@ endef define Package/hostapd-common/install $(INSTALL_DIR) $(1)/lib/netifd - $(INSTALL_DATA) ./files/netifd.sh $(1)/lib/netifd/hostapd.sh + $(INSTALL_DATA) ./files/hostapd.sh $(1)/lib/netifd/hostapd.sh endef define Package/hostapd/install diff --git a/package/network/services/hostapd/files/hostapd.sh b/package/network/services/hostapd/files/hostapd.sh new file mode 100644 index 0000000000..988ebc7757 --- /dev/null +++ b/package/network/services/hostapd/files/hostapd.sh @@ -0,0 +1,763 @@ +. /lib/functions/network.sh + +wpa_supplicant_add_rate() { + local var="$1" + local val="$(($2 / 1000))" + local sub="$((($2 / 100) % 10))" + append $var "$val" "," + [ $sub -gt 0 ] && append $var "." +} + +hostapd_add_rate() { + local var="$1" + local val="$(($2 / 100))" + append $var "$val" " " +} + +hostapd_append_wep_key() { + local var="$1" + + wep_keyidx=0 + set_default key 1 + case "$key" in + [1234]) + for idx in 1 2 3 4; do + local zidx + zidx=$(($idx - 1)) + json_get_var ckey "key${idx}" + [ -n "$ckey" ] && \ + append $var "wep_key${zidx}=$(prepare_key_wep "$ckey")" "$N$T" + done + wep_keyidx=$((key - 1)) + ;; + *) + append $var "wep_key0=$(prepare_key_wep "$key")" "$N$T" + ;; + 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:-0}" -gt 0 ] && append wpa_key_mgmt "FT-${auth_type}" + [ "${ieee80211w:-0}" -gt 0 ] && append wpa_key_mgmt "WPA-${auth_type}-SHA256" +} + +hostapd_add_log_config() { + config_add_boolean \ + log_80211 \ + log_8021x \ + log_radius \ + log_wpa \ + log_driver \ + log_iapp \ + log_mlme + + config_add_int log_level +} + +hostapd_common_add_device_config() { + config_add_array basic_rate + config_add_array supported_rates + + config_add_string country + config_add_boolean country_ie doth + config_add_string require_mode + + hostapd_add_log_config +} + +hostapd_prepare_device_config() { + local config="$1" + local driver="$2" + + local base="${config%%.conf}" + local base_cfg= + + 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 + + [ -n "$country" ] && { + append base_cfg "country_code=$country" "$N" + + [ "$country_ie" -gt 0 ] && append base_cfg "ieee80211d=1" "$N" + [ "$hwmode" = "a" -a "$doth" -gt 0 ] && append base_cfg "ieee80211h=1" "$N" + } + [ -n "$hwmode" ] && append base_cfg "hw_mode=$hwmode" "$N" + + local brlist= br + json_get_values basic_rate_list basic_rate + for br in $basic_rate_list; do + hostapd_add_rate brlist "$br" + done + case "$require_mode" in + g) brlist="60 120 240" ;; + n) append base_cfg "require_ht=1" "$N";; + ac) append base_cfg "require_vht=1" "$N";; + esac + + local rlist= r + json_get_values rate_list supported_rates + for r in $rate_list; do + hostapd_add_rate rlist "$r" + done + + [ -n "$rlist" ] && append base_cfg "supported_rates=$rlist" "$N" + [ -n "$brlist" ] && append base_cfg "basic_rates=$brlist" "$N" + [ -n "$beacon_int" ] && append base_cfg "beacon_int=$beacon_int" "$N" + + cat > "$config" <