line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!/usr/bin/perl |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Net::BGP::Refresh; |
4
|
5
|
|
|
5
|
|
4719
|
use bytes; |
|
5
|
|
|
|
|
26
|
|
|
5
|
|
|
|
|
28
|
|
5
|
|
|
|
|
|
|
|
6
|
5
|
|
|
5
|
|
177
|
use strict; |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
147
|
|
7
|
5
|
|
|
5
|
|
21
|
use vars qw( $VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS @AFI @SAFI ); |
|
5
|
|
|
|
|
18
|
|
|
5
|
|
|
|
|
501
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
## Inheritance and Versioning ## |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
@ISA = qw( Exporter ); |
12
|
|
|
|
|
|
|
$VERSION = '0.18'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
## Module Imports ## |
15
|
|
|
|
|
|
|
|
16
|
5
|
|
|
5
|
|
32
|
use Exporter; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
246
|
|
17
|
5
|
|
|
5
|
|
474
|
use Net::BGP::Notification qw( :errors ); |
|
5
|
|
|
|
|
11
|
|
|
5
|
|
|
|
|
3905
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
## BGP Protocol Error Code and Subcode Enumerations ## |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
# http://www.iana.org/assignments/address-family-numbers |
23
|
6
|
|
|
6
|
0
|
20
|
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
|
20
|
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
|
644
|
my $class = shift(); |
57
|
6
|
|
|
|
|
14
|
my ($arg, $value); |
58
|
|
|
|
|
|
|
|
59
|
6
|
|
|
|
|
19
|
my $this = { |
60
|
|
|
|
|
|
|
_afi => AFI_IP4, |
61
|
|
|
|
|
|
|
_safi => SAFI_BOTH |
62
|
|
|
|
|
|
|
}; |
63
|
|
|
|
|
|
|
|
64
|
6
|
|
|
|
|
23
|
bless($this, $class); |
65
|
|
|
|
|
|
|
|
66
|
6
|
|
|
|
|
25
|
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
|
|
|
|
|
16
|
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
|
|
14
|
my ($class, $buffer) = @_; |
100
|
|
|
|
|
|
|
|
101
|
3
|
|
|
|
|
14
|
my $this = $class->new; |
102
|
|
|
|
|
|
|
|
103
|
3
|
|
|
|
|
12
|
$this->_decode_message($buffer); |
104
|
|
|
|
|
|
|
|
105
|
3
|
|
|
|
|
10
|
return $this; |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
sub _decode_message |
109
|
|
|
|
|
|
|
{ |
110
|
3
|
|
|
3
|
|
10
|
my ($this, $buffer) = @_; |
111
|
|
|
|
|
|
|
|
112
|
3
|
50
|
|
|
|
135
|
if ( length($buffer) != 4 ) { |
113
|
0
|
|
|
|
|
0
|
Net::BGP::Notification->throw( |
114
|
|
|
|
|
|
|
ErrorCode => BGP_ERROR_CODE_FINITE_STATE_MACHINE |
115
|
|
|
|
|
|
|
); |
116
|
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
|
118
|
3
|
|
|
|
|
32
|
($this->{_afi},undef,$this->{_safi}) = unpack('ncc', $buffer); |
119
|
|
|
|
|
|
|
|
120
|
3
|
|
|
|
|
13
|
return undef; |
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
sub _encode_message |
124
|
|
|
|
|
|
|
{ |
125
|
4
|
|
|
4
|
|
299
|
my $this = shift(); |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
# encode the message |
128
|
4
|
|
|
|
|
51
|
my $buffer = pack('ncc', $this->{_afi}, 0, $this->{_safi}); |
129
|
|
|
|
|
|
|
|
130
|
4
|
|
|
|
|
19
|
return ( $buffer ); |
131
|
|
|
|
|
|
|
} |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
## POD ## |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=pod |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=head1 NAME |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
C - 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 = $refresh->afi(); |
151
|
|
|
|
|
|
|
$subsequent_address_family_identifier = $refresh->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
|
|
|
|
|
|
|
specified by RFC 2918. It provides a constructor, and accessor methods for |
159
|
|
|
|
|
|
|
each of the fields, AFI and SAFI, of a REFRESH message. To refresh the route |
160
|
|
|
|
|
|
|
table for a given address family, call the peer object's I function |
161
|
|
|
|
|
|
|
with a C object as argument. |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=head1 METHODS |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
I - create a new C object |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
$refresh = Net::BGP::Refresh->new( |
168
|
|
|
|
|
|
|
AFI => $address_family_identifier, |
169
|
|
|
|
|
|
|
SAFI => $subsequent_address_family_identifier |
170
|
|
|
|
|
|
|
); |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
This is the constructor for C objects. It returns a |
173
|
|
|
|
|
|
|
reference to the newly created object. The following named parameters may |
174
|
|
|
|
|
|
|
be passed to the constructor. |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=head2 AFI |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
This parameter corresponds to the Address Family Identifier field of a REFRESH |
179
|
|
|
|
|
|
|
message. Default is I. |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
=head2 SAFI |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
This parameter corresponds to the Subsequent Address Family Identifier field of |
184
|
|
|
|
|
|
|
a REFRESH message. Default is I. |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
I - retrieve the value of the Address Family Identifier field |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
$address_family_identifier = $refresh->afi(); |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
I - retrieve the value of the Subsequent Address Family Identifier field |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
$subsequent_address_family_identifier = $refresh->safi(); |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
=head1 SEE ALSO |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
=over |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
=item L |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
=item L |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
=item L |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
=item L |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
=item L |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
=item L |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
=item L |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
=back |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
=head1 AUTHOR |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
Stephen J. Scheck |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
=cut |
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
## End Package Net::BGP::Notification ## |
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
1; |