X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2FIP_Mixin.pm;h=1967ccd573399c618234ca37df6f658e1dcc2a2e;hb=d6e48aee6cf1e19d001b8837288cf2630d6917e6;hp=0b138dd21e6a39ffe2360bb730711da60110d1e7;hpb=f56debe7d5703435e6a3cdd4c4c90b9de2527ae7;p=freeside.git diff --git a/FS/FS/IP_Mixin.pm b/FS/FS/IP_Mixin.pm index 0b138dd21..1967ccd57 100644 --- a/FS/FS/IP_Mixin.pm +++ b/FS/FS/IP_Mixin.pm @@ -94,14 +94,9 @@ sub ip_check { $self->ip_addr(''); } - # strip user-entered leading 0's from IPv4 addresses - # Parsers like NetAddr::IP interpret them as octal instead of decimal - $self->ip_addr( - join( '.', ( - map{ int($_) } - split( /\./, $self->ip_addr ) - )) - ) if $self->ip_addr =~ /\./ && $self->ip_addr =~ /[\.^]0/; + # Will strip extraneous leading zeros from ip adddresses + # e.g. 10.0.022.220 corrected to 10.0.22.220 + $self->ut_ip46n('ip_addr'); if ( $self->ip_addr and !$self->router @@ -273,18 +268,22 @@ sub router { FS::router->by_key($self->routernum); } -=item used_addresses [ BLOCK ] +=item used_addresses [ FS::addr_block ] -Returns a list of all addresses (in BLOCK, or in all blocks) -that are in use. If called as an instance method, excludes -that instance from the search. +Returns a list of all addresses in use within the given L. + +If called as an instance method, excludes that instance from the search. =cut sub used_addresses { - my $self = shift; - my $block = shift; - return ( map { $_->_used_addresses($block, $self) } @subclasses ); + my ($self, $block) = @_; + + ( + $block->ip_gateway ? $block->ip_gateway : (), + $block->NetAddr->broadcast->addr, + map { $_->_used_addresses($block, $self ) } @subclasses + ); } sub _used_addresses {