include $(TOPDIR)/rules.mk
PKG_NAME:=wshaper
-PKG_VERSION:=0.1
+PKG_VERSION:=0.2
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
$(INSTALL_DIR) $(1)/usr/sbin/ $(1)/etc/init.d
$(INSTALL_BIN) ./files/wshaper.htb $(1)/usr/sbin/
$(INSTALL_BIN) ./files/wshaper.init $(1)/etc/init.d/wshaper
+ $(INSTALL_DATA) ./files/wshaper.config $(1)/etc/config/wshaper
endef
$(eval $(call BuildPackage,wshaper))
# Set the following values to somewhat less than your actual download
# and uplink speed. In kilobits. Also set the device that is to be shaped.
-MODULES='sch_ingress sch_sfq sch_htb cls_u32'
-DOWNLINK=2000
-UPLINK=240
-DEV=eth0
+# All config needs to be done in /etc/config/wshaper
+
+. /etc/functions.sh
+config_load wshaper
+for s in downlink uplink network nopriohostdst nopriohostsrc noprioportdst noprioportsrc; do
+ config_get $s settings $s
+done
+
+device=$(uci_get_state network "$network" device)
+[ -z "$device" ] && logger -t wondershaper "Error: Could not find the device for network $network, aborting." && exit 1
+[ -z "$downlink" ] && logger -t wondershaper "Error: Downlink speed not set, aborting." && exit 1
+[ -z "$uplink" ] && logger -t wondershaper "Error: Uplink speed not set, aborting." && exit 1
+
+MODULES='sch_ingress sch_sfq sch_htb cls_u32 act_police'
+DOWNLINK="$downlink"
+UPLINK="$uplink"
+DEV="$device"
# low priority OUTGOING traffic - you can leave this blank if you want
# low priority source netmasks
-NOPRIOHOSTSRC=
+NOPRIOHOSTSRC="$nopriohostsrc"
# low priority destination netmasks
-NOPRIOHOSTDST=
+NOPRIOHOSTDST="$nopriohostdst"
# low priority source ports
-NOPRIOPORTSRC=
+NOPRIOPORTSRC="$noprioportsrc"
# low priority destination ports
-NOPRIOPORTDST="21"
+NOPRIOPORTDST="$noprioportdst"
if [ "$1" = "status" ]
then
tc filter add dev $DEV parent ffff: protocol ip prio 50 u32 match ip src \
0.0.0.0/0 police rate ${DOWNLINK}kbit burst 10k drop flowid :1
+
+logger -t wondershaper "Wondershaper was started on device $device."