summaryrefslogtreecommitdiff
path: root/scripts/VyattaQosUtil.pm
diff options
context:
space:
mode:
authorStephen Hemminger <stephen.hemminger@vyatta.com>2008-02-05 16:54:48 -0800
committerStephen Hemminger <stephen.hemminger@vyatta.com>2008-02-05 16:54:48 -0800
commit0b8d73903c3a1245c95d3ed92756fe3df649bbed (patch)
tree67e0342479bc718d35c04e657357b3036419e9cb /scripts/VyattaQosUtil.pm
parent24b46144a00f1346b0c983884e3f11b91b0c4379 (diff)
downloadvyatta-cfg-qos-0b8d73903c3a1245c95d3ed92756fe3df649bbed.tar.gz
vyatta-cfg-qos-0b8d73903c3a1245c95d3ed92756fe3df649bbed.zip
add support for match based on incoming device and vlan
This is preliminary (still needs testing) but get the syntax and basic structure in place.
Diffstat (limited to 'scripts/VyattaQosUtil.pm')
-rw-r--r--scripts/VyattaQosUtil.pm15
1 files changed, 12 insertions, 3 deletions
diff --git a/scripts/VyattaQosUtil.pm b/scripts/VyattaQosUtil.pm
index 3a115db..0c9ab83 100644
--- a/scripts/VyattaQosUtil.pm
+++ b/scripts/VyattaQosUtil.pm
@@ -1,7 +1,7 @@
package VyattaQosUtil;
use POSIX;
require Exporter;
-@EXPORT = qw/getRate getSize getProtocol getDsfield interfaceRate/;
+@EXPORT = qw/getRate getSize getProtocol getDsfield getIfIndex interfaceRate/;
use strict;
sub get_num {
@@ -119,12 +119,21 @@ sub getDsfield {
last;
}
}
- close($ds);
+ close($ds) or die "read $dsFileName error\n";
return $match;
}
-# Utility routines
+sub getIfIndex {
+ my ($str) = @_;
+
+ defined $str or return;
+ open my $sysfs, "<", "/sys/class/net/$str/ifindex" || die "Unknown interface $str\n";
+ my $ifindex = <$sysfs>;
+ close($sysfs) or die "read sysfs error\n";
+ return $ifindex;
+}
+
## interfaceRate("eth0")
# return result in bits per second