line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# $Id: RIP.pm 49 2009-05-31 13:15:34Z VinsWorldcom $ |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
package Net::Frame::Layer::RIP; |
5
|
7
|
|
|
7
|
|
578139
|
use strict; use warnings; |
|
7
|
|
|
7
|
|
17
|
|
|
7
|
|
|
|
|
270
|
|
|
7
|
|
|
|
|
43
|
|
|
7
|
|
|
|
|
15
|
|
|
7
|
|
|
|
|
371
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '1.02'; |
8
|
|
|
|
|
|
|
|
9
|
7
|
|
|
7
|
|
3377
|
use Net::Frame::Layer qw(:consts :subs); |
|
7
|
|
|
|
|
285372
|
|
|
7
|
|
|
|
|
2157
|
|
10
|
7
|
|
|
7
|
|
60
|
use Exporter; |
|
7
|
|
|
|
|
13
|
|
|
7
|
|
|
|
|
423
|
|
11
|
|
|
|
|
|
|
our @ISA = qw(Net::Frame::Layer Exporter); |
12
|
|
|
|
|
|
|
|
13
|
7
|
|
|
7
|
|
5215
|
use Net::Frame::Layer::RIP::v1 qw(:consts); |
|
7
|
|
|
|
|
32
|
|
|
7
|
|
|
|
|
1077
|
|
14
|
7
|
|
|
7
|
|
5654
|
use Net::Frame::Layer::RIP::v2 qw(:consts); |
|
7
|
|
|
|
|
23
|
|
|
7
|
|
|
|
|
2466
|
|
15
|
|
|
|
|
|
|
my @consts; |
16
|
|
|
|
|
|
|
for my $c (sort(keys(%constant::declared))) { |
17
|
|
|
|
|
|
|
if ($c =~ /^Net::Frame::Layer::RIP::v[12]::/) { |
18
|
|
|
|
|
|
|
$c =~ s/^Net::Frame::Layer::RIP::v[12]:://; |
19
|
|
|
|
|
|
|
push @consts, $c |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( |
24
|
|
|
|
|
|
|
consts => [@consts, qw( |
25
|
|
|
|
|
|
|
NF_RIP_V1_DEST_HWADDR |
26
|
|
|
|
|
|
|
NF_RIP_V1_DEST_ADDR |
27
|
|
|
|
|
|
|
NF_RIP_V1_DEST_PORT |
28
|
|
|
|
|
|
|
NF_RIP_V2_DEST_HWADDR |
29
|
|
|
|
|
|
|
NF_RIP_V2_DEST_ADDR |
30
|
|
|
|
|
|
|
NF_RIP_V2_DEST_PORT |
31
|
|
|
|
|
|
|
NF_RIP_V1_COMMAND_REQUEST |
32
|
|
|
|
|
|
|
NF_RIP_V1_COMMAND_RESPONSE |
33
|
|
|
|
|
|
|
NF_RIP_V1_COMMAND_TRACEON |
34
|
|
|
|
|
|
|
NF_RIP_V1_COMMAND_TRACEOFF |
35
|
|
|
|
|
|
|
NF_RIP_V1_COMMAND_SUNRESV |
36
|
|
|
|
|
|
|
NF_RIP_V1_COMMAND_TRIGGEREDREQUEST |
37
|
|
|
|
|
|
|
NF_RIP_V1_COMMAND_TRIGGEREDRESPONSE |
38
|
|
|
|
|
|
|
NF_RIP_V1_COMMAND_TRIGGEREDACK |
39
|
|
|
|
|
|
|
NF_RIP_V1_COMMAND_UPDATEREQUEST |
40
|
|
|
|
|
|
|
NF_RIP_V1_COMMAND_UPDATERESPONSE |
41
|
|
|
|
|
|
|
NF_RIP_V1_COMMAND_UPDATEACK |
42
|
|
|
|
|
|
|
NF_RIP_V2_COMMAND_REQUEST |
43
|
|
|
|
|
|
|
NF_RIP_V2_COMMAND_RESPONSE |
44
|
|
|
|
|
|
|
NF_RIP_V2_COMMAND_TRACEON |
45
|
|
|
|
|
|
|
NF_RIP_V2_COMMAND_TRACEOFF |
46
|
|
|
|
|
|
|
NF_RIP_V2_COMMAND_SUNRESV |
47
|
|
|
|
|
|
|
NF_RIP_V2_COMMAND_TRIGGEREDREQUEST |
48
|
|
|
|
|
|
|
NF_RIP_V2_COMMAND_TRIGGEREDRESPONSE |
49
|
|
|
|
|
|
|
NF_RIP_V2_COMMAND_TRIGGEREDACK |
50
|
|
|
|
|
|
|
NF_RIP_V2_COMMAND_UPDATEREQUEST |
51
|
|
|
|
|
|
|
NF_RIP_V2_COMMAND_UPDATERESPONSE |
52
|
|
|
|
|
|
|
NF_RIP_V2_COMMAND_UPDATEACK |
53
|
|
|
|
|
|
|
)], |
54
|
|
|
|
|
|
|
); |
55
|
|
|
|
|
|
|
our @EXPORT_OK = ( |
56
|
|
|
|
|
|
|
@{$EXPORT_TAGS{consts}}, |
57
|
|
|
|
|
|
|
); |
58
|
|
|
|
|
|
|
|
59
|
7
|
|
|
7
|
|
48
|
use constant NF_RIP_V1_DEST_HWADDR => 'ff:ff:ff:ff:ff:ff'; |
|
7
|
|
|
|
|
21
|
|
|
7
|
|
|
|
|
409
|
|
60
|
7
|
|
|
7
|
|
38
|
use constant NF_RIP_V1_DEST_ADDR => '255.255.255.255'; |
|
7
|
|
|
|
|
13
|
|
|
7
|
|
|
|
|
380
|
|
61
|
7
|
|
|
7
|
|
38
|
use constant NF_RIP_V1_DEST_PORT => 520; |
|
7
|
|
|
|
|
14
|
|
|
7
|
|
|
|
|
393
|
|
62
|
7
|
|
|
7
|
|
38
|
use constant NF_RIP_V2_DEST_HWADDR => '01:00:5e:00:00:09'; |
|
7
|
|
|
|
|
11
|
|
|
7
|
|
|
|
|
415
|
|
63
|
7
|
|
|
7
|
|
36
|
use constant NF_RIP_V2_DEST_ADDR => '224.0.0.9'; |
|
7
|
|
|
|
|
14
|
|
|
7
|
|
|
|
|
324
|
|
64
|
7
|
|
|
7
|
|
38
|
use constant NF_RIP_V2_DEST_PORT => 520; |
|
7
|
|
|
|
|
13
|
|
|
7
|
|
|
|
|
313
|
|
65
|
7
|
|
|
7
|
|
46
|
use constant NF_RIP_V1_COMMAND_REQUEST => 1; |
|
7
|
|
|
|
|
13
|
|
|
7
|
|
|
|
|
367
|
|
66
|
7
|
|
|
7
|
|
148
|
use constant NF_RIP_V1_COMMAND_RESPONSE => 2; |
|
7
|
|
|
|
|
16
|
|
|
7
|
|
|
|
|
504
|
|
67
|
7
|
|
|
7
|
|
34
|
use constant NF_RIP_V1_COMMAND_TRACEON => 3; |
|
7
|
|
|
|
|
14
|
|
|
7
|
|
|
|
|
357
|
|
68
|
7
|
|
|
7
|
|
37
|
use constant NF_RIP_V1_COMMAND_TRACEOFF => 4; |
|
7
|
|
|
|
|
19
|
|
|
7
|
|
|
|
|
313
|
|
69
|
7
|
|
|
7
|
|
2067
|
use constant NF_RIP_V1_COMMAND_SUNRESV => 5; |
|
7
|
|
|
|
|
12
|
|
|
7
|
|
|
|
|
1763
|
|
70
|
7
|
|
|
7
|
|
52
|
use constant NF_RIP_V1_COMMAND_TRIGGEREDREQUEST => 6; |
|
7
|
|
|
|
|
15
|
|
|
7
|
|
|
|
|
324
|
|
71
|
7
|
|
|
7
|
|
37
|
use constant NF_RIP_V1_COMMAND_TRIGGEREDRESPONSE => 7; |
|
7
|
|
|
|
|
10
|
|
|
7
|
|
|
|
|
296
|
|
72
|
7
|
|
|
7
|
|
35
|
use constant NF_RIP_V1_COMMAND_TRIGGEREDACK => 8; |
|
7
|
|
|
|
|
19
|
|
|
7
|
|
|
|
|
309
|
|
73
|
7
|
|
|
7
|
|
33
|
use constant NF_RIP_V1_COMMAND_UPDATEREQUEST => 9; |
|
7
|
|
|
|
|
12
|
|
|
7
|
|
|
|
|
319
|
|
74
|
7
|
|
|
7
|
|
37
|
use constant NF_RIP_V1_COMMAND_UPDATERESPONSE => 10; |
|
7
|
|
|
|
|
13
|
|
|
7
|
|
|
|
|
445
|
|
75
|
7
|
|
|
7
|
|
35
|
use constant NF_RIP_V1_COMMAND_UPDATEACK => 11; |
|
7
|
|
|
|
|
13
|
|
|
7
|
|
|
|
|
331
|
|
76
|
7
|
|
|
7
|
|
36
|
use constant NF_RIP_V2_COMMAND_REQUEST => 1; |
|
7
|
|
|
|
|
12
|
|
|
7
|
|
|
|
|
365
|
|
77
|
7
|
|
|
7
|
|
43
|
use constant NF_RIP_V2_COMMAND_RESPONSE => 2; |
|
7
|
|
|
|
|
11
|
|
|
7
|
|
|
|
|
312
|
|
78
|
7
|
|
|
7
|
|
43
|
use constant NF_RIP_V2_COMMAND_TRACEON => 3; |
|
7
|
|
|
|
|
11
|
|
|
7
|
|
|
|
|
306
|
|
79
|
7
|
|
|
7
|
|
40
|
use constant NF_RIP_V2_COMMAND_TRACEOFF => 4; |
|
7
|
|
|
|
|
18
|
|
|
7
|
|
|
|
|
371
|
|
80
|
7
|
|
|
7
|
|
337
|
use constant NF_RIP_V2_COMMAND_SUNRESV => 5; |
|
7
|
|
|
|
|
15
|
|
|
7
|
|
|
|
|
338
|
|
81
|
7
|
|
|
7
|
|
40
|
use constant NF_RIP_V2_COMMAND_TRIGGEREDREQUEST => 6; |
|
7
|
|
|
|
|
11
|
|
|
7
|
|
|
|
|
362
|
|
82
|
7
|
|
|
7
|
|
32
|
use constant NF_RIP_V2_COMMAND_TRIGGEREDRESPONSE => 7; |
|
7
|
|
|
|
|
14
|
|
|
7
|
|
|
|
|
381
|
|
83
|
7
|
|
|
7
|
|
33
|
use constant NF_RIP_V2_COMMAND_TRIGGEREDACK => 8; |
|
7
|
|
|
|
|
11
|
|
|
7
|
|
|
|
|
1831
|
|
84
|
7
|
|
|
7
|
|
35
|
use constant NF_RIP_V2_COMMAND_UPDATEREQUEST => 9; |
|
7
|
|
|
|
|
17
|
|
|
7
|
|
|
|
|
370
|
|
85
|
7
|
|
|
7
|
|
66
|
use constant NF_RIP_V2_COMMAND_UPDATERESPONSE => 10; |
|
7
|
|
|
|
|
25
|
|
|
7
|
|
|
|
|
350
|
|
86
|
7
|
|
|
7
|
|
35
|
use constant NF_RIP_V2_COMMAND_UPDATEACK => 11; |
|
7
|
|
|
|
|
12
|
|
|
7
|
|
|
|
|
5889
|
|
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
our @AS = qw( |
89
|
|
|
|
|
|
|
command |
90
|
|
|
|
|
|
|
version |
91
|
|
|
|
|
|
|
reserved |
92
|
|
|
|
|
|
|
); |
93
|
|
|
|
|
|
|
__PACKAGE__->cgBuildIndices; |
94
|
|
|
|
|
|
|
__PACKAGE__->cgBuildAccessorsScalar(\@AS); |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
#no strict 'vars'; |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
$Net::Frame::Layer::UDP::Next->{520} = "RIP"; |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
sub new { |
101
|
|
|
|
|
|
|
shift->SUPER::new( |
102
|
11
|
|
|
11
|
1
|
13561
|
command => NF_RIP_V2_COMMAND_REQUEST, |
103
|
|
|
|
|
|
|
version => 2, |
104
|
|
|
|
|
|
|
reserved => 0, |
105
|
|
|
|
|
|
|
@_, |
106
|
|
|
|
|
|
|
); |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
sub match { |
110
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
111
|
0
|
|
|
|
|
0
|
my ($with) = @_; |
112
|
0
|
|
|
|
|
0
|
my $sVer = $self->version; |
113
|
0
|
|
|
|
|
0
|
my $wVer = $with->version; |
114
|
0
|
|
|
|
|
0
|
my $sCmd = $self->command; |
115
|
0
|
|
|
|
|
0
|
my $wCmd = $with->command; |
116
|
0
|
0
|
0
|
|
|
0
|
if (($sCmd == NF_RIP_V1_COMMAND_REQUEST) |
|
|
|
0
|
|
|
|
|
117
|
|
|
|
|
|
|
&& ($wCmd == NF_RIP_V1_COMMAND_RESPONSE) |
118
|
|
|
|
|
|
|
&& ($sVer == $wVer)) { |
119
|
0
|
|
|
|
|
0
|
return 1; |
120
|
|
|
|
|
|
|
} |
121
|
0
|
|
|
|
|
0
|
0; |
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
# XXX: may be better, by keying on type also |
125
|
0
|
|
|
0
|
1
|
0
|
sub getKey { shift->layer } |
126
|
0
|
|
|
0
|
1
|
0
|
sub getKeyReverse { shift->layer } |
127
|
|
|
|
|
|
|
|
128
|
0
|
|
|
0
|
1
|
0
|
sub getLength { 4 } |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
sub pack { |
131
|
1
|
|
|
1
|
1
|
335
|
my $self = shift; |
132
|
|
|
|
|
|
|
|
133
|
1
|
50
|
|
|
|
7
|
my $raw = $self->SUPER::pack('CCn', |
134
|
|
|
|
|
|
|
$self->command, |
135
|
|
|
|
|
|
|
$self->version, |
136
|
|
|
|
|
|
|
$self->reserved |
137
|
|
|
|
|
|
|
) or return; |
138
|
|
|
|
|
|
|
|
139
|
1
|
|
|
|
|
82
|
return $self->raw($raw); |
140
|
|
|
|
|
|
|
} |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
sub unpack { |
143
|
1
|
|
|
1
|
1
|
19
|
my $self = shift; |
144
|
|
|
|
|
|
|
|
145
|
1
|
50
|
|
|
|
6
|
my ($command, $version, $reserved, $payload) = |
146
|
|
|
|
|
|
|
$self->SUPER::unpack('CCn a*', $self->raw) |
147
|
|
|
|
|
|
|
or return; |
148
|
|
|
|
|
|
|
|
149
|
1
|
|
|
|
|
49
|
$self->command($command); |
150
|
1
|
|
|
|
|
14
|
$self->version($version); |
151
|
1
|
|
|
|
|
15
|
$self->reserved($reserved); |
152
|
|
|
|
|
|
|
|
153
|
1
|
|
|
|
|
17
|
$self->payload($payload); |
154
|
|
|
|
|
|
|
|
155
|
1
|
|
|
|
|
12
|
return $self; |
156
|
|
|
|
|
|
|
} |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
sub encapsulate { |
159
|
1
|
|
|
1
|
1
|
9
|
my $self = shift; |
160
|
|
|
|
|
|
|
|
161
|
1
|
50
|
|
|
|
16
|
return $self->nextLayer if $self->nextLayer; |
162
|
|
|
|
|
|
|
|
163
|
1
|
50
|
|
|
|
67
|
if ($self->payload) { |
164
|
0
|
0
|
|
|
|
0
|
if ($self->version == 1) { |
|
|
0
|
|
|
|
|
|
165
|
0
|
|
|
|
|
0
|
return 'RIP::v1'; |
166
|
|
|
|
|
|
|
} elsif ($self->version == 2) { |
167
|
0
|
|
|
|
|
0
|
return 'RIP::v2'; |
168
|
|
|
|
|
|
|
} |
169
|
|
|
|
|
|
|
} |
170
|
|
|
|
|
|
|
|
171
|
1
|
|
|
|
|
16
|
NF_LAYER_NONE; |
172
|
|
|
|
|
|
|
} |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
sub print { |
175
|
1
|
|
|
1
|
1
|
7
|
my $self = shift; |
176
|
|
|
|
|
|
|
|
177
|
1
|
|
|
|
|
9
|
my $l = $self->layer; |
178
|
1
|
|
|
|
|
17
|
my $buf = sprintf |
179
|
|
|
|
|
|
|
"$l: command:%d version:%d reserved:%d", |
180
|
|
|
|
|
|
|
$self->command, $self->version, $self->reserved; |
181
|
|
|
|
|
|
|
|
182
|
1
|
|
|
|
|
444
|
return $buf; |
183
|
|
|
|
|
|
|
} |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
1; |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
__END__ |