diff --git a/easy-qos/Makefile b/easy-qos/Makefile deleted file mode 100644 index 6ed6e21be..000000000 --- a/easy-qos/Makefile +++ /dev/null @@ -1,47 +0,0 @@ -# -# Copyright (C) 2019 iopsys Software Solutions AB -# -# This is free software, licensed under the GNU General Public License v2. -# - -include $(TOPDIR)/rules.mk - -PKG_NAME:=easy-qos -PKG_VERSION:=1.1 -PKG_RELEASE:=0 - -PKG_LICENSE:=GPLv2 -PKG_LICENSE_FILES:=none - -include $(INCLUDE_DIR)/package.mk - -define Package/easy-qos - SECTION:=net - CATEGORY:=Network - TITLE:=Easy QoS - DEPENDS:=@(TARGET_brcmbca||TARGET_airoha) -endef - -define Package/easy-qos/description - This package contains Easy QoS utility -endef - -define Build/Prepare - mkdir -p $(PKG_BUILD_DIR) - $(CP) ./files/* $(PKG_BUILD_DIR)/ -endef - -define Build/Compile -endef - -define Package/easy-qos/install - $(INSTALL_DIR) $(1)/etc/config - $(INSTALL_DIR) $(1)/etc/init.d - $(INSTALL_DIR) $(1)/etc/uci-defaults - $(CP) ./files/etc/config/easy_qos $(1)/etc/config/ - $(CP) ./files/etc/init.d/easy_qos.iptables $(1)/etc/init.d/easy_qos - $(CP) ./files/etc/uci-defaults/* $(1)/etc/uci-defaults/ - $(CP) ./files/etc/firewall.easyqos $(1)/etc/firewall.easyqos -endef - -$(eval $(call BuildPackage,easy-qos)) diff --git a/easy-qos/files/etc/config/easy_qos b/easy-qos/files/etc/config/easy_qos deleted file mode 100644 index e69de29bb..000000000 diff --git a/easy-qos/files/etc/firewall.easyqos b/easy-qos/files/etc/firewall.easyqos deleted file mode 100644 index 7851adb61..000000000 --- a/easy-qos/files/etc/firewall.easyqos +++ /dev/null @@ -1 +0,0 @@ -/etc/init.d/easy_qos reload diff --git a/easy-qos/files/etc/init.d/easy_qos.ebtables b/easy-qos/files/etc/init.d/easy_qos.ebtables deleted file mode 100755 index 8501376a1..000000000 --- a/easy-qos/files/etc/init.d/easy_qos.ebtables +++ /dev/null @@ -1,140 +0,0 @@ -#!/bin/sh /etc/rc.common - -START=99 -USE_PROCD=1 - -log() { - echo "${@}"|logger -t easy_qos.ebtable -p debug -} - -exec_log() { - ${@} - if [ "${?}" -ne 0 ]; then - log "Failed to create ${@}"; - fi -} - -get_priority() { - local prio=$(echo $1|tr 'A-Z' 'a-z'); - case "${prio}" in - "lowest") - echo 0;; - "low") - echo 1;; - "besteffort") - echo 2;; - "normal") - echo 3;; - "video") - echo 4;; - "medium") - echo 5;; - "high") - echo 6;; - "highest") - echo 7;; - esac -} - -validate_rule_section() -{ - uci_validate_section easy_qos rule "${1}" \ - 'priority:string' \ - 'macaddr:string' \ - 'proto:string:none' \ - 'port:list(uinteger)' \ - 'comment:string:none' -} - -# Clear existing rules before applying new rules -clear_existing_rules() { - local rule=$(ebtables --concurrent -t broute -L BROUTING|grep -m 1 mark) - while [ -n "${rule}" ]; do - exec_log ebtables --concurrent -t broute -D BROUTING ${rule} - rule=$(ebtables --concurrent -t broute -L BROUTING|grep -m 1 mark) - done -} - -create_rule() { - local protocol=$1; shift - local mac=$1; shift - local mark="0x$1"; shift - local forward_port=$1; - local cmd=""; - local protocol_number - - cmd="-j mark --mark-or ${mark}"; - if [ -n "${forward_port}" ]; then - cmd="--ip-destination-port ${forward_port} ${cmd}"; - fi - - case "${protocol}" in - "tcp") - protocol_number=6;; - "udp") - protocol_number=17;; - "dccp") - protocol_number=33;; - "sctp") - protocol_number=132;; - *) - log "Protocol ${protocol} not supported in ebtables" - return;; - esac - - cmd="--ip-proto ${protocol_number} $cmd" - cmd="-p ip $cmd" - - cmd="-s ${mac} $cmd" - exec_log ebtables --concurrent -t broute -A BROUTING ${cmd} -} - -manage_rule() { - local cfg="$1" - local priority macaddr proto port comment prio_num protocol - - validate_rule_section "${1}" || { - log "Validation of section failed" - return 1; - } - - protocol=$(echo ${proto}|tr 'A-Z' 'a-z') - prio_num=$(get_priority ${priority}) - if [ -n "${macaddr}" -a -n "${prio_num}" ]; then - for p in ${port}; do - if [ "${protocol}" == "none" -o "${protocol}" == "tcpudp" ]; then - create_rule tcp ${macaddr} ${prio_num} ${p} - create_rule udp ${macaddr} ${prio_num} ${p} - else - create_rule ${protocol} ${macaddr} ${prio_num} ${p} - fi - done - # Create rule for all ports if port is not mentioned in uci - if [ -z "${port}" ]; then - if [ "${protocol}" == "none" -o "${protocol}" == "tcpudp" ]; then - create_rule tcp ${macaddr} ${prio_num} - create_rule udp ${macaddr} ${prio_num} - else - create_rule ${protocol} ${macaddr} ${prio_num} - fi - fi - fi -} - -reload_service() { - # Do not apply rules if ebtables is not present in system - [ -x /usr/sbin/ebtables ] || return; - - clear_existing_rules - config_load easy_qos - config_foreach manage_rule rule -} - -start_service() { - reload_service -} - -service_triggers() { - procd_add_reload_trigger "easy_qos" -} - diff --git a/easy-qos/files/etc/init.d/easy_qos.iptables b/easy-qos/files/etc/init.d/easy_qos.iptables deleted file mode 100755 index d19d78d49..000000000 --- a/easy-qos/files/etc/init.d/easy_qos.iptables +++ /dev/null @@ -1,186 +0,0 @@ -#!/bin/sh /etc/rc.common - -. /usr/share/libubox/jshn.sh - -START=99 -USE_PROCD=1 - -CLIENT_LIST="/tmp/easy_qos_client.list" - -log() { - echo "${@}"|logger -t easy_qos -p debug -} - -exec_log() { - ${@} - if [ "${?}" -ne 0 ]; then - log "Failed to create ${@}"; - fi -} - -get_priority() { - local prio=$(echo $1|tr 'A-Z' 'a-z'); - case "${prio}" in - "lowest") - echo 0;; - "low") - echo 1;; - "besteffort") - echo 2;; - "normal") - echo 3;; - "video") - echo 4;; - "medium") - echo 5;; - "high") - echo 6;; - "highest") - echo 7;; - esac -} - -clean_client_entries() { - [ -f ${CLIENT_LIST} ] && rm ${CLIENT_LIST} -} - -map_client_entries() { - local clients ip mac host - - json_load "$(ubus call router.network 'clients')" - json_get_keys keys - - for key in ${keys}; - do - json_select ${key} - json_get_vars ipaddr macaddr hostname - clients="${macaddr} ${ipaddr} ${hostname};${clients}" - json_select .. - done - - json_init - -# json_add_array "clients" - IFS=";" - for client in ${clients}; - do - macaddr=$(echo ${client} | cut -d" " -f1) - json_add_object "${macaddr//:/_}" - json_add_string "ip" "$(echo ${client} | cut -d" " -f2)" - json_add_string "macaddr" "$(echo ${client} | cut -d" " -f1)" - json_add_string "host" "$(echo ${client} | cut -d" " -f3)" - json_close_object - done - - IFS=' ' - echo `json_dump` > ${CLIENT_LIST} - json_cleanup -} - -# Find the IP of a corresponding mac from arp table -get_ipaddress() { - local clients ip mac host - - json_load "$(cat ${CLIENT_LIST})" - json_get_keys keys - - # jshn seems a bit iffy on having : in key, replace by _ - json_select "${1//:/_}" 2 > /dev/null - json_get_var ip ip - - echo "$ip" -} - -validate_rule_section() -{ - uci_validate_section easy_qos rule "${1}" \ - 'priority:string' \ - 'macaddr:string' \ - 'proto:string:none' \ - 'port:list(uinteger)' \ - 'comment:string:none' -} - -# Clear existing rules before applying new rules -clear_existing_rules() { - local rule=$(iptables -t mangle -S PREROUTING | grep -m 1 MARK |sed 's/-A/-D/1') - while [ -n "${rule}" ]; do - exec_log iptables -t mangle ${rule} - rule=$(iptables -t mangle -S PREROUTING | grep -m 1 MARK |sed 's/-A/-D/1') - done -} - -check_and_create() { - iptables -t mangle -C PREROUTING ${@} 2>/dev/null - # Create rule if not exists - if [ ${?} -ne 0 ]; then - exec_log iptables -t mangle -A PREROUTING ${@} - else - log "Rule exists for ${@}" - fi -} - -create_rule() { - local proto=$1; shift - local src_ip=$1; shift - local mark="0x$1/0x$1"; shift - local ports=$1; - local cmd=""; - - cmd="-j MARK --set-xmark ${mark}"; - if [ -n "${ports}" ]; then - cmd="--match multiport --dports ${ports} ${cmd}"; - fi - - if [ "${proto}" == "icmp" ]; then - cmd="-p icmp -m icmp --icmp-type 8 $cmd" - elif [ "${proto}" == "all" ]; then - cmd="-p all $cmd" - else - cmd="-p ${proto} -m ${proto} $cmd" - fi - cmd="-s ${src_ip} $cmd" - - check_and_create ${cmd} -} - -manage_rule() { - local cfg="$1" - local priority macaddr proto port comment prio_num ip port_list - - validate_rule_section "${1}" || { - log "Validation of section failed" - return 1; - } - - prio_num=$(get_priority ${priority}) - ip=$(get_ipaddress ${macaddr}) - port_list=$(echo ${port}|sed 's/ /,/g') - - if [ -n "${ip}" -a -n "${prio_num}" ]; then - if [ "${proto}" == "none" -o "${proto}" == "tcpudp" ]; then - create_rule tcp ${ip} ${prio_num} ${port_list} - create_rule udp ${ip} ${prio_num} ${port_list} - else - create_rule ${proto} ${ip} ${prio_num} ${port_list} - fi - fi -} - -reload_service() { - clear_existing_rules - map_client_entries - config_load easy_qos - config_foreach manage_rule rule - clean_client_entries -} - -start_service() { - reload_service - echo "Easy QoS installed">/dev/console; -} - -service_triggers() { - procd_add_reload_trigger "easy_qos" -} - diff --git a/easy-qos/files/etc/uci-defaults/60-easyqos-reqs b/easy-qos/files/etc/uci-defaults/60-easyqos-reqs deleted file mode 100644 index cb2ad44c5..000000000 --- a/easy-qos/files/etc/uci-defaults/60-easyqos-reqs +++ /dev/null @@ -1,8 +0,0 @@ -# Add firewall include -uci -q batch <<-EOT - delete firewall.easyqos - set firewall.easyqos=include - set firewall.easyqos.path=/etc/firewall.easyqos - set firewall.easyqos.reload=1 - commit firewall -EOT