summaryrefslogtreecommitdiff
path: root/lib/Vyatta
diff options
context:
space:
mode:
authorStephen Hemminger <stephen.hemminger@vyatta.com>2009-01-13 10:01:39 -0800
committerStephen Hemminger <stephen.hemminger@vyatta.com>2009-01-13 10:01:39 -0800
commit8ec813a09136b167c1ac93cd049c6945ec6acddb (patch)
tree5649c1fd1b4da79deee38ca9e783135b6475ff2e /lib/Vyatta
parentc368665647b9ac72efc161c6e291cba8c3674628 (diff)
downloadvyatta-cfg-8ec813a09136b167c1ac93cd049c6945ec6acddb.tar.gz
vyatta-cfg-8ec813a09136b167c1ac93cd049c6945ec6acddb.zip
Ignore IPV6 addresses in getInterfacesIPadresses
This routine is used by DHCP server and needs to ignore IPV6 addresses. NB: Does not fix bogus spellung.
Diffstat (limited to 'lib/Vyatta')
-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;