diff options
author | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2009-05-19 10:10:59 -0700 |
---|---|---|
committer | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2009-05-19 10:10:59 -0700 |
commit | e955a55bcdf42ee9079e9d9575b53ae8c050c122 (patch) | |
tree | cea95d99cc561600d1bbf9882d64a081d39da274 /lib/Vyatta/Qos/Util.pm | |
parent | df1d6348323708b34958cd622e02cbba122c748a (diff) | |
download | vyatta-cfg-qos-e955a55bcdf42ee9079e9d9575b53ae8c050c122.tar.gz vyatta-cfg-qos-e955a55bcdf42ee9079e9d9575b53ae8c050c122.zip |
Move getAutoRate into Util
The getAutoRate function is needed by WRED as well
Diffstat (limited to 'lib/Vyatta/Qos/Util.pm')
-rw-r--r-- | lib/Vyatta/Qos/Util.pm | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/lib/Vyatta/Qos/Util.pm b/lib/Vyatta/Qos/Util.pm index c78e762..3aefbd8 100644 --- a/lib/Vyatta/Qos/Util.pm +++ b/lib/Vyatta/Qos/Util.pm @@ -20,7 +20,7 @@ use strict; use warnings; our @EXPORT = - qw(getRate getPercent getBurstSize getProtocol getDsfield getTime); + qw(getRate getPercent getBurstSize getProtocol getDsfield getTime getAutoRate); our @EXPORT_OK = qw(interfaceRate getIfIndex); use base qw(Exporter); @@ -65,6 +65,25 @@ my %rates = ( 'tbps' => 8000000000000., ); +# Rate can be something like "auto" or "10.2mbit" +sub getAutoRate { + my ( $rate, $dev ) = @_; + + if ( $rate eq "auto" ) { + $rate = interfaceRate($dev); + if ( !defined $rate ) { + print STDERR + "Interface $dev speed cannot be determined (assuming 10mbit)\n"; + $rate = 10000000; + } + } + else { + $rate = getRate($rate); + } + + return $rate; +} + sub getRate { my $rate = shift; my ( $num, $suffix ) = get_num($rate); |