| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
#!/usr/bin/perl |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# $Id: IPAccess.pm,v 1.10 2003/06/06 18:45:02 unimlo Exp $ |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Net::ACL::File::IPAccessRule; |
|
6
|
|
|
|
|
|
|
|
|
7
|
2
|
|
|
2
|
|
3110
|
use strict; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
85
|
|
|
8
|
2
|
|
|
2
|
|
11
|
use vars qw( $VERSION @ISA ); |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
144
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
## Inheritance ## |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
@ISA = qw( Net::ACL::Rule ); |
|
13
|
|
|
|
|
|
|
$VERSION = '0.07'; |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
## Module Imports ## |
|
16
|
|
|
|
|
|
|
|
|
17
|
2
|
|
|
2
|
|
10
|
use Net::ACL::Rule; |
|
|
2
|
|
|
|
|
10
|
|
|
|
2
|
|
|
|
|
80
|
|
|
18
|
2
|
|
|
2
|
|
11
|
use Carp; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
453
|
|
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
## Public Object Methods ## |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub asconfig |
|
23
|
|
|
|
|
|
|
{ # Don't check data - expect them to be constructed the right way! |
|
24
|
8
|
|
|
8
|
|
11
|
my $this = shift; |
|
25
|
8
|
|
|
|
|
9
|
my $name = shift; |
|
26
|
8
|
|
|
|
|
13
|
my $match = $this->{_match}->[0]; |
|
27
|
8
|
50
|
|
|
|
32
|
my $net = $match->net if defined $match; |
|
28
|
8
|
|
|
|
|
11
|
my $str = ''; |
|
29
|
8
|
50
|
|
|
|
30
|
$str = $net->base if defined $net; |
|
30
|
8
|
50
|
33
|
|
|
97
|
$str .= ' ' . $net->hostmask if defined $net && $net->bits != 32; |
|
31
|
8
|
100
|
66
|
|
|
134
|
$str = 'any' if defined $net && $net->bits == 0; |
|
32
|
8
|
50
|
|
|
|
67
|
return 'access-list ' . $name . ' ' . $this->action_str . ($str eq '' ? '' : ' ' . $str) . "\n"; |
|
33
|
|
|
|
|
|
|
} |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
## End of Net::ACL::File::IPAccessRule ## |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
package Net::ACL::File::IPAccess; |
|
38
|
|
|
|
|
|
|
|
|
39
|
2
|
|
|
2
|
|
12
|
use strict; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
70
|
|
|
40
|
2
|
|
|
2
|
|
11
|
use vars qw( $VERSION @ISA ); |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
118
|
|
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
## Inheritance ## |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
@ISA = qw( Net::ACL::File::Standard ); |
|
45
|
|
|
|
|
|
|
$VERSION = '0.07'; |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
## Module Imports ## |
|
48
|
|
|
|
|
|
|
|
|
49
|
2
|
|
|
2
|
|
593
|
use Net::ACL::File::Standard; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
79
|
|
|
50
|
2
|
|
|
2
|
|
11
|
use Carp; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
779
|
|
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
## Net::ACL::File Class Auto Registration Code ## |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
Net::ACL::File->add_listtype('access-list',__PACKAGE__,'access-list'); |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
## Public Object Methods ## |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub loadmatch |
|
59
|
|
|
|
|
|
|
{ |
|
60
|
9
|
|
|
9
|
1
|
14
|
my ($this,$lines) = @_; |
|
61
|
|
|
|
|
|
|
|
|
62
|
9
|
50
|
|
|
|
70
|
foreach my $line ($lines =~ /\n./ ? $lines->all : $lines) # For some reasons we got more then one! |
|
63
|
|
|
|
|
|
|
{ |
|
64
|
9
|
|
|
|
|
268
|
$line =~ s/ +/ /g; |
|
65
|
9
|
50
|
|
|
|
483
|
next if $line =~ /^access-list (\d{3}) /i; |
|
66
|
9
|
50
|
|
|
|
64
|
croak "Configuration line format error in line: '$line'" |
|
67
|
|
|
|
|
|
|
unless $line =~ /^access-list ([^ ]+) (permit|deny)(.*)$/i; |
|
68
|
9
|
|
|
|
|
35
|
my ($name,$action,$data) = ($1,$2,$3); |
|
69
|
9
|
|
|
|
|
28
|
$data =~ s/^ //; |
|
70
|
9
|
|
|
|
|
21
|
$data =~ s/ /#/; |
|
71
|
9
|
|
|
|
|
61
|
my $rule = new Net::ACL::File::IPAccessRule( |
|
72
|
|
|
|
|
|
|
Action => $action |
|
73
|
|
|
|
|
|
|
); |
|
74
|
9
|
|
|
|
|
39
|
$rule->add_match($rule->autoconstruction('Match','Net::ACL::Match::IP','IP',0,$data)); |
|
75
|
9
|
|
|
|
|
46
|
$this->add_rule($rule); |
|
76
|
9
|
|
|
|
|
40
|
$this->name($name); |
|
77
|
|
|
|
|
|
|
}; |
|
78
|
|
|
|
|
|
|
} |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
## POD ## |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=pod |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head1 NAME |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
Net::ACL::File::IPAccess - IP access-lists loaded from configuration string. |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
This module extends the Net::ACL::File::Standard class to handle |
|
91
|
|
|
|
|
|
|
community-lists. See L for |
|
92
|
|
|
|
|
|
|
details. |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
Net::ACL, Net::ACL::File, Net::ACL::Standard |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head1 AUTHOR |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
Martin Lorensen |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=cut |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
## End of Net::ACL::File::IPAccess ## |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
1; |