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

START=50

parse_device() {
	local cfg="$1" ip download upload
	
	config_get ip "$cfg" ip
	config_get download "$cfg" download
	config_get upload "$cfg" upload
	
	eqos add $ip $download $upload
}

eqos_start() {
	local cfg="$1" enabled download upload
	
	config_get_bool enabled "$cfg" enabled 0
	[ $enabled -eq 0 ] && return 0
	
	config_get download "$cfg" download
	config_get upload "$cfg" upload
	
	eqos start $download $upload
	
	config_foreach parse_device device
}

start() {
	eqos stop
	
	config_load eqos
	config_foreach eqos_start eqos
}

stop() {
	eqos stop
}