summaryrefslogtreecommitdiff
path: root/lib/Vyatta/IpTables
diff options
context:
space:
mode:
authorMohit Mehta <mohit@vyatta.com>2010-09-21 21:16:02 -0700
committerMohit Mehta <mohit@vyatta.com>2010-09-21 21:16:02 -0700
commit1f74bdf65791ee8d18d8cfc914e81b25cef9a6c8 (patch)
treedb7977d1f5e8b587e39221e4f1eb5644a9c741fd /lib/Vyatta/IpTables
parentb37ca3f710c6d398626b4b5e8066ba91a1cd5e65 (diff)
downloadvyatta-cfg-firewall-1f74bdf65791ee8d18d8cfc914e81b25cef9a6c8.tar.gz
vyatta-cfg-firewall-1f74bdf65791ee8d18d8cfc914e81b25cef9a6c8.zip
* move count_iptables_rule to Iptables::Mgr and update it's usage
Diffstat (limited to 'lib/Vyatta/IpTables')
-rwxr-xr-xlib/Vyatta/IpTables/Mgr.pm12
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/Vyatta/IpTables/Mgr.pm b/lib/Vyatta/IpTables/Mgr.pm
index 9247a44..ff468cb 100755
--- a/lib/Vyatta/IpTables/Mgr.pm
+++ b/lib/Vyatta/IpTables/Mgr.pm
@@ -29,7 +29,7 @@ use warnings;
use base 'Exporter';
our @EXPORT = qw(ipt_find_chain_rule ipt_enable_conntrack
- ipt_disable_conntrack);
+ ipt_disable_conntrack count_iptables_rules);
sub ipt_find_chain_rule {
@@ -104,4 +104,14 @@ sub ipt_disable_conntrack {
return 0;
}
+sub count_iptables_rules {
+ my ($command, $table, $chain) = @_;
+ my @lines = `sudo $command -t $table -L $chain -n --line`;
+ my $cnt = 0;
+ foreach my $line (@lines) {
+ $cnt++ if $line =~ /^\d/;
+ }
+ return $cnt;
+}
+
1;