summaryrefslogtreecommitdiff
path: root/lib/Vyatta/Misc.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Vyatta/Misc.pm')
-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>;