| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
#!/usr/bin/perl |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Net::BGP::Peer; |
|
4
|
4
|
|
|
4
|
|
17913
|
use bytes; |
|
|
4
|
|
|
|
|
14
|
|
|
|
4
|
|
|
|
|
20
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
4
|
|
|
4
|
|
103
|
use strict; |
|
|
4
|
|
|
|
|
4
|
|
|
|
4
|
|
|
|
|
124
|
|
|
7
|
4
|
|
|
|
|
805
|
use vars qw( |
|
8
|
|
|
|
|
|
|
$VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS @BGP @GENERIC |
|
9
|
|
|
|
|
|
|
@BGP_EVENT_MESSAGE_MAP @BGP_EVENTS @BGP_FSM @BGP_STATES |
|
10
|
4
|
|
|
4
|
|
14
|
); |
|
|
4
|
|
|
|
|
4
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
## Inheritance and Versioning ## |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
@ISA = qw( Exporter ); |
|
15
|
|
|
|
|
|
|
$VERSION = '0.16'; |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
## General Definitions ## |
|
18
|
|
|
|
|
|
|
|
|
19
|
17
|
|
|
17
|
0
|
55
|
sub TRUE { 1 } |
|
20
|
17
|
|
|
17
|
0
|
114
|
sub FALSE { 0 } |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
## BGP Network Constants ## |
|
23
|
|
|
|
|
|
|
|
|
24
|
8
|
|
|
8
|
0
|
126
|
sub BGP_PORT { 179 } |
|
25
|
5
|
|
|
5
|
0
|
14
|
sub BGP_VERSION_4 { 4 } |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
## Export Tag Definitions ## |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
@BGP = qw( BGP_PORT BGP_VERSION_4 ); |
|
30
|
|
|
|
|
|
|
@GENERIC = qw( TRUE FALSE dump_hex ); |
|
31
|
|
|
|
|
|
|
@EXPORT = (); |
|
32
|
|
|
|
|
|
|
@EXPORT_OK = ( @BGP, @GENERIC ); |
|
33
|
|
|
|
|
|
|
%EXPORT_TAGS = ( |
|
34
|
|
|
|
|
|
|
bgp => [ @BGP ], |
|
35
|
|
|
|
|
|
|
generic => [ @GENERIC ], |
|
36
|
|
|
|
|
|
|
ALL => [ @EXPORT, @EXPORT_OK ] |
|
37
|
|
|
|
|
|
|
); |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
## Module Imports ## |
|
40
|
|
|
|
|
|
|
|
|
41
|
4
|
|
|
4
|
|
19
|
use Scalar::Util qw( weaken ); |
|
|
4
|
|
|
|
|
7
|
|
|
|
4
|
|
|
|
|
276
|
|
|
42
|
4
|
|
|
4
|
|
16
|
use Exporter; |
|
|
4
|
|
|
|
|
5
|
|
|
|
4
|
|
|
|
|
97
|
|
|
43
|
4
|
|
|
4
|
|
474
|
use IO::Socket; |
|
|
4
|
|
|
|
|
17873
|
|
|
|
4
|
|
|
|
|
22
|
|
|
44
|
4
|
|
|
4
|
|
2002
|
use Carp; |
|
|
4
|
|
|
|
|
8
|
|
|
|
4
|
|
|
|
|
180
|
|
|
45
|
4
|
|
|
4
|
|
17
|
use Carp qw(cluck); |
|
|
4
|
|
|
|
|
7
|
|
|
|
4
|
|
|
|
|
150
|
|
|
46
|
4
|
|
|
4
|
|
813
|
use Net::BGP::Notification qw( :errors ); |
|
|
4
|
|
|
|
|
6
|
|
|
|
4
|
|
|
|
|
852
|
|
|
47
|
4
|
|
|
4
|
|
675
|
use Net::BGP::Refresh; |
|
|
4
|
|
|
|
|
11
|
|
|
|
4
|
|
|
|
|
149
|
|
|
48
|
4
|
|
|
4
|
|
814
|
use Net::BGP::Update; |
|
|
4
|
|
|
|
|
7
|
|
|
|
4
|
|
|
|
|
133
|
|
|
49
|
4
|
|
|
4
|
|
2171
|
use Net::BGP::Transport; |
|
|
4
|
|
|
|
|
11
|
|
|
|
4
|
|
|
|
|
8356
|
|
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
## Global private variables ## |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
my %knownpeers; |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
## Generic Subroutines ## |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
# This subroutine was snicked from David Town's excellent Net::SNMP |
|
58
|
|
|
|
|
|
|
# module and renamed as dump_hex(). Removed class dependence and made |
|
59
|
|
|
|
|
|
|
# into standalone subroutine. |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub dump_hex |
|
62
|
|
|
|
|
|
|
{ |
|
63
|
0
|
|
|
0
|
0
|
0
|
my $data = shift(); |
|
64
|
0
|
|
|
|
|
0
|
my ($length, $offset, $line, $hex) = (0, 0, '', ''); |
|
65
|
0
|
|
|
|
|
0
|
my $string; |
|
66
|
|
|
|
|
|
|
|
|
67
|
0
|
|
|
|
|
0
|
$string = ''; |
|
68
|
0
|
|
|
|
|
0
|
$length = length($data); |
|
69
|
|
|
|
|
|
|
|
|
70
|
0
|
|
|
|
|
0
|
while ($length > 0) { |
|
71
|
0
|
0
|
|
|
|
0
|
if ($length >= 16) { |
|
72
|
0
|
|
|
|
|
0
|
$line = substr($data, $offset, 16); |
|
73
|
|
|
|
|
|
|
} else { |
|
74
|
0
|
|
|
|
|
0
|
$line = substr($data, $offset, $length); |
|
75
|
|
|
|
|
|
|
} |
|
76
|
0
|
|
|
|
|
0
|
$hex = unpack('H*', $line); |
|
77
|
0
|
|
|
|
|
0
|
$hex .= ' ' x (32 - length($hex)); |
|
78
|
0
|
|
|
|
|
0
|
$hex = sprintf("%s %s %s %s " x 4, unpack('a2' x 16, $hex)); |
|
79
|
0
|
|
|
|
|
0
|
$line =~ s/[\x00-\x1f\x7f-\xff]/./g; |
|
80
|
0
|
|
|
|
|
0
|
$string .= sprintf("[%03d] %s %s\n", $offset, uc($hex), $line); |
|
81
|
0
|
|
|
|
|
0
|
$offset += 16; |
|
82
|
0
|
|
|
|
|
0
|
$length -= 16; |
|
83
|
|
|
|
|
|
|
} |
|
84
|
|
|
|
|
|
|
|
|
85
|
0
|
|
|
|
|
0
|
return ( $string ); |
|
86
|
|
|
|
|
|
|
} |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
## Public Class Methods ## |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub new |
|
91
|
|
|
|
|
|
|
{ |
|
92
|
5
|
|
|
5
|
0
|
2314
|
my $class = shift(); |
|
93
|
5
|
|
|
|
|
9
|
my ($arg, $value); |
|
94
|
|
|
|
|
|
|
|
|
95
|
5
|
|
|
|
|
17
|
my $this = { |
|
96
|
|
|
|
|
|
|
_bgp_version => BGP_VERSION_4, |
|
97
|
|
|
|
|
|
|
_local_id => undef, |
|
98
|
|
|
|
|
|
|
_peer_id => undef, |
|
99
|
|
|
|
|
|
|
_peer_port => BGP_PORT, |
|
100
|
|
|
|
|
|
|
_local_as => 0, |
|
101
|
|
|
|
|
|
|
_peer_as => 0, |
|
102
|
|
|
|
|
|
|
_user_timers => {}, |
|
103
|
|
|
|
|
|
|
_transport => undef, |
|
104
|
|
|
|
|
|
|
_listen => TRUE, |
|
105
|
|
|
|
|
|
|
_passive => FALSE, |
|
106
|
|
|
|
|
|
|
_announce_refresh => FALSE, |
|
107
|
|
|
|
|
|
|
_support_capabilities => TRUE, |
|
108
|
|
|
|
|
|
|
_support_mbgp => TRUE, |
|
109
|
|
|
|
|
|
|
_support_as4 => FALSE, |
|
110
|
|
|
|
|
|
|
_open_callback => undef, |
|
111
|
|
|
|
|
|
|
_established_callback => undef, |
|
112
|
|
|
|
|
|
|
_keepalive_callback => undef, |
|
113
|
|
|
|
|
|
|
_update_callback => undef, |
|
114
|
|
|
|
|
|
|
_refresh_callback => undef, |
|
115
|
|
|
|
|
|
|
_reset_callback => undef, |
|
116
|
|
|
|
|
|
|
_notification_callback => undef, |
|
117
|
|
|
|
|
|
|
_error_callback => undef |
|
118
|
|
|
|
|
|
|
}; |
|
119
|
|
|
|
|
|
|
|
|
120
|
5
|
|
|
|
|
20
|
bless($this, $class); |
|
121
|
|
|
|
|
|
|
|
|
122
|
5
|
|
|
|
|
11
|
my %transarg = (); |
|
123
|
5
|
|
|
|
|
25
|
while ( defined($arg = shift()) ) { |
|
124
|
54
|
|
|
|
|
57
|
$value = shift(); |
|
125
|
|
|
|
|
|
|
|
|
126
|
54
|
100
|
66
|
|
|
667
|
if (( $arg =~ /^start$/i ) |
|
|
|
100
|
100
|
|
|
|
|
|
|
|
100
|
66
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
|| ( $arg =~ /^connectretrytime$/i ) |
|
128
|
|
|
|
|
|
|
|| ( $arg =~ /^keepalivetime$/i ) |
|
129
|
|
|
|
|
|
|
|| ( $arg =~ /^holdtime$/i )) { |
|
130
|
9
|
|
|
|
|
34
|
$transarg{$arg} = $value; |
|
131
|
|
|
|
|
|
|
} |
|
132
|
|
|
|
|
|
|
elsif ( $arg =~ /^thisid$/i ) { |
|
133
|
5
|
|
|
|
|
25
|
$this->{_local_id} = $value; |
|
134
|
|
|
|
|
|
|
} |
|
135
|
|
|
|
|
|
|
elsif ( $arg =~ /^thisas$/i ) { |
|
136
|
5
|
|
|
|
|
17
|
$this->{_local_as} = $value; |
|
137
|
|
|
|
|
|
|
} |
|
138
|
|
|
|
|
|
|
elsif ( $arg =~ /^peerid$/i ) { |
|
139
|
5
|
|
|
|
|
17
|
$this->{_peer_id} = $value; |
|
140
|
|
|
|
|
|
|
} |
|
141
|
|
|
|
|
|
|
elsif ( $arg =~ /^peeras$/i ) { |
|
142
|
5
|
|
|
|
|
21
|
$this->{_peer_as} = $value; |
|
143
|
|
|
|
|
|
|
} |
|
144
|
|
|
|
|
|
|
elsif ( $arg =~ /^peerport$/i ) { |
|
145
|
4
|
|
|
|
|
12
|
$this->{_peer_port} = $value; |
|
146
|
|
|
|
|
|
|
} |
|
147
|
|
|
|
|
|
|
elsif ( $arg =~ /^listen$/i ) { |
|
148
|
5
|
|
|
|
|
30
|
$this->{_listen} = $value; |
|
149
|
|
|
|
|
|
|
} |
|
150
|
|
|
|
|
|
|
elsif ( $arg =~ /^passive$/i ) { |
|
151
|
5
|
|
|
|
|
17
|
$this->{_passive} = $value; |
|
152
|
|
|
|
|
|
|
} |
|
153
|
|
|
|
|
|
|
elsif ( $arg =~ /^refreshcallback$/i ) { |
|
154
|
0
|
|
|
|
|
0
|
$this->{_refresh_callback} = $value; |
|
155
|
|
|
|
|
|
|
} |
|
156
|
|
|
|
|
|
|
elsif ( $arg =~ /^refresh$/i ) { |
|
157
|
0
|
|
|
|
|
0
|
warnings::warnif( |
|
158
|
|
|
|
|
|
|
'deprecated', |
|
159
|
|
|
|
|
|
|
'Refresh in is deprecated, use AnnounceRefresh instead' |
|
160
|
|
|
|
|
|
|
); |
|
161
|
0
|
|
|
|
|
0
|
$this->{_announce_refresh} = $value; |
|
162
|
|
|
|
|
|
|
} |
|
163
|
|
|
|
|
|
|
elsif ( $arg =~ /^announcerefresh$/i ) { |
|
164
|
4
|
|
|
|
|
14
|
$this->{_announce_refresh} = $value; |
|
165
|
|
|
|
|
|
|
} |
|
166
|
|
|
|
|
|
|
elsif ( $arg =~ /^supportcapabilities$/i ) { |
|
167
|
0
|
|
|
|
|
0
|
$this->{_support_capabilities} = $value; |
|
168
|
|
|
|
|
|
|
} |
|
169
|
|
|
|
|
|
|
elsif ( $arg =~ /^supportmbgp$/i ) { |
|
170
|
4
|
|
|
|
|
13
|
$this->{_support_mbgp} = $value; |
|
171
|
|
|
|
|
|
|
} |
|
172
|
|
|
|
|
|
|
elsif ( $arg =~ /^supportas4$/i ) { |
|
173
|
3
|
|
|
|
|
8
|
$this->{_support_as4} = $value; |
|
174
|
|
|
|
|
|
|
} |
|
175
|
|
|
|
|
|
|
elsif ( $arg =~ /^opencallback$/i ) { |
|
176
|
0
|
|
|
|
|
0
|
$this->{_open_callback} = $value; |
|
177
|
|
|
|
|
|
|
} |
|
178
|
|
|
|
|
|
|
elsif ( $arg =~ /^establishedcallback$/i ) { |
|
179
|
0
|
|
|
|
|
0
|
$this->{_established_callback} = $value; |
|
180
|
|
|
|
|
|
|
} |
|
181
|
|
|
|
|
|
|
elsif ( $arg =~ /^keepalivecallback$/i ) { |
|
182
|
0
|
|
|
|
|
0
|
$this->{_keepalive_callback} = $value; |
|
183
|
|
|
|
|
|
|
} |
|
184
|
|
|
|
|
|
|
elsif ( $arg =~ /^updatecallback$/i ) { |
|
185
|
0
|
|
|
|
|
0
|
$this->{_update_callback} = $value; |
|
186
|
|
|
|
|
|
|
} |
|
187
|
|
|
|
|
|
|
elsif ( $arg =~ /^resetcallback$/i ) { |
|
188
|
0
|
|
|
|
|
0
|
$this->{_reset_callback} = $value; |
|
189
|
|
|
|
|
|
|
} |
|
190
|
|
|
|
|
|
|
elsif ( $arg =~ /^notificationcallback$/i ) { |
|
191
|
0
|
|
|
|
|
0
|
$this->{_notification_callback} = $value; |
|
192
|
|
|
|
|
|
|
} |
|
193
|
|
|
|
|
|
|
elsif ( $arg =~ /^errorcallback$/i ) { |
|
194
|
0
|
|
|
|
|
0
|
$this->{_error_callback} = $value; |
|
195
|
|
|
|
|
|
|
} |
|
196
|
|
|
|
|
|
|
else { |
|
197
|
0
|
|
|
|
|
0
|
croak "unrecognized argument $arg\n"; |
|
198
|
|
|
|
|
|
|
} |
|
199
|
|
|
|
|
|
|
} |
|
200
|
|
|
|
|
|
|
|
|
201
|
5
|
|
|
|
|
10
|
$transarg{parent} = $this; |
|
202
|
5
|
|
|
|
|
37
|
$this->{_transport} = Net::BGP::Transport->new(%transarg); |
|
203
|
|
|
|
|
|
|
|
|
204
|
5
|
|
|
|
|
30
|
weaken($knownpeers{$this} = $this); |
|
205
|
5
|
|
|
|
|
24
|
return ( $this ); |
|
206
|
|
|
|
|
|
|
} |
|
207
|
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
sub renew |
|
209
|
|
|
|
|
|
|
{ |
|
210
|
0
|
|
|
0
|
0
|
0
|
my $proto = shift; |
|
211
|
0
|
|
0
|
|
|
0
|
my $class = ref $proto || $proto; |
|
212
|
0
|
|
|
|
|
0
|
my $name = shift; |
|
213
|
0
|
|
|
|
|
0
|
return $knownpeers{$name}; |
|
214
|
|
|
|
|
|
|
} |
|
215
|
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
## Public Object Methods - Proxies for backward compatibility ## |
|
217
|
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
sub start |
|
219
|
|
|
|
|
|
|
{ |
|
220
|
0
|
|
|
0
|
0
|
0
|
foreach my $trans (shift->transports) |
|
221
|
|
|
|
|
|
|
{ |
|
222
|
0
|
|
|
|
|
0
|
$trans->start(); |
|
223
|
|
|
|
|
|
|
}; |
|
224
|
|
|
|
|
|
|
} |
|
225
|
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
sub stop |
|
227
|
|
|
|
|
|
|
{ |
|
228
|
6
|
|
|
6
|
0
|
42
|
foreach my $trans (shift->transports) |
|
229
|
|
|
|
|
|
|
{ |
|
230
|
6
|
|
|
|
|
22
|
$trans->stop(); |
|
231
|
|
|
|
|
|
|
}; |
|
232
|
|
|
|
|
|
|
} |
|
233
|
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
sub version |
|
235
|
|
|
|
|
|
|
{ |
|
236
|
0
|
|
|
0
|
0
|
0
|
return shift->transport->version; |
|
237
|
|
|
|
|
|
|
} |
|
238
|
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
sub update |
|
240
|
|
|
|
|
|
|
{ |
|
241
|
4
|
|
|
4
|
0
|
57
|
return shift->transport->update(@_); |
|
242
|
|
|
|
|
|
|
} |
|
243
|
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
sub refresh |
|
245
|
|
|
|
|
|
|
{ |
|
246
|
2
|
|
|
2
|
0
|
18
|
return shift->transport->refresh(@_); |
|
247
|
|
|
|
|
|
|
} |
|
248
|
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
## Public Object Methods ## |
|
250
|
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
sub transport |
|
252
|
|
|
|
|
|
|
{ |
|
253
|
413
|
|
|
413
|
0
|
588
|
my $this = shift(); |
|
254
|
413
|
50
|
|
|
|
792
|
$this->{_transport} = shift if @_; |
|
255
|
413
|
|
|
|
|
1394
|
return $this->{_transport}; |
|
256
|
|
|
|
|
|
|
} |
|
257
|
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
sub transports |
|
259
|
|
|
|
|
|
|
{ |
|
260
|
162
|
|
|
162
|
0
|
213
|
my $this = shift(); |
|
261
|
162
|
50
|
|
|
|
302
|
return ($this->transport) unless defined $this->transport->sibling; |
|
262
|
0
|
|
|
|
|
0
|
return ($this->transport,$this->transport->sibling); |
|
263
|
|
|
|
|
|
|
} |
|
264
|
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
sub this_id |
|
266
|
|
|
|
|
|
|
{ |
|
267
|
14
|
|
|
14
|
0
|
23
|
my $this = shift(); |
|
268
|
14
|
|
|
|
|
109
|
return ( $this->{_local_id} ); |
|
269
|
|
|
|
|
|
|
} |
|
270
|
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
sub this_as |
|
272
|
|
|
|
|
|
|
{ |
|
273
|
12
|
|
|
12
|
0
|
17
|
my $this = shift(); |
|
274
|
12
|
|
|
|
|
58
|
return ( $this->{_local_as} ); |
|
275
|
|
|
|
|
|
|
} |
|
276
|
|
|
|
|
|
|
|
|
277
|
|
|
|
|
|
|
sub this_can_refresh |
|
278
|
|
|
|
|
|
|
{ |
|
279
|
8
|
|
|
8
|
0
|
16
|
my $this = shift(); |
|
280
|
8
|
|
|
|
|
34
|
return ( $this->{_announce_refresh} ); |
|
281
|
|
|
|
|
|
|
} |
|
282
|
|
|
|
|
|
|
|
|
283
|
|
|
|
|
|
|
sub this_can_as4 |
|
284
|
|
|
|
|
|
|
{ |
|
285
|
8
|
|
|
8
|
0
|
14
|
my $this = shift(); |
|
286
|
8
|
|
|
|
|
35
|
return ( $this->{_support_as4} ); |
|
287
|
|
|
|
|
|
|
} |
|
288
|
|
|
|
|
|
|
|
|
289
|
|
|
|
|
|
|
sub support_capabilities |
|
290
|
|
|
|
|
|
|
{ |
|
291
|
6
|
|
|
6
|
0
|
11
|
my $this = shift(); |
|
292
|
6
|
|
|
|
|
23
|
return ( $this->{_support_capabilities} ); |
|
293
|
|
|
|
|
|
|
} |
|
294
|
|
|
|
|
|
|
|
|
295
|
|
|
|
|
|
|
sub support_mbgp |
|
296
|
|
|
|
|
|
|
{ |
|
297
|
6
|
|
|
6
|
0
|
19
|
my $this = shift(); |
|
298
|
6
|
|
|
|
|
19
|
return ( $this->{_support_mbgp} ); |
|
299
|
|
|
|
|
|
|
} |
|
300
|
|
|
|
|
|
|
|
|
301
|
|
|
|
|
|
|
sub peer_id |
|
302
|
|
|
|
|
|
|
{ |
|
303
|
8
|
|
|
8
|
0
|
14
|
my $this = shift(); |
|
304
|
8
|
|
|
|
|
45
|
return ( $this->{_peer_id} ); |
|
305
|
|
|
|
|
|
|
} |
|
306
|
|
|
|
|
|
|
|
|
307
|
|
|
|
|
|
|
sub peer_as |
|
308
|
|
|
|
|
|
|
{ |
|
309
|
11
|
|
|
11
|
0
|
18
|
my $this = shift(); |
|
310
|
11
|
|
|
|
|
71
|
return ( $this->{_peer_as} ); |
|
311
|
|
|
|
|
|
|
} |
|
312
|
|
|
|
|
|
|
|
|
313
|
|
|
|
|
|
|
sub peer_port |
|
314
|
|
|
|
|
|
|
{ |
|
315
|
2
|
|
|
2
|
0
|
4
|
my $this = shift(); |
|
316
|
2
|
|
|
|
|
10
|
return ( $this->{_peer_port} ); |
|
317
|
|
|
|
|
|
|
} |
|
318
|
|
|
|
|
|
|
|
|
319
|
|
|
|
|
|
|
sub peer_can_as4 |
|
320
|
|
|
|
|
|
|
{ |
|
321
|
1
|
|
|
1
|
0
|
5
|
my $this = shift(); |
|
322
|
1
|
|
|
|
|
3
|
return $this->transport->can_as4; |
|
323
|
|
|
|
|
|
|
} |
|
324
|
|
|
|
|
|
|
|
|
325
|
|
|
|
|
|
|
sub peer_can_mbgp |
|
326
|
|
|
|
|
|
|
{ |
|
327
|
2
|
|
|
2
|
0
|
18
|
my $this = shift(); |
|
328
|
2
|
|
|
|
|
9
|
return $this->transport->can_mbgp; |
|
329
|
|
|
|
|
|
|
} |
|
330
|
|
|
|
|
|
|
|
|
331
|
|
|
|
|
|
|
sub peer_can_refresh |
|
332
|
|
|
|
|
|
|
{ |
|
333
|
0
|
|
|
0
|
0
|
0
|
my $this = shift(); |
|
334
|
0
|
|
|
|
|
0
|
return $this->transport->can_refresh; |
|
335
|
|
|
|
|
|
|
} |
|
336
|
|
|
|
|
|
|
|
|
337
|
|
|
|
|
|
|
sub is_listener |
|
338
|
|
|
|
|
|
|
{ |
|
339
|
8
|
|
|
8
|
0
|
27
|
my $this = shift(); |
|
340
|
8
|
|
|
|
|
64
|
return ( $this->{_listen} ); |
|
341
|
|
|
|
|
|
|
} |
|
342
|
|
|
|
|
|
|
|
|
343
|
|
|
|
|
|
|
sub is_passive |
|
344
|
|
|
|
|
|
|
{ |
|
345
|
10
|
|
|
10
|
0
|
12
|
my $this = shift(); |
|
346
|
10
|
|
|
|
|
38
|
return ( $this->{_passive} ); |
|
347
|
|
|
|
|
|
|
} |
|
348
|
|
|
|
|
|
|
|
|
349
|
|
|
|
|
|
|
sub is_established |
|
350
|
|
|
|
|
|
|
{ |
|
351
|
0
|
|
|
0
|
0
|
0
|
my $this = shift(); |
|
352
|
0
|
|
|
|
|
0
|
return ( $this->transport->is_established ); |
|
353
|
|
|
|
|
|
|
} |
|
354
|
|
|
|
|
|
|
|
|
355
|
|
|
|
|
|
|
sub set_open_callback |
|
356
|
|
|
|
|
|
|
{ |
|
357
|
2
|
|
|
2
|
0
|
13
|
my ($this, $callback) = @_; |
|
358
|
2
|
|
|
|
|
5
|
$this->{_open_callback} = $callback; |
|
359
|
|
|
|
|
|
|
} |
|
360
|
|
|
|
|
|
|
|
|
361
|
|
|
|
|
|
|
sub set_established_callback |
|
362
|
|
|
|
|
|
|
{ |
|
363
|
2
|
|
|
2
|
0
|
11
|
my ($this, $callback) = @_; |
|
364
|
2
|
|
|
|
|
5
|
$this->{_established_callback} = $callback; |
|
365
|
|
|
|
|
|
|
} |
|
366
|
|
|
|
|
|
|
|
|
367
|
|
|
|
|
|
|
sub set_keepalive_callback |
|
368
|
|
|
|
|
|
|
{ |
|
369
|
4
|
|
|
4
|
0
|
24
|
my ($this, $callback) = @_; |
|
370
|
4
|
|
|
|
|
14
|
$this->{_keepalive_callback} = $callback; |
|
371
|
|
|
|
|
|
|
} |
|
372
|
|
|
|
|
|
|
|
|
373
|
|
|
|
|
|
|
sub set_update_callback |
|
374
|
|
|
|
|
|
|
{ |
|
375
|
2
|
|
|
2
|
0
|
10
|
my ($this, $callback) = @_; |
|
376
|
2
|
|
|
|
|
4
|
$this->{_update_callback} = $callback; |
|
377
|
|
|
|
|
|
|
} |
|
378
|
|
|
|
|
|
|
|
|
379
|
|
|
|
|
|
|
sub set_refresh_callback |
|
380
|
|
|
|
|
|
|
{ |
|
381
|
2
|
|
|
2
|
0
|
10
|
my ($this, $callback) = @_; |
|
382
|
2
|
|
|
|
|
7
|
$this->{_refresh_callback} = $callback; |
|
383
|
|
|
|
|
|
|
} |
|
384
|
|
|
|
|
|
|
|
|
385
|
|
|
|
|
|
|
sub set_reset_callback |
|
386
|
|
|
|
|
|
|
{ |
|
387
|
4
|
|
|
4
|
0
|
17
|
my ($this, $callback) = @_; |
|
388
|
4
|
|
|
|
|
9
|
$this->{_reset_callback} = $callback; |
|
389
|
|
|
|
|
|
|
} |
|
390
|
|
|
|
|
|
|
|
|
391
|
|
|
|
|
|
|
sub set_notification_callback |
|
392
|
|
|
|
|
|
|
{ |
|
393
|
4
|
|
|
4
|
0
|
16
|
my ($this, $callback) = @_; |
|
394
|
4
|
|
|
|
|
9
|
$this->{_notification_callback} = $callback; |
|
395
|
|
|
|
|
|
|
} |
|
396
|
|
|
|
|
|
|
|
|
397
|
|
|
|
|
|
|
sub set_error_callback |
|
398
|
|
|
|
|
|
|
{ |
|
399
|
6
|
|
|
6
|
0
|
31
|
my ($this, $callback) = @_; |
|
400
|
6
|
|
|
|
|
15
|
$this->{_error_callback} = $callback; |
|
401
|
|
|
|
|
|
|
} |
|
402
|
|
|
|
|
|
|
|
|
403
|
|
|
|
|
|
|
sub add_timer |
|
404
|
|
|
|
|
|
|
{ |
|
405
|
2
|
|
|
2
|
0
|
17
|
my ($this, $callback, $timeout) = @_; |
|
406
|
2
|
|
|
|
|
3
|
my $timer; |
|
407
|
|
|
|
|
|
|
|
|
408
|
2
|
|
|
|
|
9
|
$timer = { |
|
409
|
|
|
|
|
|
|
_timer => $timeout, |
|
410
|
|
|
|
|
|
|
_timeout => $timeout, |
|
411
|
|
|
|
|
|
|
_callback => $callback, |
|
412
|
|
|
|
|
|
|
}; |
|
413
|
|
|
|
|
|
|
|
|
414
|
2
|
|
|
|
|
18
|
$this->{_user_timers}->{$timer} = $timer; |
|
415
|
|
|
|
|
|
|
} |
|
416
|
|
|
|
|
|
|
|
|
417
|
|
|
|
|
|
|
sub remove_timer |
|
418
|
|
|
|
|
|
|
{ |
|
419
|
2
|
|
|
2
|
0
|
49
|
my ($this, $callback) = @_; |
|
420
|
2
|
|
|
|
|
8
|
my ($key, $timer); |
|
421
|
|
|
|
|
|
|
|
|
422
|
2
|
|
|
|
|
4
|
foreach $key ( keys(%{$this->{_user_timers}}) ) { |
|
|
2
|
|
|
|
|
12
|
|
|
423
|
2
|
|
|
|
|
7
|
$timer = $this->{_user_timers}->{$key}; |
|
424
|
2
|
50
|
|
|
|
15
|
if ( $timer->{_callback} == $callback ) { |
|
425
|
2
|
|
|
|
|
22
|
delete $this->{_user_timers}->{$key}; |
|
426
|
|
|
|
|
|
|
} |
|
427
|
|
|
|
|
|
|
} |
|
428
|
|
|
|
|
|
|
} |
|
429
|
|
|
|
|
|
|
|
|
430
|
|
|
|
|
|
|
sub asstring |
|
431
|
|
|
|
|
|
|
{ |
|
432
|
0
|
|
|
0
|
0
|
0
|
my $this = shift; |
|
433
|
|
|
|
|
|
|
|
|
434
|
0
|
0
|
|
|
|
0
|
my @l = map { defined $_ ? $_ : 'n/a'; } ( |
|
|
0
|
|
|
|
|
0
|
|
|
435
|
|
|
|
|
|
|
$this->this_id, $this->this_as, |
|
436
|
|
|
|
|
|
|
$this->peer_id, $this->peer_as); |
|
437
|
|
|
|
|
|
|
|
|
438
|
0
|
|
|
|
|
0
|
return $l[0] . ':' . $l[1] . '<=>' . $l[2] . ':' . $l[3]; |
|
439
|
|
|
|
|
|
|
} |
|
440
|
|
|
|
|
|
|
|
|
441
|
|
|
|
|
|
|
## Overridable Methods ## |
|
442
|
|
|
|
|
|
|
|
|
443
|
|
|
|
|
|
|
sub open_callback |
|
444
|
|
|
|
|
|
|
{ |
|
445
|
4
|
|
|
4
|
0
|
149
|
my $this = shift(); |
|
446
|
|
|
|
|
|
|
|
|
447
|
4
|
100
|
|
|
|
28
|
if ( defined($this->{_open_callback}) ) { |
|
448
|
2
|
|
|
|
|
3
|
&{ $this->{_open_callback} }($this); |
|
|
2
|
|
|
|
|
18
|
|
|
449
|
|
|
|
|
|
|
} |
|
450
|
|
|
|
|
|
|
} |
|
451
|
|
|
|
|
|
|
|
|
452
|
|
|
|
|
|
|
sub established_callback |
|
453
|
|
|
|
|
|
|
{ |
|
454
|
4
|
|
|
4
|
0
|
9
|
my $this = shift(); |
|
455
|
|
|
|
|
|
|
|
|
456
|
4
|
100
|
|
|
|
20
|
if ( defined($this->{_established_callback}) ) { |
|
457
|
2
|
|
|
|
|
5
|
&{ $this->{_established_callback} }($this); |
|
|
2
|
|
|
|
|
8
|
|
|
458
|
|
|
|
|
|
|
} |
|
459
|
|
|
|
|
|
|
} |
|
460
|
|
|
|
|
|
|
|
|
461
|
|
|
|
|
|
|
sub keepalive_callback |
|
462
|
|
|
|
|
|
|
{ |
|
463
|
8
|
|
|
8
|
0
|
14
|
my $this = shift(); |
|
464
|
|
|
|
|
|
|
|
|
465
|
8
|
100
|
|
|
|
29
|
if ( defined($this->{_keepalive_callback}) ) { |
|
466
|
4
|
|
|
|
|
6
|
&{ $this->{_keepalive_callback} }($this); |
|
|
4
|
|
|
|
|
23
|
|
|
467
|
|
|
|
|
|
|
} |
|
468
|
|
|
|
|
|
|
} |
|
469
|
|
|
|
|
|
|
|
|
470
|
|
|
|
|
|
|
sub update_callback |
|
471
|
|
|
|
|
|
|
{ |
|
472
|
4
|
|
|
4
|
0
|
9
|
my ($this, $update) = @_; |
|
473
|
|
|
|
|
|
|
|
|
474
|
4
|
50
|
|
|
|
16
|
if ( defined($this->{_update_callback}) ) { |
|
475
|
4
|
|
|
|
|
9
|
&{ $this->{_update_callback} }($this, $update); |
|
|
4
|
|
|
|
|
20
|
|
|
476
|
|
|
|
|
|
|
} |
|
477
|
|
|
|
|
|
|
} |
|
478
|
|
|
|
|
|
|
|
|
479
|
|
|
|
|
|
|
sub refresh_callback |
|
480
|
|
|
|
|
|
|
{ |
|
481
|
6
|
|
|
6
|
0
|
11
|
my ($this,$refresh) = @_; |
|
482
|
|
|
|
|
|
|
|
|
483
|
6
|
100
|
|
|
|
25
|
if ( defined($this->{_refresh_callback}) ) { |
|
484
|
4
|
|
|
|
|
9
|
&{ $this->{_refresh_callback} }($this,$refresh); |
|
|
4
|
|
|
|
|
21
|
|
|
485
|
|
|
|
|
|
|
} |
|
486
|
|
|
|
|
|
|
} |
|
487
|
|
|
|
|
|
|
|
|
488
|
|
|
|
|
|
|
sub reset_callback |
|
489
|
|
|
|
|
|
|
{ |
|
490
|
8
|
|
|
8
|
0
|
12
|
my ($this,$refresh) = @_; |
|
491
|
|
|
|
|
|
|
|
|
492
|
8
|
50
|
|
|
|
22
|
if ( defined($this->{_reset_callback}) ) { |
|
493
|
8
|
|
|
|
|
9
|
&{ $this->{_reset_callback} }($this); |
|
|
8
|
|
|
|
|
29
|
|
|
494
|
|
|
|
|
|
|
} |
|
495
|
|
|
|
|
|
|
} |
|
496
|
|
|
|
|
|
|
|
|
497
|
|
|
|
|
|
|
sub notification_callback |
|
498
|
|
|
|
|
|
|
{ |
|
499
|
2
|
|
|
2
|
0
|
5
|
my ($this, $error) = @_; |
|
500
|
|
|
|
|
|
|
|
|
501
|
2
|
50
|
|
|
|
11
|
if ( defined($this->{_notification_callback}) ) { |
|
502
|
2
|
|
|
|
|
4
|
&{ $this->{_notification_callback} }($this, $error); |
|
|
2
|
|
|
|
|
10
|
|
|
503
|
|
|
|
|
|
|
} |
|
504
|
|
|
|
|
|
|
} |
|
505
|
|
|
|
|
|
|
|
|
506
|
|
|
|
|
|
|
sub error_callback |
|
507
|
|
|
|
|
|
|
{ |
|
508
|
6
|
|
|
6
|
0
|
11
|
my ($this, $error) = @_; |
|
509
|
|
|
|
|
|
|
|
|
510
|
6
|
100
|
|
|
|
23
|
if ( defined($this->{_error_callback}) ) { |
|
511
|
4
|
|
|
|
|
6
|
&{ $this->{_error_callback} }($this, $error); |
|
|
4
|
|
|
|
|
41
|
|
|
512
|
|
|
|
|
|
|
} |
|
513
|
|
|
|
|
|
|
} |
|
514
|
|
|
|
|
|
|
|
|
515
|
|
|
|
|
|
|
## Private Object Methods ## |
|
516
|
|
|
|
|
|
|
|
|
517
|
|
|
|
|
|
|
sub _update_timers |
|
518
|
|
|
|
|
|
|
{ |
|
519
|
76
|
|
|
76
|
|
118
|
my ($this, $delta) = @_; |
|
520
|
|
|
|
|
|
|
|
|
521
|
|
|
|
|
|
|
# Proxy for transport timers |
|
522
|
76
|
|
|
|
|
148
|
my $min_time = $this->transport->_update_timers($delta); |
|
523
|
|
|
|
|
|
|
|
|
524
|
|
|
|
|
|
|
# Update user defined timers |
|
525
|
76
|
|
|
|
|
109
|
foreach my $key ( keys(%{$this->{_user_timers}}) ) { |
|
|
76
|
|
|
|
|
255
|
|
|
526
|
20
|
|
|
|
|
42
|
my $timer = $this->{_user_timers}->{$key}; |
|
527
|
20
|
50
|
|
|
|
56
|
if ( defined($timer->{_timer}) ) { |
|
528
|
20
|
|
|
|
|
35
|
$timer->{_timer} -= $delta; |
|
529
|
|
|
|
|
|
|
|
|
530
|
20
|
100
|
|
|
|
55
|
if ( $timer->{_timer} <= 0 ) { |
|
531
|
4
|
|
|
|
|
49
|
$timer->{_timer} = $timer->{_timeout}; |
|
532
|
4
|
|
|
|
|
12
|
&{ $timer->{_callback} }($this); |
|
|
4
|
|
|
|
|
43
|
|
|
533
|
|
|
|
|
|
|
} |
|
534
|
|
|
|
|
|
|
|
|
535
|
20
|
50
|
|
|
|
91
|
my $min = ($timer->{_timer} < 0) ? 0 : $timer->{_timer}; |
|
536
|
20
|
50
|
|
|
|
55
|
if ( $min < $min_time ) { |
|
537
|
20
|
|
|
|
|
61
|
$min_time = $min; |
|
538
|
|
|
|
|
|
|
} |
|
539
|
|
|
|
|
|
|
} |
|
540
|
|
|
|
|
|
|
} |
|
541
|
|
|
|
|
|
|
|
|
542
|
76
|
|
|
|
|
199
|
return ( $min_time ); |
|
543
|
|
|
|
|
|
|
} |
|
544
|
|
|
|
|
|
|
|
|
545
|
|
|
|
|
|
|
## POD ## |
|
546
|
|
|
|
|
|
|
|
|
547
|
|
|
|
|
|
|
=pod |
|
548
|
|
|
|
|
|
|
|
|
549
|
|
|
|
|
|
|
=head1 NAME |
|
550
|
|
|
|
|
|
|
|
|
551
|
|
|
|
|
|
|
Net::BGP::Peer - Class encapsulating BGP-4 peering session state and functionality |
|
552
|
|
|
|
|
|
|
|
|
553
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
554
|
|
|
|
|
|
|
|
|
555
|
|
|
|
|
|
|
use Net::BGP::Peer; |
|
556
|
|
|
|
|
|
|
|
|
557
|
|
|
|
|
|
|
$peer = Net::BGP::Peer->new( |
|
558
|
|
|
|
|
|
|
Start => 1, |
|
559
|
|
|
|
|
|
|
ThisID => '10.0.0.1', |
|
560
|
|
|
|
|
|
|
ThisAS => 64512, |
|
561
|
|
|
|
|
|
|
PeerID => '10.0.0.2', |
|
562
|
|
|
|
|
|
|
PeerAS => 64513, |
|
563
|
|
|
|
|
|
|
PeerPort => 1179, |
|
564
|
|
|
|
|
|
|
ConnectRetryTime => 300, |
|
565
|
|
|
|
|
|
|
HoldTime => 60, |
|
566
|
|
|
|
|
|
|
KeepAliveTime => 20, |
|
567
|
|
|
|
|
|
|
Listen => 0, |
|
568
|
|
|
|
|
|
|
Passive => 0, |
|
569
|
|
|
|
|
|
|
AnnounceRefresh => 1, |
|
570
|
|
|
|
|
|
|
SupportCapabilities => 1, |
|
571
|
|
|
|
|
|
|
SupportMBGP => 1, |
|
572
|
|
|
|
|
|
|
SupportAS4 => 1, |
|
573
|
|
|
|
|
|
|
OpenCallback => \&my_open_callback, |
|
574
|
|
|
|
|
|
|
KeepaliveCallback => \&my_keepalive_callback, |
|
575
|
|
|
|
|
|
|
UpdateCallback => \&my_update_callback, |
|
576
|
|
|
|
|
|
|
NotificationCallback => \&my_notification_callback, |
|
577
|
|
|
|
|
|
|
ErrorCallback => \&my_error_callback |
|
578
|
|
|
|
|
|
|
); |
|
579
|
|
|
|
|
|
|
|
|
580
|
|
|
|
|
|
|
$peer = renew Net::BGP::Peer("$peer"); |
|
581
|
|
|
|
|
|
|
|
|
582
|
|
|
|
|
|
|
$peer->start(); |
|
583
|
|
|
|
|
|
|
$peer->stop(); |
|
584
|
|
|
|
|
|
|
|
|
585
|
|
|
|
|
|
|
$peer->update($update); |
|
586
|
|
|
|
|
|
|
$peer->refresh($refresh); |
|
587
|
|
|
|
|
|
|
|
|
588
|
|
|
|
|
|
|
$version = $peer->version(); |
|
589
|
|
|
|
|
|
|
|
|
590
|
|
|
|
|
|
|
$this_id = $peer->this_id(); |
|
591
|
|
|
|
|
|
|
$this_as = $peer->this_as(); |
|
592
|
|
|
|
|
|
|
$peer_id = $peer->peer_id(); |
|
593
|
|
|
|
|
|
|
$peer_as = $peer->peer_as(); |
|
594
|
|
|
|
|
|
|
|
|
595
|
|
|
|
|
|
|
$i_will = $peer->support_capabilities(); |
|
596
|
|
|
|
|
|
|
|
|
597
|
|
|
|
|
|
|
$i_mbgp = $peer->support_mbgp(); |
|
598
|
|
|
|
|
|
|
|
|
599
|
|
|
|
|
|
|
$i_can = $peer->this_can_refresh(); |
|
600
|
|
|
|
|
|
|
$peer_can= $peer->peer_can_refresh(); |
|
601
|
|
|
|
|
|
|
|
|
602
|
|
|
|
|
|
|
$peer_as4= $peer->peer_can_as4(); |
|
603
|
|
|
|
|
|
|
|
|
604
|
|
|
|
|
|
|
$listen = $peer->is_listener(); |
|
605
|
|
|
|
|
|
|
$passive = $peer->is_passive(); |
|
606
|
|
|
|
|
|
|
$estab = $peer->is_established(); |
|
607
|
|
|
|
|
|
|
|
|
608
|
|
|
|
|
|
|
$trans = $peer->transport($trans); |
|
609
|
|
|
|
|
|
|
@trans = $peer->transports; |
|
610
|
|
|
|
|
|
|
|
|
611
|
|
|
|
|
|
|
$string = $peer->asstring(); |
|
612
|
|
|
|
|
|
|
|
|
613
|
|
|
|
|
|
|
$peer->set_open_callback(\&my_open_callback); |
|
614
|
|
|
|
|
|
|
$peer->set_established_callback(\&my_established_callback); |
|
615
|
|
|
|
|
|
|
$peer->set_keepalive_callback(\&my_keepalive_callback); |
|
616
|
|
|
|
|
|
|
$peer->set_update_callback(\&my_update_callback); |
|
617
|
|
|
|
|
|
|
$peer->set_notification_callback(\&my_notification_callback); |
|
618
|
|
|
|
|
|
|
$peer->set_error_callback(\&my_error_callback); |
|
619
|
|
|
|
|
|
|
|
|
620
|
|
|
|
|
|
|
$peer->add_timer(\&my_minute_timer, 60); |
|
621
|
|
|
|
|
|
|
$peer->remove_timer(\&my_minute_timer); |
|
622
|
|
|
|
|
|
|
|
|
623
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
624
|
|
|
|
|
|
|
|
|
625
|
|
|
|
|
|
|
This module encapsulates the state and functionality associated with a BGP |
|
626
|
|
|
|
|
|
|
peering session. Each instance of a B object corresponds |
|
627
|
|
|
|
|
|
|
to a peering session with a distinct peer and presents a programming |
|
628
|
|
|
|
|
|
|
interface to manipulate the peering session state and exchange of routing |
|
629
|
|
|
|
|
|
|
information. Through the methods provided by the B module, |
|
630
|
|
|
|
|
|
|
a program can start or stop peering sessions, send BGP routing UPDATE |
|
631
|
|
|
|
|
|
|
messages, and register callback functions which are invoked whenever the |
|
632
|
|
|
|
|
|
|
peer receives BGP messages from its peer. |
|
633
|
|
|
|
|
|
|
|
|
634
|
|
|
|
|
|
|
=head1 CONSTRUCTOR |
|
635
|
|
|
|
|
|
|
|
|
636
|
|
|
|
|
|
|
I - create a new Net::BGP::Peer object |
|
637
|
|
|
|
|
|
|
|
|
638
|
|
|
|
|
|
|
This is the constructor for Net::BGP::Peer objects. It returns a |
|
639
|
|
|
|
|
|
|
reference to the newly created object. The following named parameters may |
|
640
|
|
|
|
|
|
|
be passed to the constructor. Once the object is created, only the |
|
641
|
|
|
|
|
|
|
callback function references can later be changed. |
|
642
|
|
|
|
|
|
|
|
|
643
|
|
|
|
|
|
|
=head2 Start |
|
644
|
|
|
|
|
|
|
|
|
645
|
|
|
|
|
|
|
Setting this parameter to a true value causes the peer to initiate a |
|
646
|
|
|
|
|
|
|
session with its peer immediately after it is registered with the |
|
647
|
|
|
|
|
|
|
B object's I method. If omitted or |
|
648
|
|
|
|
|
|
|
set to a false value, the peer will remain in the Idle state until |
|
649
|
|
|
|
|
|
|
the I method is called explicitly by the program. When in |
|
650
|
|
|
|
|
|
|
the Idle state the peer will refuse connections and will not initiate |
|
651
|
|
|
|
|
|
|
connection attempts. |
|
652
|
|
|
|
|
|
|
|
|
653
|
|
|
|
|
|
|
=head2 ThisID |
|
654
|
|
|
|
|
|
|
|
|
655
|
|
|
|
|
|
|
This parameter sets the BGP ID (IP address) of the B |
|
656
|
|
|
|
|
|
|
object. It takes a string in IP dotted decimal notation. |
|
657
|
|
|
|
|
|
|
|
|
658
|
|
|
|
|
|
|
=head2 ThisAS |
|
659
|
|
|
|
|
|
|
|
|
660
|
|
|
|
|
|
|
This parameter sets the BGP Autonomous System number of the B |
|
661
|
|
|
|
|
|
|
object. It takes an integer value in the range of a 16-bit unsigned integer. |
|
662
|
|
|
|
|
|
|
|
|
663
|
|
|
|
|
|
|
=head2 PeerID |
|
664
|
|
|
|
|
|
|
|
|
665
|
|
|
|
|
|
|
This parameter sets the BGP ID (IP address) of the object's peer. It takes |
|
666
|
|
|
|
|
|
|
a string in IP dotted decimal notation. |
|
667
|
|
|
|
|
|
|
|
|
668
|
|
|
|
|
|
|
=head2 PeerAS |
|
669
|
|
|
|
|
|
|
|
|
670
|
|
|
|
|
|
|
This parameter sets the BGP Autonomous System number of the object's peer. |
|
671
|
|
|
|
|
|
|
It takes an integer value in the range of a 16-bit unsigned integer. |
|
672
|
|
|
|
|
|
|
|
|
673
|
|
|
|
|
|
|
=head2 PeerPort |
|
674
|
|
|
|
|
|
|
|
|
675
|
|
|
|
|
|
|
This parameter sets the TCP port number on the peer to which to connect. It |
|
676
|
|
|
|
|
|
|
must be in the range of a valid TCP port number. |
|
677
|
|
|
|
|
|
|
|
|
678
|
|
|
|
|
|
|
=head2 ConnectRetryTime |
|
679
|
|
|
|
|
|
|
|
|
680
|
|
|
|
|
|
|
This parameter sets the BGP ConnectRetry timer duration, the value of which |
|
681
|
|
|
|
|
|
|
is given in seconds. |
|
682
|
|
|
|
|
|
|
|
|
683
|
|
|
|
|
|
|
=head2 HoldTime |
|
684
|
|
|
|
|
|
|
|
|
685
|
|
|
|
|
|
|
This parameter sets the BGP Hold Time duration, the value of which |
|
686
|
|
|
|
|
|
|
is given in seconds. |
|
687
|
|
|
|
|
|
|
|
|
688
|
|
|
|
|
|
|
=head2 KeepAliveTime |
|
689
|
|
|
|
|
|
|
|
|
690
|
|
|
|
|
|
|
This parameter sets the BGP KeepAlive timer duration, the value of which |
|
691
|
|
|
|
|
|
|
is given in seconds. |
|
692
|
|
|
|
|
|
|
|
|
693
|
|
|
|
|
|
|
=head2 Listen |
|
694
|
|
|
|
|
|
|
|
|
695
|
|
|
|
|
|
|
This parameter specifies whether the B will listen for |
|
696
|
|
|
|
|
|
|
and accept connections from its peer. If set to a false value, the peer |
|
697
|
|
|
|
|
|
|
will only initiate connections and will not accept connection attempts |
|
698
|
|
|
|
|
|
|
from the peer (unless the B parameter is set to a true value). |
|
699
|
|
|
|
|
|
|
Note that this behavior is not specified by RFC 1771 and should be |
|
700
|
|
|
|
|
|
|
considered non-standard. However, it is useful under certain circumstances |
|
701
|
|
|
|
|
|
|
and should not present problems as long as one side of the connection is |
|
702
|
|
|
|
|
|
|
configured to listen. |
|
703
|
|
|
|
|
|
|
|
|
704
|
|
|
|
|
|
|
=head2 Passive |
|
705
|
|
|
|
|
|
|
|
|
706
|
|
|
|
|
|
|
This parameter specifies whether the B will attempt to |
|
707
|
|
|
|
|
|
|
initiate connections to its peer. If set to a true value, the peer will |
|
708
|
|
|
|
|
|
|
only listen for connections and will not initate connections to its peer |
|
709
|
|
|
|
|
|
|
(unless the B parameter is set to false value). Note that this |
|
710
|
|
|
|
|
|
|
behavior is not specified by RFC 1771 and should be considered non-standard. |
|
711
|
|
|
|
|
|
|
However, it is useful under certain circumstances and should not present |
|
712
|
|
|
|
|
|
|
problems as long as one side of the connection is configured to initiate |
|
713
|
|
|
|
|
|
|
connections. |
|
714
|
|
|
|
|
|
|
|
|
715
|
|
|
|
|
|
|
=head2 Refresh |
|
716
|
|
|
|
|
|
|
|
|
717
|
|
|
|
|
|
|
This parameter specifies whether the B will annonce support |
|
718
|
|
|
|
|
|
|
for route refresh ('soft re-configure' as specified by RFC 2918). No support |
|
719
|
|
|
|
|
|
|
for route refresh is implemented - only the B function. This |
|
720
|
|
|
|
|
|
|
has no effect if SupportCapabilities is FALSE. |
|
721
|
|
|
|
|
|
|
|
|
722
|
|
|
|
|
|
|
=head2 SupportCapabilities |
|
723
|
|
|
|
|
|
|
|
|
724
|
|
|
|
|
|
|
This parameter specifies whether the B will attempt to |
|
725
|
|
|
|
|
|
|
negotiate capabilities. You can set this to FALSE if talking to an old BGP |
|
726
|
|
|
|
|
|
|
speaker that doesn't support it (you'll get a notification message for an |
|
727
|
|
|
|
|
|
|
unsupported capability if this is the case). This defaults to TRUE. |
|
728
|
|
|
|
|
|
|
|
|
729
|
|
|
|
|
|
|
=head2 SupportMBGP |
|
730
|
|
|
|
|
|
|
|
|
731
|
|
|
|
|
|
|
This parameter specifies whether the B will attempt to |
|
732
|
|
|
|
|
|
|
negotiate MBGP. Quagga (and probably others) need this if you want to send |
|
733
|
|
|
|
|
|
|
the REFRESH capability. Today this just indicates support for IPv4 Unicast. |
|
734
|
|
|
|
|
|
|
This defaults to TRUE. This has no effect if SupportCapabilities is FALSE. |
|
735
|
|
|
|
|
|
|
|
|
736
|
|
|
|
|
|
|
=head2 SupportAS4 |
|
737
|
|
|
|
|
|
|
|
|
738
|
|
|
|
|
|
|
This paramemter specifies whether outgoing connections from B |
|
739
|
|
|
|
|
|
|
will attempt to negotiate AS4 (32 bit ASNs). For received connections, this |
|
740
|
|
|
|
|
|
|
parameter has no effect - it only determines whether or not AS4 is negotiated |
|
741
|
|
|
|
|
|
|
during outgoing connection. For received connections, this will be changed |
|
742
|
|
|
|
|
|
|
to TRUE (on the listening connection) whenever the appropriate OPEN capability |
|
743
|
|
|
|
|
|
|
is received. Note that the B must be true for this to |
|
744
|
|
|
|
|
|
|
be sent. This defaults to FALSE. |
|
745
|
|
|
|
|
|
|
|
|
746
|
|
|
|
|
|
|
=head2 OpenCallback |
|
747
|
|
|
|
|
|
|
|
|
748
|
|
|
|
|
|
|
This parameter sets the callback function which is invoked when the |
|
749
|
|
|
|
|
|
|
peer receives an OPEN message. It takes a subroutine reference. See |
|
750
|
|
|
|
|
|
|
L<"CALLBACK FUNCTIONS"> later in this manual for further details of |
|
751
|
|
|
|
|
|
|
the conventions of callback invocation. |
|
752
|
|
|
|
|
|
|
|
|
753
|
|
|
|
|
|
|
=head2 KeepaliveCallback |
|
754
|
|
|
|
|
|
|
|
|
755
|
|
|
|
|
|
|
This parameter sets the callback function which is invoked when the |
|
756
|
|
|
|
|
|
|
peer receives a KEEPALIVE message. It takes a subroutine reference. |
|
757
|
|
|
|
|
|
|
See L<"CALLBACK FUNCTIONS"> later in this manual for further details |
|
758
|
|
|
|
|
|
|
of the conventions of callback invocation. |
|
759
|
|
|
|
|
|
|
|
|
760
|
|
|
|
|
|
|
=head2 UpdateCallback |
|
761
|
|
|
|
|
|
|
|
|
762
|
|
|
|
|
|
|
This parameter sets the callback function which is invoked when the |
|
763
|
|
|
|
|
|
|
peer receives an UPDATE message. It takes a subroutine reference. See |
|
764
|
|
|
|
|
|
|
L<"CALLBACK FUNCTIONS"> later in this manual for further details of |
|
765
|
|
|
|
|
|
|
the conventions of callback invocation. |
|
766
|
|
|
|
|
|
|
|
|
767
|
|
|
|
|
|
|
=head2 RefreshCallback |
|
768
|
|
|
|
|
|
|
|
|
769
|
|
|
|
|
|
|
This parameter sets the callback function which is invoked when the |
|
770
|
|
|
|
|
|
|
peer receives a REFRESH message. It takes a subroutine reference. See |
|
771
|
|
|
|
|
|
|
L<"CALLBACK FUNCTIONS"> later in this manual for further details of |
|
772
|
|
|
|
|
|
|
the conventions of callback invocation. |
|
773
|
|
|
|
|
|
|
|
|
774
|
|
|
|
|
|
|
=head2 NotificationCallback |
|
775
|
|
|
|
|
|
|
|
|
776
|
|
|
|
|
|
|
This parameter sets the callback function which is invoked when the |
|
777
|
|
|
|
|
|
|
peer receives a NOTIFICATION message. It takes a subroutine reference. |
|
778
|
|
|
|
|
|
|
See L<"CALLBACK FUNCTIONS"> later in this manual for further details |
|
779
|
|
|
|
|
|
|
of the conventions of callback invocation. |
|
780
|
|
|
|
|
|
|
|
|
781
|
|
|
|
|
|
|
=head2 ErrorCallback |
|
782
|
|
|
|
|
|
|
|
|
783
|
|
|
|
|
|
|
This parameter sets the callback function which is invoked when the |
|
784
|
|
|
|
|
|
|
peer encounters an error and must send a NOTIFICATION message to its |
|
785
|
|
|
|
|
|
|
peer. It takes a subroutine reference. See L<"CALLBACK FUNCTIONS"> |
|
786
|
|
|
|
|
|
|
later in this manual for further details of the conventions of callback |
|
787
|
|
|
|
|
|
|
invocation. |
|
788
|
|
|
|
|
|
|
|
|
789
|
|
|
|
|
|
|
I - fetch the existing Net::BGP::Peer object from the "object string". |
|
790
|
|
|
|
|
|
|
|
|
791
|
|
|
|
|
|
|
This "reconstructor" returns a previeus constructed object from the |
|
792
|
|
|
|
|
|
|
perl genereted string-context scalar of the object, eg. |
|
793
|
|
|
|
|
|
|
I. |
|
794
|
|
|
|
|
|
|
|
|
795
|
|
|
|
|
|
|
=head1 ACCESSOR METHODS |
|
796
|
|
|
|
|
|
|
|
|
797
|
|
|
|
|
|
|
I - start the BGP peering session with the peer |
|
798
|
|
|
|
|
|
|
|
|
799
|
|
|
|
|
|
|
$peer->start(); |
|
800
|
|
|
|
|
|
|
|
|
801
|
|
|
|
|
|
|
This method initiates the BGP peering session with the peer by |
|
802
|
|
|
|
|
|
|
internally emitting the BGP Start event, which causes the peer |
|
803
|
|
|
|
|
|
|
to initiate a transport-layer connection to its peer (unless |
|
804
|
|
|
|
|
|
|
the B parameter was set to a true value in the |
|
805
|
|
|
|
|
|
|
constructor) and listen for a connection from the peer (unless |
|
806
|
|
|
|
|
|
|
the B parameter is set to a false value). |
|
807
|
|
|
|
|
|
|
|
|
808
|
|
|
|
|
|
|
I - cease the BGP peering session with the peer |
|
809
|
|
|
|
|
|
|
|
|
810
|
|
|
|
|
|
|
$peer->stop(); |
|
811
|
|
|
|
|
|
|
|
|
812
|
|
|
|
|
|
|
This method immediately ceases the peering session with the |
|
813
|
|
|
|
|
|
|
peer by sending it a NOTIFICATION message with Error Code |
|
814
|
|
|
|
|
|
|
Cease, closing the transport-layer connection, and entering |
|
815
|
|
|
|
|
|
|
the Idle state. |
|
816
|
|
|
|
|
|
|
|
|
817
|
|
|
|
|
|
|
I - send a BGP UPDATE message to the peer |
|
818
|
|
|
|
|
|
|
|
|
819
|
|
|
|
|
|
|
$peer->update($update); |
|
820
|
|
|
|
|
|
|
|
|
821
|
|
|
|
|
|
|
This method sends the peer an UPDATE message. It takes a reference |
|
822
|
|
|
|
|
|
|
to a Net::BGP::Update object. See the Net::BGP::Update |
|
823
|
|
|
|
|
|
|
manual page for details on setting UPDATE attributes. |
|
824
|
|
|
|
|
|
|
|
|
825
|
|
|
|
|
|
|
I - send a BGP REFRESH message to the peer |
|
826
|
|
|
|
|
|
|
|
|
827
|
|
|
|
|
|
|
$peer->refresh($refresh); |
|
828
|
|
|
|
|
|
|
|
|
829
|
|
|
|
|
|
|
This method sends the peer a REFRESH message. It takes a reference |
|
830
|
|
|
|
|
|
|
to a Net::BGP::Refesh object. If no argument is provided, a default |
|
831
|
|
|
|
|
|
|
Net::BGP::Refresh object is constructed. See the Net::BGP::Refresh |
|
832
|
|
|
|
|
|
|
manual page for details on setting REFRESH attributes. |
|
833
|
|
|
|
|
|
|
|
|
834
|
|
|
|
|
|
|
I |
|
835
|
|
|
|
|
|
|
|
|
836
|
|
|
|
|
|
|
Returns the active transport object to the peer - See Net::BGP::Transport. |
|
837
|
|
|
|
|
|
|
|
|
838
|
|
|
|
|
|
|
I |
|
839
|
|
|
|
|
|
|
|
|
840
|
|
|
|
|
|
|
Return a list of transport objects. The list will contain one or two elements. |
|
841
|
|
|
|
|
|
|
The first will always be the primary transport object. If there are two |
|
842
|
|
|
|
|
|
|
sessions (e.g. collision detection hasn't removed one of them), the sibling |
|
843
|
|
|
|
|
|
|
will be returned as the second element of the list. |
|
844
|
|
|
|
|
|
|
|
|
845
|
|
|
|
|
|
|
I |
|
846
|
|
|
|
|
|
|
|
|
847
|
|
|
|
|
|
|
I |
|
848
|
|
|
|
|
|
|
|
|
849
|
|
|
|
|
|
|
I |
|
850
|
|
|
|
|
|
|
|
|
851
|
|
|
|
|
|
|
I |
|
852
|
|
|
|
|
|
|
|
|
853
|
|
|
|
|
|
|
I |
|
854
|
|
|
|
|
|
|
|
|
855
|
|
|
|
|
|
|
I |
|
856
|
|
|
|
|
|
|
|
|
857
|
|
|
|
|
|
|
I |
|
858
|
|
|
|
|
|
|
|
|
859
|
|
|
|
|
|
|
I |
|
860
|
|
|
|
|
|
|
|
|
861
|
|
|
|
|
|
|
I |
|
862
|
|
|
|
|
|
|
|
|
863
|
|
|
|
|
|
|
I |
|
864
|
|
|
|
|
|
|
|
|
865
|
|
|
|
|
|
|
These are accessor methods for the corresponding constructor named parameters. |
|
866
|
|
|
|
|
|
|
They retrieve the values set when the object was created, but the values cannot |
|
867
|
|
|
|
|
|
|
be changed after object construction. Hence, they take no arguments. |
|
868
|
|
|
|
|
|
|
|
|
869
|
|
|
|
|
|
|
I |
|
870
|
|
|
|
|
|
|
|
|
871
|
|
|
|
|
|
|
This accessor method returns true if the peer has a established transport |
|
872
|
|
|
|
|
|
|
connection - e.g. the peering is up. |
|
873
|
|
|
|
|
|
|
|
|
874
|
|
|
|
|
|
|
I |
|
875
|
|
|
|
|
|
|
|
|
876
|
|
|
|
|
|
|
This accessor method returns a true value if connected to a peer that supports |
|
877
|
|
|
|
|
|
|
refresh messages - otherwise a false value. |
|
878
|
|
|
|
|
|
|
|
|
879
|
|
|
|
|
|
|
I |
|
880
|
|
|
|
|
|
|
|
|
881
|
|
|
|
|
|
|
This accessor method returns a print friendly string with the local and remote |
|
882
|
|
|
|
|
|
|
IP and AS numbers. |
|
883
|
|
|
|
|
|
|
|
|
884
|
|
|
|
|
|
|
I |
|
885
|
|
|
|
|
|
|
|
|
886
|
|
|
|
|
|
|
I |
|
887
|
|
|
|
|
|
|
|
|
888
|
|
|
|
|
|
|
I |
|
889
|
|
|
|
|
|
|
|
|
890
|
|
|
|
|
|
|
I |
|
891
|
|
|
|
|
|
|
|
|
892
|
|
|
|
|
|
|
I |
|
893
|
|
|
|
|
|
|
|
|
894
|
|
|
|
|
|
|
I |
|
895
|
|
|
|
|
|
|
|
|
896
|
|
|
|
|
|
|
I |
|
897
|
|
|
|
|
|
|
|
|
898
|
|
|
|
|
|
|
I |
|
899
|
|
|
|
|
|
|
|
|
900
|
|
|
|
|
|
|
These methods set the callback functions which are invoked whenever the |
|
901
|
|
|
|
|
|
|
peer receives the corresponding BGP message type from its peer, or, in the |
|
902
|
|
|
|
|
|
|
case of I, transitions to the relevant state. They |
|
903
|
|
|
|
|
|
|
can be set in the constructor as well as with these methods. These methods |
|
904
|
|
|
|
|
|
|
each take one argument, which is the subroutine reference to be invoked. |
|
905
|
|
|
|
|
|
|
A callback function can be removed by calling the corresponding one of these |
|
906
|
|
|
|
|
|
|
methods and passing it the perl I value. For callback definition and |
|
907
|
|
|
|
|
|
|
invocation conventions see L<"CALLBACK FUNCTIONS"> later in this manual. |
|
908
|
|
|
|
|
|
|
|
|
909
|
|
|
|
|
|
|
I - add a program defined timer callback function |
|
910
|
|
|
|
|
|
|
|
|
911
|
|
|
|
|
|
|
$peer->add_timer(\&my_minute_timer, 60); |
|
912
|
|
|
|
|
|
|
|
|
913
|
|
|
|
|
|
|
This method sets a program defined timer which invokes the specified callback |
|
914
|
|
|
|
|
|
|
function when the timer expires. It takes two arguments: the first is a code |
|
915
|
|
|
|
|
|
|
reference to the subroutine to be invoked when the timer expires, and the |
|
916
|
|
|
|
|
|
|
second is the timer interval, in seconds. The program may set as many timers |
|
917
|
|
|
|
|
|
|
as needed, and multiple timer callbacks may share the same interval. Program |
|
918
|
|
|
|
|
|
|
timers add an asynchronous means for user code to gain control of the program |
|
919
|
|
|
|
|
|
|
control flow - without them user code would only be invoked whenever BGP |
|
920
|
|
|
|
|
|
|
events exposed by the module occur. They may be used to perform any necessary |
|
921
|
|
|
|
|
|
|
action - for example, sending UPDATEs, starting or stopping the peering |
|
922
|
|
|
|
|
|
|
session, house-keeping, etc. |
|
923
|
|
|
|
|
|
|
|
|
924
|
|
|
|
|
|
|
I - remove a program defined timer callback function |
|
925
|
|
|
|
|
|
|
|
|
926
|
|
|
|
|
|
|
$peer->remove_timer(\&my_minute_timer); |
|
927
|
|
|
|
|
|
|
|
|
928
|
|
|
|
|
|
|
This method removes a program defined timer callback which has been previously |
|
929
|
|
|
|
|
|
|
set with the I method. It takes a single argument: a reference |
|
930
|
|
|
|
|
|
|
to the subroutine previously added. |
|
931
|
|
|
|
|
|
|
|
|
932
|
|
|
|
|
|
|
=head1 CALLBACK FUNCTIONS |
|
933
|
|
|
|
|
|
|
|
|
934
|
|
|
|
|
|
|
Whenever a B object receives one of the BGP protocol messages - |
|
935
|
|
|
|
|
|
|
OPEN, KEEPALIVE, UPDATE, REFRESH, or NOTIFICATION - from its peer, or whenever it |
|
936
|
|
|
|
|
|
|
encounters an error condition and must send a NOTIFICATION message to its peer, |
|
937
|
|
|
|
|
|
|
the peer object will invoke a program defined callback function corresponding |
|
938
|
|
|
|
|
|
|
to the event type, if one has been provided, to inform the application about |
|
939
|
|
|
|
|
|
|
the event. These callback functions are installed as described in the preceding |
|
940
|
|
|
|
|
|
|
section of the manual. Whenever any callback function is invoked, it is passed |
|
941
|
|
|
|
|
|
|
one or more arguments, depending on the BGP message type associated with the |
|
942
|
|
|
|
|
|
|
callback. The first argument passed to all of the callbacks is a reference |
|
943
|
|
|
|
|
|
|
to the B object which the application may use to identify |
|
944
|
|
|
|
|
|
|
which peer has signalled the event and to take appropriate action. For OPEN |
|
945
|
|
|
|
|
|
|
and KEEPALIVE callbacks, this is the only argument passed. It is very unlikely |
|
946
|
|
|
|
|
|
|
that applications will be interested in OPEN and KEEPALIVE events, since the |
|
947
|
|
|
|
|
|
|
B module handles all details of OPEN and KEEPALIVE message processing |
|
948
|
|
|
|
|
|
|
in order to establish and maintain BGP sessions. Callback handling for these |
|
949
|
|
|
|
|
|
|
messages is mainly included for the sake of completeness. For UPDATE and |
|
950
|
|
|
|
|
|
|
NOTIFICATION messages, however, most applications will install callback handlers. |
|
951
|
|
|
|
|
|
|
Whenever an UPDATE, REFRESH, NOTIFICATION, or error handler is called, the object |
|
952
|
|
|
|
|
|
|
will pass a second argument. In the first two cases, this is a B |
|
953
|
|
|
|
|
|
|
or B object respectivly encapsulating the information contained |
|
954
|
|
|
|
|
|
|
in the UPDATE or REFRESH message, while in the latter two cases it is a |
|
955
|
|
|
|
|
|
|
B object encapsulating the information in the |
|
956
|
|
|
|
|
|
|
NOTIFICATION message sent or received. |
|
957
|
|
|
|
|
|
|
|
|
958
|
|
|
|
|
|
|
The RESET and ESTABLISHED callbacks are special, since they are used whenever an |
|
959
|
|
|
|
|
|
|
established BGP session is reset, even though no message has been recieved or sent. |
|
960
|
|
|
|
|
|
|
The REFRESH callback is also special, since it is also called without a REFRESH |
|
961
|
|
|
|
|
|
|
object whenever a BGP session is established. The two callbacks can be used to |
|
962
|
|
|
|
|
|
|
clear and retransmit a RIB from/to the peer in question. |
|
963
|
|
|
|
|
|
|
|
|
964
|
|
|
|
|
|
|
Whenever a callback function is to be invoked, the action occuring internally is |
|
965
|
|
|
|
|
|
|
the invocation of one of the following methods, corresponding to the event which |
|
966
|
|
|
|
|
|
|
has occured: |
|
967
|
|
|
|
|
|
|
|
|
968
|
|
|
|
|
|
|
I |
|
969
|
|
|
|
|
|
|
|
|
970
|
|
|
|
|
|
|
I |
|
971
|
|
|
|
|
|
|
|
|
972
|
|
|
|
|
|
|
I |
|
973
|
|
|
|
|
|
|
|
|
974
|
|
|
|
|
|
|
I |
|
975
|
|
|
|
|
|
|
|
|
976
|
|
|
|
|
|
|
I |
|
977
|
|
|
|
|
|
|
|
|
978
|
|
|
|
|
|
|
I |
|
979
|
|
|
|
|
|
|
|
|
980
|
|
|
|
|
|
|
I |
|
981
|
|
|
|
|
|
|
|
|
982
|
|
|
|
|
|
|
I |
|
983
|
|
|
|
|
|
|
|
|
984
|
|
|
|
|
|
|
Internally, each of these methods just checks to see whether a program defined |
|
985
|
|
|
|
|
|
|
callback function has been set and calls it if so, passing it arguments as |
|
986
|
|
|
|
|
|
|
described above. As an alternative to providing subroutine references to the |
|
987
|
|
|
|
|
|
|
constructor or through the I, I, |
|
988
|
|
|
|
|
|
|
I, I, I, |
|
989
|
|
|
|
|
|
|
I, I, and I |
|
990
|
|
|
|
|
|
|
methods, an application may effect a similar result by sub-classing the |
|
991
|
|
|
|
|
|
|
B module and overridding the defintions of the above methods |
|
992
|
|
|
|
|
|
|
to perform whatever actions would have been executed by ordinary callback functions. |
|
993
|
|
|
|
|
|
|
The overridden methods are passed the same arguments as the callback functions. |
|
994
|
|
|
|
|
|
|
This method might offer an advantage in organizing code according to different |
|
995
|
|
|
|
|
|
|
derived classes which apply specifc routing policies. |
|
996
|
|
|
|
|
|
|
|
|
997
|
|
|
|
|
|
|
=head1 ERROR HANDLING |
|
998
|
|
|
|
|
|
|
|
|
999
|
|
|
|
|
|
|
There are two possibilities for error handling callbacks to be invoked. The first |
|
1000
|
|
|
|
|
|
|
case occurs when the peer receives a NOTIFICATION messages from its peer. The |
|
1001
|
|
|
|
|
|
|
second case occurs when the peer detects an error condition while processing an |
|
1002
|
|
|
|
|
|
|
incoming BGP message or when some other protocol covenant is violated - for |
|
1003
|
|
|
|
|
|
|
example if a KEEPALIVE or UPDATE message is not received before the peer's |
|
1004
|
|
|
|
|
|
|
Keepalive timer expires. In this case, the peer responds by sending a NOTIFICATION |
|
1005
|
|
|
|
|
|
|
message to its peer. In the former case the I method |
|
1006
|
|
|
|
|
|
|
is invoked as described above to handle the error, while in the latter the |
|
1007
|
|
|
|
|
|
|
I method is invoked to inform the application that it has |
|
1008
|
|
|
|
|
|
|
encountered an error. Both methods are passed a B |
|
1009
|
|
|
|
|
|
|
object encapsulating the details of the error. In both cases, the transport-layer |
|
1010
|
|
|
|
|
|
|
connection and BGP session are closed and the peer transitions to the Idle state. |
|
1011
|
|
|
|
|
|
|
The error handler callbacks can examine the cause of the error and take appropriate |
|
1012
|
|
|
|
|
|
|
action. This could be to attempt to re-establish the session (perhaps after |
|
1013
|
|
|
|
|
|
|
sleeping for some amount of time), or to unregister the peer object from the |
|
1014
|
|
|
|
|
|
|
B object and permanently end the session (for the duration |
|
1015
|
|
|
|
|
|
|
of the application's running time), or to log the event to a file on the host |
|
1016
|
|
|
|
|
|
|
system, or some combination of these or none. |
|
1017
|
|
|
|
|
|
|
|
|
1018
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
1019
|
|
|
|
|
|
|
|
|
1020
|
|
|
|
|
|
|
Net::BGP, Net::BGP::Process, Net::BGP::Update, Net::BGP::Transport, |
|
1021
|
|
|
|
|
|
|
Net::BGP::Refresh, Net::BGP::Notification |
|
1022
|
|
|
|
|
|
|
|
|
1023
|
|
|
|
|
|
|
=head1 AUTHOR |
|
1024
|
|
|
|
|
|
|
|
|
1025
|
|
|
|
|
|
|
Stephen J. Scheck |
|
1026
|
|
|
|
|
|
|
|
|
1027
|
|
|
|
|
|
|
=cut |
|
1028
|
|
|
|
|
|
|
|
|
1029
|
|
|
|
|
|
|
## End Package Net::BGP::Peer ## |
|
1030
|
|
|
|
|
|
|
|
|
1031
|
|
|
|
|
|
|
1; |