2006-10-06 17:38:48 +00:00
|
|
|
#!/bin/sh
|
2011-01-20 17:33:41 +00:00
|
|
|
# Copyright (C) 2011 OpenWrt.org
|
|
|
|
|
|
|
|
. /etc/functions.sh
|
|
|
|
|
|
|
|
include /lib/network
|
|
|
|
|
|
|
|
get_ifname() {
|
|
|
|
local interface="$1"
|
|
|
|
local cfgt
|
|
|
|
|
|
|
|
scan_interfaces
|
|
|
|
config_get cfgt "$interface" TYPE
|
|
|
|
[ "$cfgt" == "interface" ] && config_get "$interface" ifname
|
|
|
|
}
|
|
|
|
|
|
|
|
config_cb() {
|
|
|
|
config_get TYPE "$CONFIG_SECTION" TYPE
|
|
|
|
[ "interface" == "$TYPE" ] && {
|
|
|
|
config_get device "$CONFIG_SECTION" ifname
|
|
|
|
[ -z "$device" ] && device="$(get_ifname ${CONFIG_SECTION})"
|
|
|
|
config_set "$CONFIG_SECTION" device "$device"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
config_load qos
|
|
|
|
|
|
|
|
print_comments() {
|
|
|
|
echo ''
|
|
|
|
echo '# Interface: '"$1"
|
|
|
|
echo '# Direction: '"$2"
|
|
|
|
echo '# Stats: '"$3"
|
|
|
|
echo ''
|
|
|
|
}
|
|
|
|
|
2011-02-21 01:33:27 +00:00
|
|
|
get_device() {
|
|
|
|
( config_load network; scan_interfaces; config_get "$1" ifname )
|
|
|
|
}
|
|
|
|
|
2011-01-20 17:33:41 +00:00
|
|
|
interface_stats() {
|
|
|
|
local interface="$1"
|
|
|
|
local device
|
|
|
|
|
2011-02-21 01:33:27 +00:00
|
|
|
device="$(get_device "$interface")"
|
|
|
|
[ -z "$device" ] && config_get device "$interface" device
|
2011-01-20 17:33:41 +00:00
|
|
|
config_get_bool enabled "$interface" enabled 1
|
|
|
|
[ -z "$device" -o 1 -ne "$enabled" ] && {
|
|
|
|
return 1
|
|
|
|
}
|
2011-02-21 01:33:27 +00:00
|
|
|
config_get_bool halfduplex "$interface" halfduplex 0
|
2011-01-20 17:33:41 +00:00
|
|
|
|
2011-02-21 01:33:27 +00:00
|
|
|
if [ 1 -ne "$halfduplex" ]; then
|
2011-01-20 17:33:41 +00:00
|
|
|
unset halfduplex
|
|
|
|
print_comments "$interface" "Egress" "Start"
|
|
|
|
tc -s class show dev "$device"
|
|
|
|
print_comments "$interface" "Egress" "End"
|
2011-02-21 01:33:27 +00:00
|
|
|
id="root"
|
|
|
|
else
|
|
|
|
id=""
|
|
|
|
fi
|
2011-01-20 17:33:41 +00:00
|
|
|
|
|
|
|
print_comments "$interface" "Ingress${halfduplex:+/Egress}" "Start"
|
2011-02-21 01:33:27 +00:00
|
|
|
tc -s class show dev "$(tc filter show dev $device $id | grep mirred | sed -e 's,.*\(ifb.*\)).*,\1,')"
|
2011-01-20 17:33:41 +00:00
|
|
|
print_comments "$interface" "Ingress${halfduplex:+/Egress}" "End"
|
|
|
|
}
|
|
|
|
|
|
|
|
[ -z "$1" ] && config_foreach interface_stats interface || interface_stats "$1"
|