summaryrefslogtreecommitdiff
path: root/lib/Vyatta
diff options
context:
space:
mode:
authorAn-Cheng Huang <ancheng@vyatta.com>2010-08-12 14:58:11 -0700
committerAn-Cheng Huang <ancheng@vyatta.com>2010-08-12 14:58:11 -0700
commit6e5aa3ce3f8865df2987169057c7f8291b128011 (patch)
treed386de8c4db5197219ec81ca907bb56df2429f18 /lib/Vyatta
parent33413ebeb1ba3e1a6059877df3633e3890d95dd9 (diff)
downloadvyatta-cfg-6e5aa3ce3f8865df2987169057c7f8291b128011.tar.gz
vyatta-cfg-6e5aa3ce3f8865df2987169057c7f8291b128011.zip
add util function to Interface.pm
Diffstat (limited to 'lib/Vyatta')
-rwxr-xr-xlib/Vyatta/Interface.pm26
1 files changed, 26 insertions, 0 deletions
diff --git a/lib/Vyatta/Interface.pm b/lib/Vyatta/Interface.pm
index e45e123..4c7244a 100755
--- a/lib/Vyatta/Interface.pm
+++ b/lib/Vyatta/Interface.pm
@@ -85,6 +85,32 @@ sub interface_types {
return @types;
}
+# get all configured interfaces (in active or working configuration)
+sub get_all_cfg_interfaces {
+ my ($in_active) = @_;
+ my $vfunc = ($in_active ? 'listOrigNodes' : 'listNodes');
+
+ my $cfg = new Vyatta::Config;
+ my @ret_ifs = ();
+ for my $pfx (keys %net_prefix) {
+ my ($type, $vif) = ($net_prefix{$pfx}->{path}, $net_prefix{$pfx}->{vif});
+ my @vifs = (defined($vif)
+ ? ((ref($vif) eq 'ARRAY') ? @{$vif}
+ : ($vif))
+ : ());
+ for my $tif ($cfg->$vfunc("interfaces $type")) {
+ push @ret_ifs, { 'name' => $tif, 'path' => "interfaces $type $tif" };
+ for my $vpath (@vifs) {
+ for my $vnum ($cfg->$vfunc("interfaces $type $tif $vpath")) {
+ push @ret_ifs, { 'name' => "$tif.$vnum",
+ 'path' => "interfaces $type $tif $vpath $vnum" };
+ }
+ }
+ }
+ }
+ return @ret_ifs;
+}
+
# Read ppp config to fine associated interface for ppp device
sub _ppp_intf {
my $dev = shift;