diff options
author | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2008-09-05 15:03:30 -0700 |
---|---|---|
committer | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2008-09-05 15:03:30 -0700 |
commit | 200fb453f43a3f0406c14b9003ca5a1e6f7587f4 (patch) | |
tree | 02a1a92a6952afabbb861c15f10ef908fa4b5f4a /scripts/VyattaQosUtil.pm | |
parent | dae88a60a1b40555db65f19a417b0600055a4b51 (diff) | |
download | vyatta-cfg-qos-200fb453f43a3f0406c14b9003ca5a1e6f7587f4.tar.gz vyatta-cfg-qos-200fb453f43a3f0406c14b9003ca5a1e6f7587f4.zip |
Workaround CLI regex problem
Recent CLI changes seem to have broken working templates that
do regex matching. Workaround this by doing the syntax checking
all in the perl script
Bugfix: 3553
Diffstat (limited to 'scripts/VyattaQosUtil.pm')
-rw-r--r-- | scripts/VyattaQosUtil.pm | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/scripts/VyattaQosUtil.pm b/scripts/VyattaQosUtil.pm index 668f5c1..82dfd6b 100644 --- a/scripts/VyattaQosUtil.pm +++ b/scripts/VyattaQosUtil.pm @@ -17,7 +17,7 @@ package VyattaQosUtil; require Exporter; -@EXPORT = qw/getRate getBurstSize getProtocol getDsfield getIfIndex interfaceRate/; +@EXPORT = qw/getRate getPercent getBurstSize getProtocol getDsfield getIfIndex interfaceRate/; use strict; sub get_num { @@ -84,6 +84,23 @@ sub getRate { } } +sub getPercent { + my $percent = shift; + my ($num, $suffix) = get_num($percent); + + ($suffix eq '%') + or die "$percent incorrect suffix (expect %)\n"; + defined $num + or die "$percent is not a valid percent bandwidth (not a number)\n"; + ($num >= 0) + or die "$percent is not a acceptable percent bandwidth (negative value)\n"; + ($num <= 100) + or die "$percent is not a acceptable percent bandwidth (greater than 100%)\n"; + + return $num; +} + + # Default time units for tc are usec. my %timeunits = ( 's' => 1000000, |