File Coverage

blib/lib/Net/ACL/File/Standard.pm
Criterion Covered Total %
statement 19 23 82.6
branch 0 2 0.0
condition 1 6 16.6
subroutine 5 6 83.3
pod 2 2 100.0
total 27 39 69.2


line stmt bran cond sub pod time code
1             #!/usr/bin/perl
2              
3             # $Id: Standard.pm,v 1.11 2003/06/06 18:45:02 unimlo Exp $
4              
5             package Net::ACL::File::Standard;
6              
7 2     2   1492 use strict;
  2         3  
  2         82  
8 2     2   12 use vars qw( $VERSION @ISA );
  2         4  
  2         139  
9              
10             ## Inheritance and Versioning ##
11              
12             @ISA = qw( Net::ACL::File );
13             $VERSION = '0.07';
14              
15             ## Module Imports ##
16              
17 2     2   12 use Net::ACL::File;
  2         5  
  2         85  
18 2     2   11 use Carp;
  2         4  
  2         495  
19              
20             ## Public Class Methods ##
21              
22             sub load
23             {
24 19     19 1 27 my $proto = shift;
25 19   33     85 my $class = ref $proto || $proto;
26 19         27 my $config = shift;
27              
28 19         95 my $obj = $class->new;
29              
30 19         58 foreach my $rule ($config->get)
31             {
32 29         3325 $obj->loadmatch($rule,$config);
33             };
34              
35 19         67 return $obj;
36             }
37              
38             ## Public Object Methods ##
39              
40             sub loadmatch
41             {
42 0     0 1   my $this = shift;
43 0   0       my $class = ref $this || $this;
44 0 0         croak __PACKAGE__ . ' objects cannot do loadmatch!'
45             if $class eq __PACKAGE__;
46              
47 0           croak "$class should reimplement the match method inhireted from __PACKAGE__";
48             };
49              
50             ## POD ##
51              
52             =pod
53              
54             =head1 NAME
55              
56             Net::ACL::File::Standard - Standard access-lists loaded from configuration string.
57              
58             =head1 SYNOPSIS
59              
60             use Net::ACL::File;
61             use Net::ACL::File::Community;
62             use Net::ACL::File::ASPath;
63             use Net::ACL::File::Prefix;
64             use Net::ACL::File::Access;
65              
66             # Construction
67             my $list_hr = load Net::ACL::File(<
68             ! Community-lists
69             ip community-list 1 permit 65001:1
70             ip community-list 42 deny 65001:1
71             ip community-list 42 permit
72             ! AS Path-lists
73             ip as-path access-list 1 permit .*
74             ip as-path access-list 2 permit ^$
75             ip as-path access-list 55 permit ^65001_65002
76             ! Prefix-lists
77             ip prefix-list ournet seq 10 permit 10.0.0.0/8
78             ip prefix-list ournet seq 20 permit 192.168.0.0/16
79             ! Access-lists
80             access-list 10 permit 10.20.30.0 0.0.0.255
81             access-list 10 permit 10.30.00.0 0.0.255.255
82             access-list 12 deny 10.0.0.0 0.255.255.255
83             access-list 12 permit any
84             CONF
85              
86             # Abstract method
87             $list->loadmatch($line);
88              
89             =head1 DESCRIPTION
90              
91             This is an abstract class that extends the Net::ACL::File class. It has the
92             common features of loading a standard access-list in Cisco-notation.
93             It replaces the load constructor and adds a loadmatch() method that should be
94             replaced in any sub-class.
95              
96             Any sub-classes should register them self with the Net::ACL::File class using
97             the add_listtype() class method. After this, classes are constructed by the
98             Net::ACL::File new() constructor.
99              
100             =head1 CONSTRUCTOR
101              
102             There should be no reason to use nor change the constructor of this class.
103             However - It gets a Cisco::Reconfig object as argument. It returns a reference
104             to the object created from the data in the Cisco::Reconfig object.
105              
106             =head1 ACCESSOR METHODS
107              
108             =over 4
109              
110             =item loadmatch()
111              
112             The loadmatch() method is called with an access-list clause - normally a single
113             line. It should construct a Net::ACL::Rule object and add it using the
114             add_rule() inherited method.
115              
116             =back
117              
118             =head1 SEE ALSO
119              
120             Cisco::Reconfig, Net::ACL::File, Net::ACL,
121             Net::ACL::File::Community, Net::ACL::File::ASPath,
122             Net::ACL::File::Prefix, Net::ACL::File::Access,
123             Net::ACL::File::IPAccess, Net::ACL::File::IPAccessExt,
124             Net::ACL::File::RouteMap
125              
126              
127             =head1 AUTHOR
128              
129             Martin Lorensen
130              
131             =cut
132              
133             ## End of Net::ACL::File::Standard ##
134              
135             1;