summaryrefslogtreecommitdiff
path: root/scripts/vyatta-qos-util.pl
diff options
context:
space:
mode:
authorStephen Hemminger <stephen.hemminger@vyatta.com>2008-11-20 12:16:02 -0800
committerStephen Hemminger <stephen.hemminger@vyatta.com>2008-11-20 20:34:16 -0800
commit790663c88fb291ddb5b645bdde62d8229d5e115b (patch)
treebdf236cc76437e82df9254d3cb89ef1c271424bc /scripts/vyatta-qos-util.pl
parent22fba825c57ed336bca64ff154bbd911bc6754d5 (diff)
downloadvyatta-cfg-qos-790663c88fb291ddb5b645bdde62d8229d5e115b.tar.gz
vyatta-cfg-qos-790663c88fb291ddb5b645bdde62d8229d5e115b.zip
Change perl module names from VyattaQosXXX to Vyatta::Qos:XXX
Use more multi-level directory hierarchy instead of having all modules at top level.
Diffstat (limited to 'scripts/vyatta-qos-util.pl')
-rwxr-xr-xscripts/vyatta-qos-util.pl85
1 files changed, 33 insertions, 52 deletions
diff --git a/scripts/vyatta-qos-util.pl b/scripts/vyatta-qos-util.pl
index 8c3bafd..a19baee 100755
--- a/scripts/vyatta-qos-util.pl
+++ b/scripts/vyatta-qos-util.pl
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#! /usr/bin/perl
#
# Utility routines for validating input
# These functions don't change existing QoS parameters
@@ -18,62 +18,43 @@
# All Rights Reserved.
# **** End License ****
-use lib "/opt/vyatta/share/perl5/";
-use VyattaQosUtil;
+use lib "/opt/vyatta/share/perl5";
+use Vyatta::Qos::Util qw( getPercent getRate getBurstSize getProtocol
+ getDsfield getTime );
use Getopt::Long;
-my ($percent, $rate, $burst, $protocol, $dsfield, $time);
-
-GetOptions(
- "percent-or-rate=s" => \$percent,
- "rate=s" => \$rate,
- "burst=s" => \$burst,
- "protocol=s" => \$protocol,
- "dscp=s" => \$dsfield,
- "tos=s" => \$dsfield,
- "time=s" => \$time,
-);
-
-if ( defined $percent ) {
- if ($percent =~ /%$/) {
- my $p = VyattaQosUtil::getPercent($percent);
- } else {
- my $r = VyattaQosUtil::getRate($percent);
+sub getPercentOrRate {
+ my $percent = shift;
+ if ( $percent =~ /%$/ ) {
+ return getPercent($percent);
+ }
+ else {
+ return getRate($percent);
}
- exit 0;
-}
-
-if ( defined $rate ) {
- my $r = VyattaQosUtil::getRate($rate);
- exit 0;
-}
-
-if ( defined $burst ) {
- my $b = VyattaQosUtil::getBurstSize($burst);
- exit 0;
-}
-
-if ( defined $protocol ) {
- my $p = VyattaQosUtil::getProtocol($protocol);
- exit 0;
}
-if ( defined $dsfield ) {
- my $d = VyattaQosUtil::getDsfield($dsfield);
- exit 0;
+sub usage {
+ print <<EOF;
+ usage:
+ vyatta-qos-util.pl --percent value
+ vyatta-qos-util.pl --percent-or-rate value
+ vyatta-qos-util.pl --rate rate
+ vyatta-qos-util.pl --time time
+ vyatta-qos-util.pl --burst size
+ vyatta-qos-util.pl --protocol protocol
+ vyatta-qos-util.pl --dscp tos|dsfield
+EOF
+ exit 1;
}
-if ( defined $time ) {
- my $t = VyattaQosUtil::getTime($time);
- exit 0;
-}
+GetOptions(
+ "percent=s" => sub { getPercent( $_[1] ); },
+ "percent-or-rate=s" => sub { getPercentOrRate( $_[1] ); },
+ "rate=s" => sub { getRate( $_[1] ); },
+ "burst=s" => sub { getBurstSize( $_[1] ); },
+ "protocol=s" => sub { getProtocol( $_[1] ); },
+ "dscp=s" => sub { getDsfield( $_[1] ); },
+ "tos=s" => sub { getDsfield( $_[1] ); },
+ "time=s" => sub { getTime( $_[1] ); },
+) or usage();
-print <<EOF;
-usage: vyatta-qos-util.pl --percent-or-rate value
- vyatta-qos-util.pl --rate rate
- vyatta-qos-util.pl --time time
- vyatta-qos-util.pl --burst size
- vyatta-qos-util.pl --protocol protocol
- vyatta-qos-util.pl --dscp tos|dsfield
-EOF
-exit 1;