From 516e4988be28dd2441e915fe7d4c6a2efb5bd0c6 Mon Sep 17 00:00:00 2001 From: Gaurav Date: Fri, 24 Feb 2012 11:22:41 -0800 Subject: Adding deletion, error handling etc. (cherry picked from commit 6a59a800acf9a9f6a21677e6187a33647ceb3539) --- scripts/vyatta-conntrack-timeouts.pl | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) (limited to 'scripts') diff --git a/scripts/vyatta-conntrack-timeouts.pl b/scripts/vyatta-conntrack-timeouts.pl index bf7165e..ac9b56d 100644 --- a/scripts/vyatta-conntrack-timeouts.pl +++ b/scripts/vyatta-conntrack-timeouts.pl @@ -23,6 +23,19 @@ GetOptions("create=s" => \$create, ); update_config(); +sub remove_timeout_policy { + my ($rule_string, $timeout_policy) = @_; + print "removing with $rule_string and $timeout_policy\n"; + # function to apply the policy and then apply the policy to + # the iptables rule. + # Do nothing as of now. +} +sub apply_timeout_policy { + # function to apply the policy and then apply the policy to + # the iptables rule. + # Do nothing as of now. +} + sub update_config { my $config = new Vyatta::Config; @@ -34,20 +47,22 @@ sub update_config { foreach my $rule (sort keys %rules) { if ("$rules{$rule}" eq 'static') { } elsif ("$rules{$rule}" eq 'added') { - print $rules{$rule}; my $node = new Vyatta::Conntrack::RuleCT; + my ($rule_string, $timeout_policy); $node->setup("system conntrack timeout custom rule $rule"); - $node->print(); - $node->rule(); - $node->get_policy_command(); #nfct-timeout command string - + $rule_string = $node->rule(); + $timeout_policy = $node->get_policy_command(); #nfct-timeout command string + apply_timeout_policy($rule_string, $timeout_policy); } elsif ("$rules{$rule}" eq 'changed') { - print $rules{$rule}; my $node = new Vyatta::Conntrack::RuleCT; $node->setup("system conntrack timeout custom rule $rule"); - $node->print(); } elsif ("$rules{$rule}" eq 'deleted') { - print $rules{$rule}; + my $node = new Vyatta::Conntrack::RuleCT; + my ($rule_string, $timeout_policy); + $node->setupOrig("system conntrack timeout custom rule $rule"); + $rule_string = $node->rule(); + $timeout_policy = $node->get_policy_command(); #nfct-timeout command string + remove_timeout_policy($rule_string, $timeout_policy); } } } -- cgit v1.2.3