diff options
author | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2009-04-28 23:01:47 -0700 |
---|---|---|
committer | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2009-04-28 23:01:47 -0700 |
commit | 4bb05740120a92338d081bd3f2a2993b87ce3909 (patch) | |
tree | 06c45a5b925457354545796a884ca8101dd21716 /lib | |
parent | 5e7cbd98a5f76adf37f15020b1a9375e388ba37a (diff) | |
parent | cb8a0c4dd7f3ebb47bbda57edb528c1cda278578 (diff) | |
download | vyatta-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-x | lib/Vyatta/Misc.pm | 10 |
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>; |