Do a fancier job of comparing networks

This commit is contained in:
Tom Eastep 2011-02-03 09:44:46 -08:00
parent 27684908c4
commit 4ed4443abb
2 changed files with 11 additions and 1 deletions

View File

@ -122,7 +122,7 @@ sub process_accounting_rule( ) {
my $prevnet = $tables{$table};
if ( $prevnet ) {
fatal_error "Previous net associated with $table ($prevnet) does not match this one ($net)" unless $net eq $prevnet;
fatal_error "Previous net associated with $table ($prevnet) does not match this one ($net)" unless compare_nets( $net , $prevnet );
} else {
$tables{$table} = $net;
}

View File

@ -59,6 +59,7 @@ our @EXPORT = qw( ALLIPv4
validate_address
validate_net
decompose_net
compare_nets
validate_host
validate_range
ip_range_explicit
@ -284,6 +285,15 @@ sub decompose_net( $ ) {
}
sub compare_nets( $$ ) {
my ( @net1, @net2 );
@net1 = decompose_net( $_[0] );
@net2 = decompose_net( $_[1] );
$net1[0] eq $net2[0] && $net1[1] == $net2[1];
}
sub allipv4() {
@allipv4;
}