From 498d84fc4e00ad75514c3a9dde09338552b89a8c Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Mon, 2 Dec 2013 16:41:03 +0000 Subject: netifd: add wireless configuration support and port mac80211 to the new framework Signed-off-by: Felix Fietkau SVN-Revision: 38988 --- package/network/services/hostapd/Makefile | 11 + package/network/services/hostapd/files/netifd.sh | 577 +++++++++++++++++++++++ 2 files changed, 588 insertions(+) create mode 100644 package/network/services/hostapd/files/netifd.sh (limited to 'package/network/services') diff --git a/package/network/services/hostapd/Makefile b/package/network/services/hostapd/Makefile index 896a637..05a74bb 100644 --- a/package/network/services/hostapd/Makefile +++ b/package/network/services/hostapd/Makefile @@ -208,6 +208,11 @@ define Package/wpa-cli/Description WPA Supplicant control utility endef +define Package/hostapd-common + TITLE:=hostapd/wpa_supplicant common support files + SECTION:=net + CATEGORY:=Network +endef ifneq ($(wildcard $(PKG_BUILD_DIR)/.config_*),$(subst .configured_,.config_,$(STAMP_CONFIGURED))) define Build/Configure/rebuild @@ -309,6 +314,11 @@ define Install/supplicant $(INSTALL_DIR) $(1)/usr/sbin endef +define Package/hostapd-common/install + $(INSTALL_DIR) $(1)/lib/netifd + $(INSTALL_DATA) ./files/netifd.sh $(1)/lib/netifd/hostapd.sh +endef + define Package/hostapd/install $(call Install/hostapd,$(1)) $(INSTALL_BIN) $(PKG_BUILD_DIR)/hostapd/hostapd $(1)/usr/sbin/ @@ -355,3 +365,4 @@ $(eval $(call BuildPackage,wpa-supplicant-mini)) $(eval $(call BuildPackage,wpa-supplicant-p2p)) $(eval $(call BuildPackage,wpa-cli)) $(eval $(call BuildPackage,hostapd-utils)) +$(eval $(call BuildPackage,hostapd-common)) diff --git a/package/network/services/hostapd/files/netifd.sh b/package/network/services/hostapd/files/netifd.sh new file mode 100644 index 0000000..020c41f --- /dev/null +++ b/package/network/services/hostapd/files/netifd.sh @@ -0,0 +1,577 @@ +hostapd_add_rate() { + local var="$1" + local val="$(($2 / 1000))" + local sub="$((($2 / 100) % 10))" + append $var "$val" "," + [ $sub -gt 0 ] && append $var "." +} + +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 network_data "wep_key${zidx}=$(prepare_key_wep "$ckey")" "$N$T" + done + wep_keyidx=$((key - 1)) + ;; + *) + append network_data "wep_key0=$(prepare_key_wep "$key")" "$N$T" + ;; + esac +} + +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_string country + config_add_boolean country_ie + + 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 basic_rate + + hostapd_set_log_options base_cfg + + set_default country_ie 1 + [ -n "$country" ] && { + append base_cfg "country_code=$country" "$N" + [ "$country_ie" -gt 0 ] && append base_cfg "ieee80211d=1" "$N" + } + [ -n "$hwmode" ] && append base_cfg "hw_mode=$hwmode" "$N" + + local brlist= br + for br in $basic_rate_list; do + hostapd_add_rate brlist "$br" + done + [ -n "$brlist" ] && append base_cfg "basic_rates=$brlist" "$N" + [ -n "$beacon_int" ] && append base_cfg "beacon_int=$beacon_int" "$N" + + cat > "$config" <