forked from extern/shorewall_code
Do a fancier job of comparing networks
This commit is contained in:
parent
27684908c4
commit
4ed4443abb
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user