summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rwxr-xr-xlib/Vyatta/Interface.pm26
1 files changed, 26 insertions, 0 deletions
diff --git a/lib/Vyatta/Interface.pm b/lib/Vyatta/Interface.pm
index ff9e067..6d8de08 100755
--- a/lib/Vyatta/Interface.pm
+++ b/lib/Vyatta/Interface.pm
@@ -85,6 +85,32 @@ sub interface_types {
return @types;
}
+# check to see if an address is unique in the working configuration
+sub is_uniq_address {
+ my $ip = pop(@_);
+ my @cfgifs = get_all_cfg_interfaces();
+ my $config = new Vyatta::Config;
+ my %addr_hash = ();
+ foreach my $intf ( @cfgifs ) {
+ my $addrs = [ ];
+ my $path = "$intf->{'path'}";
+ if ($path =~ /openvpn/) {
+ $addrs = [$config->listNodes("$path local-address")];
+ } else {
+ $addrs = [$config->returnValues("$path address")];
+ }
+ foreach my $addr ( @{$addrs} ){
+ if (not exists $addr_hash{$addr}){
+ $addr_hash{$addr} = { _intf => [ $intf->{name} ] };
+ } else {
+ $addr_hash{$addr}->{_intf} =
+ [ @{$addr_hash{$addr}->{_intf}}, $intf->{name} ];
+ }
+ }
+ }
+ return ((scalar @{$addr_hash{$ip}->{_intf}}) <= 1);
+}
+
# get all configured interfaces (in active or working configuration)
sub get_all_cfg_interfaces {
my ($in_active) = @_;