mirror of
https://gitlab.com/shorewall/code.git
synced 2024-11-07 16:24:01 +01:00
Refactor ALL_ACASTS code
Signed-off-by: Tom Eastep <teastep@shorewall.net>
This commit is contained in:
parent
b253be8a69
commit
8d4e79650e
@ -7478,9 +7478,9 @@ sub have_address_variables() {
|
||||
#
|
||||
# Generate setting of run-time global shell variables
|
||||
#
|
||||
sub set_global_variables( $$ ) {
|
||||
sub set_global_variables( $$$ ) {
|
||||
|
||||
my ( $setall, $conditional ) = @_;
|
||||
my ( $setall, $conditional, $call_generate_all_acasts ) = @_;
|
||||
|
||||
if ( $conditional ) {
|
||||
my ( $interface, @interfaces );
|
||||
@ -7523,7 +7523,7 @@ sub set_global_variables( $$ ) {
|
||||
emit 'ALL_BCASTS="$(get_all_bcasts) 255.255.255.255"';
|
||||
emit $interfacebcasts{$_} for sortkeysiftest %interfacebcasts;
|
||||
} else {
|
||||
generate_all_acasts;
|
||||
emit $call_generate_all_acasts;
|
||||
emit $interfaceacasts{$_} for sortkeysiftest %interfaceacasts;
|
||||
}
|
||||
}
|
||||
|
@ -276,6 +276,11 @@ sub generate_script_2() {
|
||||
|
||||
emit "}\n"; # End of initialize()
|
||||
|
||||
#
|
||||
# Conditionally emit the 'generate_all_acasts() function
|
||||
#
|
||||
my $call_generate_all_acasts = $family == F_IPV6 && ! have_capability( 'ADDRTYPE' ) && generate_all_acasts;
|
||||
|
||||
emit( '' ,
|
||||
'#' ,
|
||||
'# Set global variables holding detected IP information' ,
|
||||
@ -297,8 +302,6 @@ sub generate_script_2() {
|
||||
);
|
||||
}
|
||||
|
||||
emit( 'local iface', '' ) if $family == F_IPV6;
|
||||
|
||||
map_provider_to_interface if have_providers;
|
||||
|
||||
if ( $global_variables ) {
|
||||
@ -315,7 +318,7 @@ sub generate_script_2() {
|
||||
|
||||
if ( $global_variables == ( ALL_COMMANDS | NOT_RESTORE ) ) {
|
||||
verify_required_interfaces(0);
|
||||
set_global_variables($family == F_IPV6, 0);
|
||||
set_global_variables( $family == F_IPV6, 0, $call_generate_all_acasts );
|
||||
handle_optional_interfaces;
|
||||
}
|
||||
|
||||
@ -329,7 +332,7 @@ sub generate_script_2() {
|
||||
}
|
||||
|
||||
verify_required_interfaces(1);
|
||||
set_global_variables(1,1);
|
||||
set_global_variables(1, 1, $call_generate_all_acasts );
|
||||
handle_optional_interfaces;
|
||||
|
||||
if ( $global_variables & NOT_RESTORE ) {
|
||||
|
@ -2430,13 +2430,15 @@ sub generate_all_acasts() {
|
||||
}
|
||||
}
|
||||
|
||||
unless( @noacasts || @wildnoacasts ) {
|
||||
emit( 'ALL_ACASTS="$(get_all_acasts)"' );
|
||||
return;
|
||||
}
|
||||
return 'ALL_ACASTS="$(get_all_acasts)"' unless @noacasts || @wildnoacasts;
|
||||
|
||||
@wildacasts = '*' unless @wildacasts;
|
||||
|
||||
emit( "#\n# Populate the ALL_ACASTS variable\n#",
|
||||
'generate_all_acasts()',
|
||||
'{' );
|
||||
push_indent;
|
||||
|
||||
emit( 'ALL_ACASTS=',
|
||||
'',
|
||||
'for iface in $(find_all_interfaces1); do' );
|
||||
@ -2489,6 +2491,10 @@ sub generate_all_acasts() {
|
||||
emit( 'esac');
|
||||
pop_indent;
|
||||
emit( 'done');
|
||||
pop_indent;
|
||||
emit( "}\n" );
|
||||
|
||||
return 'generate_all_acasts';
|
||||
}
|
||||
|
||||
1;
|
||||
|
Loading…
Reference in New Issue
Block a user