#!/bin/sh /etc/rc.common
# Copyright (C) 2006 OpenWrt.org

START=96

boot() {
    . /lib/qos-tplink/api.sh start
}

start() {
	. /lib/qos-tplink/api.sh stop
	##for 605w hwnat
	local qos_state=`uci get qos.setting.qos_enable`
	local hnat_sens=`uci -c /etc/profile.d  get profile.@hwnat[0].bandwidth_control`
	[ "$hnat_sens" == "1" ] && [ "x$qos_state" = "xon" ] && {
		uci set hwnat.module.bandwidth_control=1
		uci commit hwnat
		/lib/cfg_save/config.sh save
		echo "!!!!hwnat bandwidth control set to 1" > /dev/console
		. /bin/hwnat -y
	}
	. /lib/qos-tplink/api.sh start
}

restart() {
	rm -rf /tmp/.qos/
	. /lib/qos-tplink/api.sh stop
	. /lib/qos-tplink/api.sh start
}

stop() {
	. /lib/qos-tplink/api.sh stop
	##for 605w hwnat
	local qos_state=`uci get qos.setting.qos_enable`
	local hnat_care=`uci -c /etc/profile.d  get profile.@hwnat[0].bandwidth_control`
	[ "$hnat_care" == "1" ] && [ "x$qos_state" = "xoff" ] && {
		uci set hwnat.module.bandwidth_control=0
		uci commit hwnat
		/lib/cfg_save/config.sh save
		echo "!!!!hwnat bandwidth control set to 0" > /dev/console
		. /bin/hwnat -y
	}
}

reload() {
	. /lib/qos-tplink/api.sh reload
}

