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