From 21166e07f39434deb32d5d6142952ed509ce3429 Mon Sep 17 00:00:00 2001 From: Tom Eastep Date: Sat, 18 Dec 2010 12:31:37 -0800 Subject: [PATCH] Add action normalization routines --- Shorewall/Perl/Shorewall/Actions.pm | 22 ++++++++++++++++++++++ Shorewall/Perl/Shorewall/Rules.pm | 2 +- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/Shorewall/Perl/Shorewall/Actions.pm b/Shorewall/Perl/Shorewall/Actions.pm index 64a35c08f..38ffda6d7 100644 --- a/Shorewall/Perl/Shorewall/Actions.pm +++ b/Shorewall/Perl/Shorewall/Actions.pm @@ -37,6 +37,8 @@ our @ISA = qw(Exporter); our @EXPORT = qw( split_action get_target_param + normalize_action + normalize_action_name createactionchain %actions %usedactions @@ -133,6 +135,26 @@ sub get_target_param( $ ) { ( $target, $param ); } +# +# Create a normalized action name from the passed pieces +# +sub normalize_action( $$ ) { + my $target = shift; + my $param = shift; + + my ($action, $level, $tag ) = split /:/, $target; + + $level = 'none' unless defined $level && $level ne ''; + $tag = '' unless defined $tag; + $param = '' unless defined $param; + + ( $action, $level, $tag, $param ); +} + +sub normalize_action_name( $$ ) { + join (':', &normalize_action( @_ ) ); +} + # # Create and record a log action chain -- Log action chains have names # that are formed from the action name by prepending a "%" and appending diff --git a/Shorewall/Perl/Shorewall/Rules.pm b/Shorewall/Perl/Shorewall/Rules.pm index 5c8314ee0..cb0efefcf 100644 --- a/Shorewall/Perl/Shorewall/Rules.pm +++ b/Shorewall/Perl/Shorewall/Rules.pm @@ -86,7 +86,7 @@ sub initialize( $ ) { } # -# This function determines the logging for a subordinate action or a rule within a superior action +# This function determines the logging and params for a subordinate action or a rule within a superior action # sub merge_levels ($$) { my ( $superior, $subordinate ) = @_;