diff options
author | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2008-02-05 16:54:48 -0800 |
---|---|---|
committer | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2008-02-05 16:54:48 -0800 |
commit | 0b8d73903c3a1245c95d3ed92756fe3df649bbed (patch) | |
tree | 67e0342479bc718d35c04e657357b3036419e9cb /scripts/VyattaQosUtil.pm | |
parent | 24b46144a00f1346b0c983884e3f11b91b0c4379 (diff) | |
download | vyatta-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.pm | 15 |
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 |