line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!/usr/bin/perl |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Net::BGP::Notification; |
4
|
|
|
|
|
|
|
|
5
|
8
|
|
|
8
|
|
53
|
use strict; |
|
8
|
|
|
|
|
16
|
|
|
8
|
|
|
|
|
295
|
|
6
|
8
|
|
|
8
|
|
40
|
use vars qw( $VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS @ERRORS ); |
|
8
|
|
|
|
|
11
|
|
|
8
|
|
|
|
|
741
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
## Inheritance and Versioning ## |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
@ISA = qw( Exporter ); |
11
|
|
|
|
|
|
|
$VERSION = '0.17'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
## Module Imports ## |
14
|
|
|
|
|
|
|
|
15
|
8
|
|
|
8
|
|
49
|
use Exporter; |
|
8
|
|
|
|
|
15
|
|
|
8
|
|
|
|
|
295
|
|
16
|
8
|
|
|
8
|
|
44
|
use Carp; |
|
8
|
|
|
|
|
13
|
|
|
8
|
|
|
|
|
6187
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
## BGP Protocol Error Code and Subcode Enumerations ## |
19
|
|
|
|
|
|
|
|
20
|
0
|
|
|
0
|
0
|
0
|
sub BGP_ERROR_CODE_MESSAGE_HEADER { 1 } |
21
|
0
|
|
|
0
|
0
|
0
|
sub BGP_ERROR_CODE_OPEN_MESSAGE { 2 } |
22
|
1
|
|
|
1
|
0
|
4
|
sub BGP_ERROR_CODE_UPDATE_MESSAGE { 3 } |
23
|
0
|
|
|
0
|
0
|
0
|
sub BGP_ERROR_CODE_HOLD_TIMER_EXPIRED { 4 } |
24
|
0
|
|
|
0
|
0
|
0
|
sub BGP_ERROR_CODE_FINITE_STATE_MACHINE { 5 } |
25
|
6
|
|
|
6
|
0
|
41
|
sub BGP_ERROR_CODE_CEASE { 6 } |
26
|
|
|
|
|
|
|
|
27
|
6
|
|
|
6
|
0
|
12
|
sub BGP_ERROR_SUBCODE_NULL { 0 } |
28
|
|
|
|
|
|
|
|
29
|
0
|
|
|
0
|
0
|
0
|
sub BGP_ERROR_SUBCODE_CONN_NOT_SYNC { 1 } |
30
|
0
|
|
|
0
|
0
|
0
|
sub BGP_ERROR_SUBCODE_BAD_MSG_LENGTH { 2 } |
31
|
0
|
|
|
0
|
0
|
0
|
sub BGP_ERROR_SUBCODE_BAD_MSG_TYPE { 3 } |
32
|
|
|
|
|
|
|
|
33
|
0
|
|
|
0
|
0
|
0
|
sub BGP_ERROR_SUBCODE_BAD_VERSION_NUM { 1 } |
34
|
0
|
|
|
0
|
0
|
0
|
sub BGP_ERROR_SUBCODE_BAD_PEER_AS { 2 } |
35
|
0
|
|
|
0
|
0
|
0
|
sub BGP_ERROR_SUBCODE_BAD_BGP_ID { 3 } |
36
|
0
|
|
|
0
|
0
|
0
|
sub BGP_ERROR_SUBCODE_BAD_OPT_PARAMETER { 4 } |
37
|
0
|
|
|
0
|
0
|
0
|
sub BGP_ERROR_SUBCODE_AUTH_FAILURE { 5 } |
38
|
0
|
|
|
0
|
0
|
0
|
sub BGP_ERROR_SUBCODE_BAD_HOLD_TIME { 6 } |
39
|
|
|
|
|
|
|
|
40
|
0
|
|
|
0
|
0
|
0
|
sub BGP_ERROR_SUBCODE_MALFORMED_ATTR_LIST { 1 } |
41
|
0
|
|
|
0
|
0
|
0
|
sub BGP_ERROR_SUBCODE_BAD_WELL_KNOWN_ATTR { 2 } |
42
|
0
|
|
|
0
|
0
|
0
|
sub BGP_ERROR_SUBCODE_MISSING_WELL_KNOWN_ATTR { 3 } |
43
|
1
|
|
|
1
|
0
|
17
|
sub BGP_ERROR_SUBCODE_BAD_ATTR_FLAGS { 4 } |
44
|
0
|
|
|
0
|
0
|
0
|
sub BGP_ERROR_SUBCODE_BAD_ATTR_LENGTH { 5 } |
45
|
0
|
|
|
0
|
0
|
0
|
sub BGP_ERROR_SUBCODE_BAD_ORIGIN_ATTR { 6 } |
46
|
0
|
|
|
0
|
0
|
0
|
sub BGP_ERROR_SUBCODE_AS_ROUTING_LOOP { 7 } |
47
|
0
|
|
|
0
|
0
|
0
|
sub BGP_ERROR_SUBCODE_BAD_NEXT_HOP_ATTR { 8 } |
48
|
0
|
|
|
0
|
0
|
0
|
sub BGP_ERROR_SUBCODE_BAD_OPT_ATTR { 9 } |
49
|
0
|
|
|
0
|
0
|
0
|
sub BGP_ERROR_SUBCODE_BAD_NLRI { 10 } |
50
|
0
|
|
|
0
|
0
|
0
|
sub BGP_ERROR_SUBCODE_BAD_AS_PATH { 11 } |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
## Export Tag Definitions ## |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
@ERRORS = qw( |
55
|
|
|
|
|
|
|
BGP_ERROR_CODE_MESSAGE_HEADER |
56
|
|
|
|
|
|
|
BGP_ERROR_CODE_OPEN_MESSAGE |
57
|
|
|
|
|
|
|
BGP_ERROR_CODE_UPDATE_MESSAGE |
58
|
|
|
|
|
|
|
BGP_ERROR_CODE_HOLD_TIMER_EXPIRED |
59
|
|
|
|
|
|
|
BGP_ERROR_CODE_FINITE_STATE_MACHINE |
60
|
|
|
|
|
|
|
BGP_ERROR_CODE_CEASE |
61
|
|
|
|
|
|
|
BGP_ERROR_SUBCODE_NULL |
62
|
|
|
|
|
|
|
BGP_ERROR_SUBCODE_CONN_NOT_SYNC |
63
|
|
|
|
|
|
|
BGP_ERROR_SUBCODE_BAD_MSG_LENGTH |
64
|
|
|
|
|
|
|
BGP_ERROR_SUBCODE_BAD_MSG_TYPE |
65
|
|
|
|
|
|
|
BGP_ERROR_SUBCODE_BAD_VERSION_NUM |
66
|
|
|
|
|
|
|
BGP_ERROR_SUBCODE_BAD_PEER_AS |
67
|
|
|
|
|
|
|
BGP_ERROR_SUBCODE_BAD_BGP_ID |
68
|
|
|
|
|
|
|
BGP_ERROR_SUBCODE_BAD_OPT_PARAMETER |
69
|
|
|
|
|
|
|
BGP_ERROR_SUBCODE_AUTH_FAILURE |
70
|
|
|
|
|
|
|
BGP_ERROR_SUBCODE_BAD_HOLD_TIME |
71
|
|
|
|
|
|
|
BGP_ERROR_SUBCODE_MALFORMED_ATTR_LIST |
72
|
|
|
|
|
|
|
BGP_ERROR_SUBCODE_BAD_WELL_KNOWN_ATTR |
73
|
|
|
|
|
|
|
BGP_ERROR_SUBCODE_MISSING_WELL_KNOWN_ATTR |
74
|
|
|
|
|
|
|
BGP_ERROR_SUBCODE_BAD_ATTR_FLAGS |
75
|
|
|
|
|
|
|
BGP_ERROR_SUBCODE_BAD_ATTR_LENGTH |
76
|
|
|
|
|
|
|
BGP_ERROR_SUBCODE_BAD_ORIGIN_ATTR |
77
|
|
|
|
|
|
|
BGP_ERROR_SUBCODE_AS_ROUTING_LOOP |
78
|
|
|
|
|
|
|
BGP_ERROR_SUBCODE_BAD_NEXT_HOP_ATTR |
79
|
|
|
|
|
|
|
BGP_ERROR_SUBCODE_BAD_OPT_ATTR |
80
|
|
|
|
|
|
|
BGP_ERROR_SUBCODE_BAD_NLRI |
81
|
|
|
|
|
|
|
BGP_ERROR_SUBCODE_BAD_AS_PATH |
82
|
|
|
|
|
|
|
); |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
@EXPORT = (); |
85
|
|
|
|
|
|
|
@EXPORT_OK = ( @ERRORS ); |
86
|
|
|
|
|
|
|
%EXPORT_TAGS = ( |
87
|
|
|
|
|
|
|
errors => [ @ERRORS ], |
88
|
|
|
|
|
|
|
ALL => [ @EXPORT, @EXPORT_OK ] |
89
|
|
|
|
|
|
|
); |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
## Public Methods ## |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub new |
94
|
|
|
|
|
|
|
{ |
95
|
9
|
|
|
9
|
0
|
20
|
my $class = shift(); |
96
|
9
|
|
|
|
|
17
|
my ($arg, $value); |
97
|
|
|
|
|
|
|
|
98
|
9
|
|
|
|
|
62
|
my $this = { |
99
|
|
|
|
|
|
|
_error_code => undef, |
100
|
|
|
|
|
|
|
_error_subcode => undef, |
101
|
|
|
|
|
|
|
_error_data => undef |
102
|
|
|
|
|
|
|
}; |
103
|
|
|
|
|
|
|
|
104
|
9
|
|
|
|
|
20
|
bless($this, $class); |
105
|
|
|
|
|
|
|
|
106
|
9
|
|
|
|
|
29
|
while ( defined($arg = shift()) ) { |
107
|
15
|
|
|
|
|
30
|
$value = shift(); |
108
|
|
|
|
|
|
|
|
109
|
15
|
100
|
|
|
|
89
|
if ( $arg =~ /errorcode/i ) { |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
110
|
9
|
|
|
|
|
51
|
$this->{_error_code} = $value; |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
elsif ( $arg =~ /errorsubcode/i ) { |
113
|
3
|
|
|
|
|
12
|
$this->{_error_subcode} = $value; |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
elsif ( $arg =~ /errordata/i ) { |
116
|
3
|
|
|
|
|
14
|
$this->{_error_data} = $value; |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
else { |
119
|
0
|
|
|
|
|
0
|
die("unrecognized argument $arg\n"); |
120
|
|
|
|
|
|
|
} |
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
|
123
|
9
|
50
|
|
|
|
39
|
defined $this->{_error_code} or croak "ErrorCode not defined"; |
124
|
|
|
|
|
|
|
defined $this->{_error_subcode} |
125
|
9
|
100
|
|
|
|
43
|
or $this->{_error_subcode} = BGP_ERROR_SUBCODE_NULL; |
126
|
|
|
|
|
|
|
|
127
|
9
|
|
|
|
|
31
|
return ( $this ); |
128
|
|
|
|
|
|
|
} |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
sub throw { |
131
|
1
|
|
|
1
|
0
|
4
|
my $class = shift; |
132
|
1
|
|
|
|
|
5
|
my $notif = $class->new(@_); |
133
|
1
|
|
|
|
|
12
|
die $notif; |
134
|
|
|
|
|
|
|
} |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
sub error_code |
137
|
|
|
|
|
|
|
{ |
138
|
8
|
|
|
8
|
0
|
61
|
my $this = shift(); |
139
|
8
|
|
|
|
|
34
|
return ( $this->{_error_code} ); |
140
|
|
|
|
|
|
|
} |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
sub error_subcode |
143
|
|
|
|
|
|
|
{ |
144
|
8
|
|
|
8
|
0
|
32
|
my $this = shift(); |
145
|
8
|
|
|
|
|
23
|
return ( $this->{_error_subcode} ); |
146
|
|
|
|
|
|
|
} |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
sub error_data |
149
|
|
|
|
|
|
|
{ |
150
|
2
|
|
|
2
|
0
|
4
|
my $this = shift(); |
151
|
2
|
|
|
|
|
10
|
return ( $this->{_error_data} ); |
152
|
|
|
|
|
|
|
} |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
## Private Methods ## |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
## POD ## |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=pod |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=head1 NAME |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
Net::BGP::Notification - Class encapsulating BGP-4 NOTIFICATION message |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=head1 SYNOPSIS |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
use Net::BGP::Notification; |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
$error = Net::BGP::Notification->new( |
169
|
|
|
|
|
|
|
ErrorCode => $error_code, |
170
|
|
|
|
|
|
|
ErrorSubCode => $error_subcode, |
171
|
|
|
|
|
|
|
ErrorData => $error_data |
172
|
|
|
|
|
|
|
); |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
$error_code = $error->error_code(); |
175
|
|
|
|
|
|
|
$error_subcode = $error->error_subcode(); |
176
|
|
|
|
|
|
|
$error_data = $error->error_data(); |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
=head1 DESCRIPTION |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
This module encapsulates the data contained in a BGP-4 NOTIFICATION message. |
181
|
|
|
|
|
|
|
It provides a constructor, and accessor methods for each of the Error Code, |
182
|
|
|
|
|
|
|
Error Subcode, and Error Data fields of a NOTIFICATION. It is unlikely that |
183
|
|
|
|
|
|
|
user programs will need to instantiate B objects |
184
|
|
|
|
|
|
|
directly. However, when an error occurs and a NOTIFICATION message is sent |
185
|
|
|
|
|
|
|
or received by a BGP peering session established with the B |
186
|
|
|
|
|
|
|
module, a reference to a B object will be passed |
187
|
|
|
|
|
|
|
to the corresponding user callback subroutine. The subroutine can then use |
188
|
|
|
|
|
|
|
the accessor methods provided by this module to examine the details of the |
189
|
|
|
|
|
|
|
NOTIFICATION message. |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
=head1 METHODS |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
I - create a new Net::BGP::Notification object |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
$error = Net::BGP::Notification->new( |
196
|
|
|
|
|
|
|
ErrorCode => $error_code, |
197
|
|
|
|
|
|
|
ErrorSubCode => $error_subcode, |
198
|
|
|
|
|
|
|
ErrorData => $error_data |
199
|
|
|
|
|
|
|
); |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
This is the constructor for Net::BGP::Notification objects. It returns a |
202
|
|
|
|
|
|
|
reference to the newly created object. The following named parameters may |
203
|
|
|
|
|
|
|
be passed to the constructor. |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
=head2 ErrorCode |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
This parameter corresponds to the Error Code field of a NOTIFICATION |
208
|
|
|
|
|
|
|
message. It must be provided to the constructor. |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
=head2 ErrorSubCode |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
This parameter corresponds to the Error Subcode field of a NOTIFICATION |
213
|
|
|
|
|
|
|
message. It may be omitted, in which case the field defaults to the null |
214
|
|
|
|
|
|
|
(0) subcode value. |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
=head2 ErrorData |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
This parameter corresponds to the Error Data field of a NOTIFICATION |
219
|
|
|
|
|
|
|
message. It may be omitted, in which case the field defaults to a null |
220
|
|
|
|
|
|
|
(zero-length) value. |
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
I - create a Notification object and throw an exception |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
Net::BGP::Notification->throw( same args as new ); |
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
I - retrieve the value of the Error Code field |
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
$error_code = $error->error_code(); |
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
I - retrieve the value of the Error Subcode field |
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
$error_subcode = $error->error_subcode(); |
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
I - retrieve the value of the Error Data field |
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
$error_data = $error->error_data(); |
237
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
=head1 SEE ALSO |
239
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
B, B, B, |
241
|
|
|
|
|
|
|
B |
242
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
=head1 AUTHOR |
244
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
Stephen J. Scheck |
246
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
=cut |
248
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
## End Package Net::BGP::Notification ## |
250
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
1; |