summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorStephen Hemminger <stephen.hemminger@vyatta.com>2009-04-28 22:38:48 -0700
committerStephen Hemminger <stephen.hemminger@vyatta.com>2009-04-28 22:38:48 -0700
commit91be36bece8c9ebc1ed89e36a7b2f52fe9a9fb67 (patch)
tree9c5b470c02a260d8aadf84415cdd3a6c9d6987ab /lib
parent0eaba8dad441707b699749f1ef80409e05897c4b (diff)
downloadvyatta-cfg-91be36bece8c9ebc1ed89e36a7b2f52fe9a9fb67.tar.gz
vyatta-cfg-91be36bece8c9ebc1ed89e36a7b2f52fe9a9fb67.zip
Extend getIP() to be able to get all addresses
Only have one interface for getting addresses.
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>;