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