summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Vyatta/Interface.pm7
-rwxr-xr-xlib/Vyatta/Misc.pm4
2 files changed, 8 insertions, 3 deletions
diff --git a/lib/Vyatta/Interface.pm b/lib/Vyatta/Interface.pm
index ead45fd..687ef67 100644
--- a/lib/Vyatta/Interface.pm
+++ b/lib/Vyatta/Interface.pm
@@ -175,7 +175,7 @@ sub using_dhcp {
# return array of current addresses (on system)
sub address {
- my $self = shift;
+ my ($self, $type) = @_;
open my $ipcmd, "ip addr show dev $self->{name} |"
or die "ip addr command failed: $!";
@@ -185,6 +185,11 @@ sub address {
while (<$ipcmd>) {
my ($proto, $addr) = split;
next unless ($proto =~ /inet/);
+ if ($type) {
+ next if ($proto eq 'inet6' && $type != 6);
+ next if ($proto eq 'inet' && $type != 4);
+ }
+
push @addresses, $addr;
}
close $ipcmd;
diff --git a/lib/Vyatta/Misc.pm b/lib/Vyatta/Misc.pm
index 60c50b4..a7bd075 100755
--- a/lib/Vyatta/Misc.pm
+++ b/lib/Vyatta/Misc.pm
@@ -104,7 +104,7 @@ my %type_hash = (
'pointtopoint' => IFF_POINTOPOINT,
);
-# getInterfacesIPadresses() returns IP addresses for the interface type passed to it
+# getInterfacesIPadresses() returns IPv4 addresses for the interface type
# possible type of interfaces : 'broadcast', 'pointopoint', 'multicast', 'all'
# the loopback IP address is never returned with any of the above parameters
sub getInterfacesIPadresses {
@@ -126,7 +126,7 @@ sub getInterfacesIPadresses {
my $flags = $intf->flags();
next if ($flags & IFF_LOOPBACK);
- my @addresses = $intf->address();
+ my @addresses = $intf->address(4);
push @ips, @addresses;
}
return @ips;