| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
#!/usr/bin/perl |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# $Id: ContextRouter.pm,v 1.3 2003/06/02 11:58:05 unimlo Exp $ |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Net::BGP::ContextRouter; |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
1054
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
28
|
|
|
9
|
1
|
|
|
1
|
|
4
|
use Carp; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
61
|
|
|
10
|
1
|
|
|
1
|
|
5
|
use vars qw( $VERSION ); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
55
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
## Inheritance and Versioning ## |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
$VERSION = '0.04'; |
|
15
|
|
|
|
|
|
|
|
|
16
|
1
|
|
|
1
|
|
5
|
use Net::BGP::Router; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
302
|
|
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub new |
|
19
|
|
|
|
|
|
|
{ |
|
20
|
0
|
|
0
|
0
|
1
|
|
my $proto = shift || __PACKAGE__; |
|
21
|
0
|
|
0
|
|
|
|
my $class = ref $proto || $proto; |
|
22
|
|
|
|
|
|
|
|
|
23
|
0
|
|
|
|
|
|
my $this = { |
|
24
|
|
|
|
|
|
|
_contexts => {} |
|
25
|
|
|
|
|
|
|
}; |
|
26
|
|
|
|
|
|
|
|
|
27
|
0
|
|
|
|
|
|
while ( defined(my $arg = shift) ) |
|
28
|
|
|
|
|
|
|
{ |
|
29
|
0
|
|
|
|
|
|
my $value = shift; |
|
30
|
0
|
|
|
|
|
|
croak "unrecognized argument $arg\n"; |
|
31
|
|
|
|
|
|
|
}; |
|
32
|
|
|
|
|
|
|
|
|
33
|
0
|
|
|
|
|
|
bless($this, $class); |
|
34
|
0
|
|
|
|
|
|
return $this; |
|
35
|
|
|
|
|
|
|
} |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub context |
|
38
|
|
|
|
|
|
|
{ |
|
39
|
0
|
|
|
0
|
1
|
|
my ($this,$context) = @_; |
|
40
|
0
|
0
|
|
|
|
|
$this->{_contexts}->{$context} = new Net::BGP::Router(Name => $context) |
|
41
|
|
|
|
|
|
|
unless defined($this->{_contexts}->{$context}); |
|
42
|
0
|
|
|
|
|
|
return $this->{_contexts}->{$context}; |
|
43
|
|
|
|
|
|
|
} |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub add_peer |
|
46
|
|
|
|
|
|
|
{ |
|
47
|
0
|
|
|
0
|
1
|
|
my ($this,$context,$peer,$dir,$acl) = @_; |
|
48
|
0
|
|
|
|
|
|
$this->context($context)->add_peer($peer,$dir,$acl); |
|
49
|
|
|
|
|
|
|
} |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub remove_peer |
|
52
|
|
|
|
|
|
|
{ |
|
53
|
0
|
|
|
0
|
1
|
|
my ($this,$context,@args) = @_; |
|
54
|
0
|
|
|
|
|
|
$this->context($context)->remove_peer(@args); |
|
55
|
|
|
|
|
|
|
} |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub set_policy |
|
58
|
|
|
|
|
|
|
{ |
|
59
|
0
|
|
|
0
|
1
|
|
my ($this,$context,@args) = @_; |
|
60
|
0
|
|
|
|
|
|
$this->context($context)->set_policy(@args); |
|
61
|
|
|
|
|
|
|
} |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub remove_context |
|
64
|
|
|
|
|
|
|
{ |
|
65
|
0
|
|
|
0
|
0
|
|
my ($this,$context) = @_; |
|
66
|
0
|
|
|
|
|
|
delete $this->{_context}->{$context}; |
|
67
|
|
|
|
|
|
|
} |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=pod |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head1 NAME |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
Net::BGP::ContextRouter - A Multiple Context BGP Router |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
use Net::BGP::ContextRouter; |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
# Constructor |
|
80
|
|
|
|
|
|
|
$crouter = new Net::BGP::ContextRouter(); |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
# Accessor Methods |
|
83
|
|
|
|
|
|
|
$router = $crouter->context($context); |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
$crouter->add_peer($context,$peer,'both',$acl); |
|
86
|
|
|
|
|
|
|
$crouter->remove_peer($context,$peer,'both'); |
|
87
|
|
|
|
|
|
|
$crouter->set_policy($context,$policy); |
|
88
|
|
|
|
|
|
|
$crouter->set_policy($context,$peer,'in',$acl); |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
This module implements a multiple-context BGP router using the |
|
94
|
|
|
|
|
|
|
L object. |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head1 CONSTRUCTOR |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=over 4 |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=item new() - create a new Net::BGP::ContextRouter object |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
$router = new Net::BGP::ContextRouter(); |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
This is the constructor for Net::BGP::ContextRouter object. It returns a |
|
105
|
|
|
|
|
|
|
reference to the newly created object. No arguments are allowed. |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=back |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head1 ACCESSOR METHODS |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=over 4 |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=item context() |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
Return a given context. If the context doesn't exist, it will be created. |
|
116
|
|
|
|
|
|
|
The argument is the name of the context. The Net::BGP::Router object |
|
117
|
|
|
|
|
|
|
representing the context is returned. |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=item add_peer() |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=item remove_peer() |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=item set_policy() |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
Just like Net::BGP::Router->add_peer() but with the context name as the first |
|
126
|
|
|
|
|
|
|
argument. |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=back |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
Net::BGP::Router, Net::BGP, Net::BGP::Policy |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=head1 AUTHOR |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
Martin Lorensen |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=cut |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
## End of Net::BGP::ContextRouter ## |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
1; |