#!/bin/bash
# 
# shows current traffic shaping settings

DEFDEV=eth0

TEMP=`getopt -o d: -n '$0' -- "$@"`
if [ $? -ne 0 ]; then
	echo "usage: $0 [-d dev]"
	exit 1
fi

eval set -- "$TEMP"

DEV=""

while true; do
	case "$1" in
		-d) DEV=$2; echo "using device $DEV"; shift 2;;
		--) shift; break;;
		*)  echo "Internal error. Help, i don't know what to do!!!"; 
		   exit 1;;
	esac
done

if [ "$DEV" == "" ]; then
	DEV=$DEFDEV
	echo "using default device $DEV"
fi

echo "current settings:"

for i in qdisc class filter
do
	tc $i show dev $DEV
	if [ $? -ne 0 ]; then
		echo "Error: I apologize. I could not show you the current settings for $i on device $DEV :("
		exit 1
	fi
done

echo -e "\nbye!"
