| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
#!/usr/bin/perl |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Net::BGP::Refresh; |
|
4
|
5
|
|
|
5
|
|
4439
|
use bytes; |
|
|
5
|
|
|
|
|
25
|
|
|
|
5
|
|
|
|
|
26
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
5
|
|
|
5
|
|
164
|
use strict; |
|
|
5
|
|
|
|
|
9
|
|
|
|
5
|
|
|
|
|
131
|
|
|
7
|
5
|
|
|
5
|
|
25
|
use vars qw( $VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS @AFI @SAFI ); |
|
|
5
|
|
|
|
|
7
|
|
|
|
5
|
|
|
|
|
452
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
## Inheritance and Versioning ## |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
@ISA = qw( Exporter ); |
|
12
|
|
|
|
|
|
|
$VERSION = '0.17'; |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
## Module Imports ## |
|
15
|
|
|
|
|
|
|
|
|
16
|
5
|
|
|
5
|
|
32
|
use Exporter; |
|
|
5
|
|
|
|
|
7
|
|
|
|
5
|
|
|
|
|
219
|
|
|
17
|
5
|
|
|
5
|
|
449
|
use Net::BGP::Notification qw( :errors ); |
|
|
5
|
|
|
|
|
10
|
|
|
|
5
|
|
|
|
|
3828
|
|
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
## BGP Protocol Error Code and Subcode Enumerations ## |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
# http://www.iana.org/assignments/address-family-numbers |
|
23
|
6
|
|
|
6
|
0
|
17
|
sub AFI_IP4 { 1 } |
|
24
|
0
|
|
|
0
|
0
|
0
|
sub AFI_IP6 { 2 } |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
# http://www.iana.org/assignments/safi-namespace |
|
27
|
0
|
|
|
0
|
0
|
0
|
sub SAFI_UNI { 1 } |
|
28
|
0
|
|
|
0
|
0
|
0
|
sub SAFI_MULTI { 2 } |
|
29
|
6
|
|
|
6
|
0
|
18
|
sub SAFI_BOTH { 3 } |
|
30
|
0
|
|
|
0
|
0
|
0
|
sub SAFI_MPLS { 4 } |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
@AFI = qw( |
|
33
|
|
|
|
|
|
|
AFI_IP4 |
|
34
|
|
|
|
|
|
|
AFI_IP6 |
|
35
|
|
|
|
|
|
|
); |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
@SAFI = qw( |
|
38
|
|
|
|
|
|
|
SAFI_UNI |
|
39
|
|
|
|
|
|
|
SAFI_MULTI |
|
40
|
|
|
|
|
|
|
SAFI_BOTH |
|
41
|
|
|
|
|
|
|
SAFI_MPLS |
|
42
|
|
|
|
|
|
|
); |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
@EXPORT = (); |
|
45
|
|
|
|
|
|
|
@EXPORT_OK = ( @AFI, @SAFI ); |
|
46
|
|
|
|
|
|
|
%EXPORT_TAGS = ( |
|
47
|
|
|
|
|
|
|
afi => [ @AFI ], |
|
48
|
|
|
|
|
|
|
safi => [ @SAFI ], |
|
49
|
|
|
|
|
|
|
ALL => [ @EXPORT, @EXPORT_OK ] |
|
50
|
|
|
|
|
|
|
); |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
## Public Methods ## |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub new |
|
55
|
|
|
|
|
|
|
{ |
|
56
|
6
|
|
|
6
|
0
|
558
|
my $class = shift(); |
|
57
|
6
|
|
|
|
|
12
|
my ($arg, $value); |
|
58
|
|
|
|
|
|
|
|
|
59
|
6
|
|
|
|
|
20
|
my $this = { |
|
60
|
|
|
|
|
|
|
_afi => AFI_IP4, |
|
61
|
|
|
|
|
|
|
_safi => SAFI_BOTH |
|
62
|
|
|
|
|
|
|
}; |
|
63
|
|
|
|
|
|
|
|
|
64
|
6
|
|
|
|
|
15
|
bless($this, $class); |
|
65
|
|
|
|
|
|
|
|
|
66
|
6
|
|
|
|
|
24
|
while ( defined($arg = shift()) ) { |
|
67
|
0
|
|
|
|
|
0
|
$value = shift(); |
|
68
|
|
|
|
|
|
|
|
|
69
|
0
|
0
|
|
|
|
0
|
if ( $arg =~ /safi/i ) { |
|
|
|
0
|
|
|
|
|
|
|
70
|
0
|
|
|
|
|
0
|
$this->{_safi} = $value; |
|
71
|
|
|
|
|
|
|
} |
|
72
|
|
|
|
|
|
|
elsif ( $arg =~ /afi/i ) { |
|
73
|
0
|
|
|
|
|
0
|
$this->{_afi} = $value; |
|
74
|
|
|
|
|
|
|
} |
|
75
|
|
|
|
|
|
|
else { |
|
76
|
0
|
|
|
|
|
0
|
die("unrecognized argument $arg\n"); |
|
77
|
|
|
|
|
|
|
} |
|
78
|
|
|
|
|
|
|
} |
|
79
|
|
|
|
|
|
|
|
|
80
|
6
|
|
|
|
|
15
|
return ( $this ); |
|
81
|
|
|
|
|
|
|
} |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub afi |
|
84
|
|
|
|
|
|
|
{ |
|
85
|
0
|
|
|
0
|
0
|
0
|
my $this = shift(); |
|
86
|
0
|
|
|
|
|
0
|
return ( $this->{_afi} ); |
|
87
|
|
|
|
|
|
|
} |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
sub safi |
|
90
|
|
|
|
|
|
|
{ |
|
91
|
0
|
|
|
0
|
0
|
0
|
my $this = shift(); |
|
92
|
0
|
|
|
|
|
0
|
return ( $this->{_safi} ); |
|
93
|
|
|
|
|
|
|
} |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
## Private Methods ## |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
sub _new_from_msg |
|
98
|
|
|
|
|
|
|
{ |
|
99
|
3
|
|
|
3
|
|
15
|
my ($class, $buffer) = @_; |
|
100
|
|
|
|
|
|
|
|
|
101
|
3
|
|
|
|
|
12
|
my $this = $class->new; |
|
102
|
|
|
|
|
|
|
|
|
103
|
3
|
|
|
|
|
31
|
$this->_decode_message($buffer); |
|
104
|
|
|
|
|
|
|
|
|
105
|
3
|
|
|
|
|
9
|
return $this; |
|
106
|
|
|
|
|
|
|
} |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
sub _decode_message |
|
109
|
|
|
|
|
|
|
{ |
|
110
|
3
|
|
|
3
|
|
12
|
my ($this, $buffer) = @_; |
|
111
|
|
|
|
|
|
|
|
|
112
|
3
|
50
|
|
|
|
29
|
if ( length($buffer) != 4 ) { |
|
113
|
0
|
|
|
|
|
0
|
Net::BGP::Notification->throw( |
|
114
|
|
|
|
|
|
|
ErrorCode => BGP_ERROR_CODE_FINITE_STATE_MACHINE |
|
115
|
|
|
|
|
|
|
); |
|
116
|
|
|
|
|
|
|
} |
|
117
|
|
|
|
|
|
|
|
|
118
|
3
|
|
|
|
|
37
|
($this->{_afi},undef,$this->{_safi}) = unpack('ncc', $buffer); |
|
119
|
|
|
|
|
|
|
|
|
120
|
3
|
|
|
|
|
11
|
return undef; |
|
121
|
|
|
|
|
|
|
} |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
sub _encode_message |
|
124
|
|
|
|
|
|
|
{ |
|
125
|
4
|
|
|
4
|
|
288
|
my $this = shift(); |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
# encode the message |
|
128
|
4
|
|
|
|
|
55
|
my $buffer = pack('ncc', $this->{_afi}, 0, $this->{_safi}); |
|
129
|
|
|
|
|
|
|
|
|
130
|
4
|
|
|
|
|
28
|
return ( $buffer ); |
|
131
|
|
|
|
|
|
|
} |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
## POD ## |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=pod |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=head1 NAME |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
Net::BGP::Refresh - Class encapsulating BGP-4 REFRESH message |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
use Net::BGP::Refresh; |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
$refresh = Net::BGP::Refresh->new( |
|
146
|
|
|
|
|
|
|
AFI => $address_family_identifier, |
|
147
|
|
|
|
|
|
|
SAFI => $subsequent_address_family_identifier |
|
148
|
|
|
|
|
|
|
); |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
$address_family_identifier = $error->afi(); |
|
151
|
|
|
|
|
|
|
$subsequent_address_family_identifier = $error->safi(); |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
$peer->refresh($refresh); |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
156
|
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
This module encapsulates the data contained in a BGP-4 REFRESH message as |
|
158
|
|
|
|
|
|
|
specifed by RFC2918. |
|
159
|
|
|
|
|
|
|
It provides a constructor, and accessor methods for each of the fields, AFI |
|
160
|
|
|
|
|
|
|
and SAFI, of a REFRESH message. |
|
161
|
|
|
|
|
|
|
To refresh the route table for a given address family, call the peer object's |
|
162
|
|
|
|
|
|
|
I function with a B object as argument. |
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=head1 METHODS |
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
I - create a new Net::BGP::Refresh object |
|
167
|
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
$error = Net::BGP::Refresh->new( |
|
169
|
|
|
|
|
|
|
AFI => $address_family_identifier, |
|
170
|
|
|
|
|
|
|
SAFI => $subsequent_address_family_identifier |
|
171
|
|
|
|
|
|
|
); |
|
172
|
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
This is the constructor for Net::BGP::Refresh objects. It returns a |
|
174
|
|
|
|
|
|
|
reference to the newly created object. The following named parameters may |
|
175
|
|
|
|
|
|
|
be passed to the constructor. |
|
176
|
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=head2 AFI |
|
178
|
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
This parameter corresponds to the Address Family Identifier field of a REFRESH |
|
180
|
|
|
|
|
|
|
message. Default is I. |
|
181
|
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
=head2 SAFI |
|
183
|
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
This parameter corresponds to the Subsequent Address Family Identifier field of |
|
185
|
|
|
|
|
|
|
a REFRESH message. Default is I. |
|
186
|
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
I - retrieve the value of the Address Family Identifier field |
|
188
|
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
$address_family_identifier = $error->afi(); |
|
190
|
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
I - retrieve the value of the Subsequent Address Family Identifier field |
|
192
|
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
$subsequent_address_family_identifier = $error->safi(); |
|
194
|
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
196
|
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
B, B, B, |
|
198
|
|
|
|
|
|
|
B, B |
|
199
|
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
=head1 AUTHOR |
|
201
|
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
Stephen J. Scheck |
|
203
|
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
=cut |
|
205
|
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
## End Package Net::BGP::Notification ## |
|
207
|
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
1; |