line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!/usr/bin/perl |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# $Id: Match.pm,v 1.13 2003/06/06 18:45:02 unimlo Exp $ |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Net::ACL::Match; |
6
|
|
|
|
|
|
|
|
7
|
6
|
|
|
6
|
|
35
|
use strict; |
|
6
|
|
|
|
|
14
|
|
|
6
|
|
|
|
|
207
|
|
8
|
6
|
|
|
6
|
|
32
|
use vars qw( $VERSION @ISA ); |
|
6
|
|
|
|
|
15
|
|
|
6
|
|
|
|
|
422
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
## Inheritance and Versioning ## |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
@ISA = qw( Exporter ); |
13
|
|
|
|
|
|
|
$VERSION = '0.07'; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
## Module Imports ## |
16
|
|
|
|
|
|
|
|
17
|
6
|
|
|
6
|
|
52
|
use Carp; |
|
6
|
|
|
|
|
19
|
|
|
6
|
|
|
|
|
1585
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
## Public Class Methods ## |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub new |
22
|
|
|
|
|
|
|
{ |
23
|
0
|
|
|
0
|
1
|
0
|
my $proto = shift; |
24
|
0
|
|
0
|
|
|
0
|
my $class = ref $proto || $proto; |
25
|
0
|
0
|
|
|
|
0
|
croak 'Cannot construct object of abstract class Net::ACL::Match' |
26
|
|
|
|
|
|
|
if $class eq 'Net::ACL::Match'; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
## Public Object Methods ## |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub match |
32
|
|
|
|
|
|
|
{ |
33
|
0
|
|
|
0
|
1
|
0
|
my $this = shift; |
34
|
0
|
|
0
|
|
|
0
|
my $class = ref $this || $this; |
35
|
0
|
0
|
|
|
|
0
|
croak __PACKAGE__ . ' objects cannot match!' |
36
|
|
|
|
|
|
|
if $class eq __PACKAGE__; |
37
|
|
|
|
|
|
|
|
38
|
0
|
|
|
|
|
0
|
croak "$class should reimplement the match method inhireted from " . __PACKAGE__; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub index |
42
|
|
|
|
|
|
|
{ |
43
|
40
|
|
|
40
|
1
|
49
|
my $this = shift; |
44
|
40
|
50
|
|
|
|
104
|
$this->{_index} = @_ ? shift : $this->{_index}; |
45
|
40
|
|
|
|
|
124
|
return $this->{_index}; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
## POD ## |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=pod |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head1 NAME |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
Net::ACL::Match - Abstract parent class of Match-classes |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head1 SYNOPSIS |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
package Net::ACL::MatchMyPackage; |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
use Net::ACL::Match; |
61
|
|
|
|
|
|
|
@ISA = qw( Net::ACL::Match ); |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub new { ... }; |
64
|
|
|
|
|
|
|
sub match { ... }; |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
package main; |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
# Construction |
70
|
|
|
|
|
|
|
my $match = new Net::ACL::MatchMyPackage($args); |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
# Accessor Methods |
73
|
|
|
|
|
|
|
$rc = $match->match(@data); |
74
|
|
|
|
|
|
|
$index = $match->index($index); |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head1 DESCRIPTION |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
This is an abstract parent class for all Net::ACL::Match* |
79
|
|
|
|
|
|
|
classes. It is used by the Net::ACL::Rule object. |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
It only has a constructor new() and two methods match() and index(). |
82
|
|
|
|
|
|
|
Both new and match should be replaced in any ancestor object. |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head1 CONSTRUCTOR |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=over 4 |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=item new() - create a new Net::ACL::Match::Scalar object |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
my $match = new Net::ACL::MatchMyPackage($args); |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
This is the constructor for Net::ACL::Match* objects. |
93
|
|
|
|
|
|
|
It returns a reference to the newly created object. |
94
|
|
|
|
|
|
|
It takes one argument, which should describe what to match. |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=back |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head1 ACCESSOR METHODS |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=over 4 |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=item match() |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
This function should match the data given as arguments (one or more) with |
105
|
|
|
|
|
|
|
the data passed to the constructor and return either ACL_MATCH or |
106
|
|
|
|
|
|
|
ACL_NOMATCH as exported by the ":rc" exporter symbol of |
107
|
|
|
|
|
|
|
Net::ACL::Rule. |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=item index() |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
This function returns the argument number that matched any sub-class. |
112
|
|
|
|
|
|
|
Called with an argument, the argument is used as the new value. |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=back |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head1 SEE ALSO |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
Net::ACL::Rule, Net::ACL, |
119
|
|
|
|
|
|
|
Net::ACL::Match::IP, Net::ACL::Match::Prefix, |
120
|
|
|
|
|
|
|
Net::ACL::Match::List, Net::ACL::Match::Scalar, |
121
|
|
|
|
|
|
|
Net::ACL::Match::Regexp, Net::ACL::Match::Member |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=head1 AUTHOR |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
Martin Lorensen |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=cut |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
## End Package Net::ACL::Match ## |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
1; |