diff options
author | Stig Thormodsrud <stig@io.vyatta.com> | 2009-02-13 18:24:12 -0800 |
---|---|---|
committer | Stig Thormodsrud <stig@io.vyatta.com> | 2009-02-13 18:24:12 -0800 |
commit | f638fad8d8550624c2ea2928f562fb953a27456c (patch) | |
tree | 6aa5acee2371477ea55f7aa28b5db586824be118 /lib/Vyatta | |
parent | 95aa4b58d430551ec0087f1951f4a2d7e18a2497 (diff) | |
download | vyatta-cfg-firewall-f638fad8d8550624c2ea2928f562fb953a27456c.tar.gz vyatta-cfg-firewall-f638fad8d8550624c2ea2928f562fb953a27456c.zip |
Add description and references to "show firewall group".
Diffstat (limited to 'lib/Vyatta')
-rwxr-xr-x | lib/Vyatta/IpTables/IpSet.pm | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/lib/Vyatta/IpTables/IpSet.pm b/lib/Vyatta/IpTables/IpSet.pm index 1f8e25b..5689f0a 100755 --- a/lib/Vyatta/IpTables/IpSet.pm +++ b/lib/Vyatta/IpTables/IpSet.pm @@ -259,6 +259,46 @@ sub delete_member { return; # undef } +sub get_description { + my ($self) = @_; + + return if ! $self->exists(); + my $config = new Vyatta::Config; + my $group_type = "$self->{_type}-group"; + $config->setLevel("firewall group $group_type $self->{_name}"); + return $config->returnOrigValue('description'); +} + +sub get_firewall_references { + my ($self) = @_; + + return if ! $self->exists(); + my @fw_refs = (); + my $config = new Vyatta::Config; + foreach my $tree ('name', 'modify') { + my $path = "firewall $tree "; + $config->setLevel($path); + my @names = $config->listOrigNodes(); + foreach my $name (@names) { + my $name_path = "$path $name rule "; + $config->setLevel($name_path); + my @rules = $config->listOrigNodes(); + foreach my $rule (@rules) { + foreach my $dir ('source', 'destination') { + my $rule_path .= "$name_path $rule $dir group"; + $config->setLevel($rule_path); + my $group_type = "$self->{_type}-group"; + my $value = $config->returnOrigValue($group_type); + if (defined $value and $self->{_name} eq $value) { + push @fw_refs, "$name-$rule-$dir"; + } + } # foreach $dir + } # foreach $rule + } # foreach $name + } # foreach $tree + return @fw_refs; +} + sub rule { my ($self, $direction) = @_; |