summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorStephen Hemminger <stephen.hemminger@vyatta.com>2009-04-28 23:01:47 -0700
committerStephen Hemminger <stephen.hemminger@vyatta.com>2009-04-28 23:01:47 -0700
commit4bb05740120a92338d081bd3f2a2993b87ce3909 (patch)
tree06c45a5b925457354545796a884ca8101dd21716 /lib
parent5e7cbd98a5f76adf37f15020b1a9375e388ba37a (diff)
parentcb8a0c4dd7f3ebb47bbda57edb528c1cda278578 (diff)
downloadvyatta-cfg-4bb05740120a92338d081bd3f2a2993b87ce3909.tar.gz
vyatta-cfg-4bb05740120a92338d081bd3f2a2993b87ce3909.zip
Merge branch 'jenner' of 192.168.100.1:git/vyatta-cfg into jenner
Diffstat (limited to 'lib')
-rwxr-xr-xlib/Vyatta/Misc.pm10
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/Vyatta/Misc.pm b/lib/Vyatta/Misc.pm
index e5d0738..01f1537 100755
--- a/lib/Vyatta/Misc.pm
+++ b/lib/Vyatta/Misc.pm
@@ -102,12 +102,18 @@ sub getInterfaces {
return @interfaces;
}
+# get list of IPv4 and IPv6 addresses
+# if name is defined then get the addresses on that interface
+# if type is defined then restrict to that type (inet, inet6)
sub getIP {
my ( $name, $type ) = @_;
+ my @args = qw(ip addr show);
my @addresses;
- open my $ipcmd, '-|'
- or exec qw(ip addr show dev), $name
+ push @args, ('dev', $name) if $name;
+
+ open my $ipcmd, '-|'
+ or exec @args
or die "ip addr command failed: $!";
<$ipcmd>;