X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Faddr_block.pm;h=5fd64bf7a861b6df848f92a9f844f93bb047b576;hb=b0888dc8399fc4e8d75c874c00d01366eacf5596;hp=ba0f61db11b1ff8d36b6ac24ce1bb7cedf3e70dc;hpb=8dd41f364aaba88969dfd0908feb22709025e7f6;p=freeside.git diff --git a/FS/FS/addr_block.pm b/FS/FS/addr_block.pm index ba0f61db1..5fd64bf7a 100755 --- a/FS/FS/addr_block.pm +++ b/FS/FS/addr_block.pm @@ -207,6 +207,27 @@ sub cidr { $self->NetAddr->cidr; } +=item free_addrs + +Returns an aref sorted list of free addresses in the block. + +=cut + +sub free_addrs { + my $self = shift; + + my %used_addr_map = + map {$_ => 1} + FS::IP_Mixin->used_addresses($self), + FS::Conf->new()->config('exclude_ip_addr'); + + [ + grep { !exists $used_addr_map{$_} } + map { $_->addr } + $self->NetAddr->hostenum + ]; +} + =item next_free_addr Returns a NetAddr::IP object corresponding to the first unassigned address @@ -416,4 +437,3 @@ now because that's the smallest block that makes any sense at all. =cut 1; -