X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=FS%2FFS%2Faddr_block.pm;h=eb84dafc32ed03d0c201a1c46599b314d043e8fe;hp=ba0f61db11b1ff8d36b6ac24ce1bb7cedf3e70dc;hb=b79b0ebca0c15ad527de3d589cda36da63b0601e;hpb=1af8ff7f48f7259fc99f090c301c84b9680fdb4d diff --git a/FS/FS/addr_block.pm b/FS/FS/addr_block.pm index ba0f61db1..eb84dafc3 100755 --- a/FS/FS/addr_block.pm +++ b/FS/FS/addr_block.pm @@ -207,6 +207,23 @@ sub cidr { $self->NetAddr->cidr; } +=item free_addrs + +Returns a 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_in_block($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 @@ -233,7 +250,7 @@ sub next_free_addr { $selfaddr->addr, $selfaddr->network->addr, $selfaddr->broadcast->addr, - FS::IP_Mixin->used_addresses($self) + FS::IP_Mixin->used_addresses_in_block($self) ); # just do a linear search of the block @@ -416,4 +433,3 @@ now because that's the smallest block that makes any sense at all. =cut 1; -