summaryrefslogtreecommitdiff
path: root/FS/FS/IP_Mixin.pm
diff options
context:
space:
mode:
authorMark Wells <mark@freeside.biz>2013-12-10 20:08:43 -0800
committerMark Wells <mark@freeside.biz>2013-12-10 20:08:43 -0800
commita4c1077430ac3b053c30084dcf76c54be45dca08 (patch)
tree2f225a7519cc9f0f83b4b7b99986b99cdb37f2e3 /FS/FS/IP_Mixin.pm
parentc27f80ec10180391d00286bf50dfbf09a96c1b00 (diff)
Designate forbidden address ranges, #25530
Diffstat (limited to 'FS/FS/IP_Mixin.pm')
-rw-r--r--FS/FS/IP_Mixin.pm11
1 files changed, 10 insertions, 1 deletions
diff --git a/FS/FS/IP_Mixin.pm b/FS/FS/IP_Mixin.pm
index fdeb51d..b3c1052 100644
--- a/FS/FS/IP_Mixin.pm
+++ b/FS/FS/IP_Mixin.pm
@@ -200,12 +200,21 @@ sub check_ip_addr {
return '' if $addr eq '';
my $na = $self->NetAddr
or return "Can't parse address '$addr'";
+ # if there's a chosen address block, check that the address is in it
if ( my $block = $self->addr_block ) {
if ( !$block->NetAddr->contains($na) ) {
return "Address $addr not in block ".$block->cidr;
}
}
- # this returns '' if the address is in use by $self.
+ # if the address is in any designated ranges, check that they don't
+ # disallow use
+ foreach my $range (FS::addr_range->any_contains($addr)) {
+ if ( !$range->allow_use ) {
+ return "Address $addr is in ".$range->desc." range ".$range->as_string;
+ }
+ }
+ # check that nobody else is sitting on the address
+ # (this returns '' if the address is in use by $self)
if ( my $dup = $self->is_used($self->ip_addr) ) {
return "Address $addr in use by $dup";
}