Reorganize process_action3 for possible nested macro implementation

git-svn-id: https://shorewall.svn.sourceforge.net/svnroot/shorewall/trunk@6337 fbd18981-670d-0410-9b5c-8dc0c1a9a2bb
This commit is contained in:
teastep 2007-05-13 16:30:19 +00:00
parent f6ae8ff0f4
commit 3a5b81082b

View File

@ -400,14 +400,9 @@ sub process_actions2 () {
}
#
# Generate chain for non-builtin action invocation
# This function is called to process each rule generated from an action file.
#
sub process_action3( $$$$$ ) {
my ( $chainref, $wholeaction, $action, $level, $tag ) = @_;
#
# This function is called to process each rule generated from an action file.
#
sub process_action( $$$$$$$$$$ ) {
sub process_action( $$$$$$$$$$ ) {
my ($chainref, $actionname, $target, $source, $dest, $proto, $ports, $sports, $rate, $user ) = @_;
my ( $action , $level ) = split_action $target;
@ -422,44 +417,13 @@ sub process_action3( $$$$$ ) {
$level ,
$action ,
'' );
}
}
my $actionfile = find_file "action.$action";
my $standard = ( $actionfile =~ /^$globals{SHAREDIR}/ );
fatal_error "Missing Action File: $actionfile" unless -f $actionfile;
progress_message2 "Processing $actionfile for chain $chainref->{name}...";
open_file $actionfile;
while ( read_a_line ) {
my ($target, $source, $dest, $proto, $ports, $sports, $rate, $user ) = split_line1 1, 8, 'action file';
if ( $target eq 'COMMENT' ) {
process_comment;
next;
}
my $target2 = merge_levels $wholeaction, $target;
my ( $action2 , $level2 ) = split_action $target2;
my $action2type = $targets{isolate_basic_target $action2};
unless ( $action2type == STANDARD ) {
if ( $action2type & ACTION ) {
$target2 = (find_logactionchain ( $target = $target2 ))->{name};
} else {
die "Internal Error" unless $action2type == MACRO || $action2type & LOGRULE;
}
}
if ( $action2type == MACRO ) {
( $action2, my $param ) = split '/', $action2;
fatal_error "Null Macro" unless my $fn = $macros{$action2};
#
# Expand Macro in action file4s.
#
sub process_macro3( $$$$$$$$$$$ ) {
my ( $fn, $param, $chainref, $action, $source, $dest, $proto, $ports, $sports, $rate, $user ) = @_;
progress_message "..Expanding Macro $fn...";
@ -516,7 +480,51 @@ sub process_action3( $$$$$ ) {
pop_open;
progress_message '..End Macro'
}
#
# Generate chain for non-builtin action invocation
#
sub process_action3( $$$$$ ) {
my ( $chainref, $wholeaction, $action, $level, $tag ) = @_;
my $actionfile = find_file "action.$action";
my $standard = ( $actionfile =~ /^$globals{SHAREDIR}/ );
fatal_error "Missing Action File: $actionfile" unless -f $actionfile;
progress_message2 "Processing $actionfile for chain $chainref->{name}...";
open_file $actionfile;
while ( read_a_line ) {
my ($target, $source, $dest, $proto, $ports, $sports, $rate, $user ) = split_line1 1, 8, 'action file';
if ( $target eq 'COMMENT' ) {
process_comment;
next;
}
my $target2 = merge_levels $wholeaction, $target;
my ( $action2 , $level2 ) = split_action $target2;
my $action2type = $targets{isolate_basic_target $action2};
unless ( $action2type == STANDARD ) {
if ( $action2type & ACTION ) {
$target2 = (find_logactionchain ( $target = $target2 ))->{name};
} else {
die "Internal Error" unless $action2type == MACRO || $action2type & LOGRULE;
}
}
if ( $action2type == MACRO ) {
( $action2, my $param ) = split '/', $action2;
fatal_error "Null Macro" unless my $fn = $macros{$action2};
process_macro3( $fn, $param, $chainref, $action, $source, $dest, $proto, $ports, $sports, $rate, $user );
} else {
process_action $chainref, $action, $target2, $source, $dest, $proto, $ports, $sports, $rate, $user;
}