diff options
author | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2009-05-28 16:16:01 -0700 |
---|---|---|
committer | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2009-05-28 16:16:01 -0700 |
commit | ad9cb0d7a1d1ca64825b7efbc41ab030d496013b (patch) | |
tree | 840969fac1bb79df51a63bf8b5c4c3226e1279c9 | |
parent | c8a0fb67591736430047a264c1bf1f2c1078cd3a (diff) | |
parent | 9488f3c64e0c29ce22631fae3f22ffb73b8349cb (diff) | |
download | vyatta-cfg-qos-ad9cb0d7a1d1ca64825b7efbc41ab030d496013b.tar.gz vyatta-cfg-qos-ad9cb0d7a1d1ca64825b7efbc41ab030d496013b.zip |
Merge branch 'jenner' of nehalam:git/vyatta-cfg-qos into jenner
-rw-r--r-- | lib/Vyatta/Qos/NetworkEmulator.pm | 16 | ||||
-rw-r--r-- | lib/Vyatta/Qos/Util.pm | 23 |
2 files changed, 14 insertions, 25 deletions
diff --git a/lib/Vyatta/Qos/NetworkEmulator.pm b/lib/Vyatta/Qos/NetworkEmulator.pm index 1fb9fc6..2a87407 100644 --- a/lib/Vyatta/Qos/NetworkEmulator.pm +++ b/lib/Vyatta/Qos/NetworkEmulator.pm @@ -23,33 +23,23 @@ use warnings; require Vyatta::Config; use Vyatta::Qos::Util; -my %fields = ( - _rate => undef, - _burst => undef, - _limit => undef, - _delay => undef, - _drop => undef, - _corrupt => undef, - _reorder => undef, -); - sub new { my ( $that, $config ) = @_; my $level = $config->setLevel(); my $class = ref($that) || $that; - my $self = {%fields}; + my $self = { }; my $bw = $config->returnValue("bandwidth"); $self->{_rate} = getRate( $bw ) if ($bw); + my $delay = $config->returnValue("network-delay"); + $self->{_delay} = getTime($delay) if ($delay); $self->{_burst} = $config->returnValue("burst"); $self->{_limit} = $config->returnValue("queue-limit"); - $self->{_delay} = getTime($config->returnValue("network-delay")); $self->{_drop} = $config->returnValue("packet-loss"); $self->{_corrupt} = $config->returnValue("packet-corruption"); $self->{_reorder} = $config->returnValue("packet-reordering"); - return bless $self, $class; } diff --git a/lib/Vyatta/Qos/Util.pm b/lib/Vyatta/Qos/Util.pm index 7f5454d..151b1d3 100644 --- a/lib/Vyatta/Qos/Util.pm +++ b/lib/Vyatta/Qos/Util.pm @@ -113,18 +113,17 @@ 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; + if (defined $suffix && $suffix ne '%' ) { + die "$percent incorrect suffix (expect %)\n"; + } elsif (! defined $num) { + die "$percent is not a valid percent (not a number)\n"; + } elsif ( $num < 0 ) { + die "$percent is not a acceptable percent (negative value)\n"; + } elsif ( $num > 100 ) { + die "$percent is not a acceptable percent (greater than 100%)\n"; + } else { + return $num; + } } # Default time units for tc are usec. |