usteer: Initial import

Signed-off-by: Felix Fietkau <nbd@nbd.name>
This commit is contained in:
Felix Fietkau
2018-03-21 16:40:05 +01:00
committed by John Crispin
commit d10731f806
23 changed files with 4512 additions and 0 deletions

37
openwrt/usteer/Makefile Normal file
View File

@@ -0,0 +1,37 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=usteer
PKG_VERSION:=$(shell git show -s --format=%cd --date=short)
PKG_RELEASE:=1
PKG_BUILD_PARALLEL:=1
PKG_FILE_DEPENDS:=$(CURDIR)/../..
include $(INCLUDE_DIR)/package.mk
include $(INCLUDE_DIR)/cmake.mk
define Build/Prepare
mkdir -p $(PKG_BUILD_DIR)
ln -s $(CURDIR)/../../.git $(PKG_BUILD_DIR)/.git
cd $(PKG_BUILD_DIR) && git checkout .
endef
define Package/usteer
SECTION:=net
CATEGORY:=Network
DEPENDS:=+libubox +libubus +libblobmsg-json +libnl-tiny
TITLE:=OpenWrt AP roaming assist daemon
endef
define Package/usteer/conffiles
/etc/config/usteer
endef
define Package/usteer/install
$(INSTALL_DIR) $(1)/sbin $(1)/etc/init.d $(1)/etc/config
$(CP) ./files/* $(1)/
$(CP) $(PKG_BUILD_DIR)/usteer $(1)/sbin/
endef
$(eval $(call BuildPackage,usteer))

View File

@@ -0,0 +1,4 @@
config usteer
option 'network' 'lan'
option 'syslog' '1'
option 'debug_level' '2'

View File

@@ -0,0 +1,120 @@
#!/bin/sh /etc/rc.common
# Copyright (C) 2013 OpenWrt.org
START=50
USE_PROCD=1
NAME=usteer
PROG=/sbin/usteer
. /lib/functions/network.sh
. /usr/share/libubox/jshn.sh
. /lib/functions.sh
load_ifaces() {
local network="$(uci get usteer.@usteer[-1].network)"
for n in $network; do
local device
json_load "$(ifstatus $n)"
json_get_var device l3_device
echo -n "$device "
done
}
uci_option_to_json_bool() {
local cfg="$1"
local option="$2"
local val
config_get_bool val "$cfg" $option
[ -n "$val" ] && json_add_boolean $option $val
}
uci_option_to_json_string() {
local cfg="$1"
local option="$2"
local val
config_get val "$cfg" "$option"
[ -n "$val" ] && json_add_string $option "$val"
}
uci_option_to_json() {
local cfg="$1"
local option="$2"
local val
config_get val "$cfg" $option
[ -n "$val" ] && json_add_int $option $val
}
uci_usteer() {
local cfg="$1"
uci_option_to_json_bool "$cfg" syslog
uci_option_to_json_bool "$cfg" load_kick_enabled
uci_option_to_json_string "$cfg" node_up_script
for opt in \
debug_level \
sta_block_timeout local_sta_timeout local_sta_update \
max_retry_band seen_policy_timeout \
load_balancing_threshold band_steering_threshold \
remote_update_interval \
min_connect_snr min_snr signal_diff_threshold \
initial_connect_delay \
roam_kick_delay roam_scan_tries \
roam_scan_snr roam_scan_interval \
roam_trigger_snr roam_trigger_interval \
load_kick_threshold load_kick_delay load_kick_min_clients \
load_kick_reason_code
do
uci_option_to_json "$cfg" "$opt"
done
}
load_config() {
[ "$ENABLED" -gt 0 ] || return
ubus -t 10 wait_for usteer
json_init
json_add_array interfaces
for i in $(load_ifaces); do
json_add_string "" "$i"
done
json_close_array
config_load usteer
config_foreach uci_usteer usteer
ubus call usteer set_config "$(json_dump)"
}
reload_service() {
start
load_config
}
service_started() {
load_config
}
service_triggers() {
procd_add_reload_trigger usteer
procd_add_raw_trigger "interface.*" 2000 /etc/init.d/usteer reload
}
start_service()
{
local network="$(uci -q get usteer.@usteer[-1].network)"
ENABLED="$(uci -q get usteer.@usteer[-1].enabled)"
ENABLED="${ENABLED:-1}"
[ "$ENABLED" -gt 0 ] || return
procd_open_instance
procd_set_param command "$PROG"
procd_close_instance
}