line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# $Id: v2.pm 49 2009-05-31 13:15:34Z VinsWorldcom $ |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
package Net::Frame::Layer::RIP::v2; |
5
|
8
|
|
|
8
|
|
16249
|
use strict; use warnings; |
|
8
|
|
|
8
|
|
17
|
|
|
8
|
|
|
|
|
287
|
|
|
8
|
|
|
|
|
43
|
|
|
8
|
|
|
|
|
14
|
|
|
8
|
|
|
|
|
274
|
|
6
|
|
|
|
|
|
|
|
7
|
8
|
|
|
8
|
|
2219
|
use Net::Frame::Layer qw(:consts :subs); |
|
8
|
|
|
|
|
162252
|
|
|
8
|
|
|
|
|
2528
|
|
8
|
|
|
|
|
|
|
our @ISA = qw(Net::Frame::Layer Exporter); |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( |
11
|
|
|
|
|
|
|
consts => [qw( |
12
|
|
|
|
|
|
|
NF_RIP_V2_ADDRESSFAMILY_IPV4 |
13
|
|
|
|
|
|
|
NF_RIP_V2_ADDRESSFAMILY_AUTH |
14
|
|
|
|
|
|
|
NF_RIP_V2_AUTHTYPE_SIMPLE |
15
|
|
|
|
|
|
|
NF_RIP_V2_METRIC_INFINITY |
16
|
|
|
|
|
|
|
)], |
17
|
|
|
|
|
|
|
); |
18
|
|
|
|
|
|
|
our @EXPORT_OK = ( |
19
|
|
|
|
|
|
|
@{$EXPORT_TAGS{consts}}, |
20
|
|
|
|
|
|
|
); |
21
|
|
|
|
|
|
|
|
22
|
8
|
|
|
8
|
|
292
|
use constant NF_RIP_V2_ADDRESSFAMILY_IPV4 => 2; |
|
8
|
|
|
|
|
18
|
|
|
8
|
|
|
|
|
577
|
|
23
|
8
|
|
|
8
|
|
46
|
use constant NF_RIP_V2_ADDRESSFAMILY_AUTH => 0xffff; |
|
8
|
|
|
|
|
20
|
|
|
8
|
|
|
|
|
600
|
|
24
|
8
|
|
|
8
|
|
45
|
use constant NF_RIP_V2_AUTHTYPE_SIMPLE => 2; |
|
8
|
|
|
|
|
23
|
|
|
8
|
|
|
|
|
379
|
|
25
|
8
|
|
|
8
|
|
42
|
use constant NF_RIP_V2_METRIC_INFINITY => 16; |
|
8
|
|
|
|
|
22
|
|
|
8
|
|
|
|
|
9568
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
our @AS = qw( |
28
|
|
|
|
|
|
|
addressFamily |
29
|
|
|
|
|
|
|
routeTag |
30
|
|
|
|
|
|
|
address |
31
|
|
|
|
|
|
|
subnetMask |
32
|
|
|
|
|
|
|
nextHop |
33
|
|
|
|
|
|
|
metric |
34
|
|
|
|
|
|
|
authType |
35
|
|
|
|
|
|
|
authentication |
36
|
|
|
|
|
|
|
); |
37
|
|
|
|
|
|
|
__PACKAGE__->cgBuildIndices; |
38
|
|
|
|
|
|
|
__PACKAGE__->cgBuildAccessorsScalar(\@AS); |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub new { |
41
|
|
|
|
|
|
|
shift->SUPER::new( |
42
|
3
|
|
|
3
|
1
|
1042
|
addressFamily => NF_RIP_V2_ADDRESSFAMILY_IPV4, |
43
|
|
|
|
|
|
|
routeTag => 0, |
44
|
|
|
|
|
|
|
address => '0.0.0.0', |
45
|
|
|
|
|
|
|
subnetMask => '0.0.0.0', |
46
|
|
|
|
|
|
|
nextHop => '0.0.0.0', |
47
|
|
|
|
|
|
|
metric => 1, |
48
|
|
|
|
|
|
|
@_, |
49
|
|
|
|
|
|
|
); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub full { |
53
|
|
|
|
|
|
|
shift->SUPER::new( |
54
|
2
|
|
|
2
|
1
|
403
|
addressFamily => 0, |
55
|
|
|
|
|
|
|
routeTag => 0, |
56
|
|
|
|
|
|
|
address => '0.0.0.0', |
57
|
|
|
|
|
|
|
subnetMask => '0.0.0.0', |
58
|
|
|
|
|
|
|
nextHop => '0.0.0.0', |
59
|
|
|
|
|
|
|
metric => NF_RIP_V2_METRIC_INFINITY, |
60
|
|
|
|
|
|
|
@_, |
61
|
|
|
|
|
|
|
); |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub auth { |
65
|
4
|
|
|
4
|
1
|
726
|
my $self = shift; |
66
|
|
|
|
|
|
|
|
67
|
4
|
|
|
|
|
13
|
my %params = ( |
68
|
|
|
|
|
|
|
authentication => '' |
69
|
|
|
|
|
|
|
); |
70
|
|
|
|
|
|
|
|
71
|
4
|
|
|
|
|
13
|
my %args = @_; |
72
|
4
|
|
|
|
|
11
|
for (keys(%args)) { |
73
|
4
|
100
|
|
|
|
21
|
if (/^authentication$/i) { |
74
|
3
|
|
|
|
|
12
|
$params{'authentication'} = substr $args{$_}, 0, 16 |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
$self->SUPER::new( |
79
|
4
|
|
|
|
|
24
|
addressFamily => NF_RIP_V2_ADDRESSFAMILY_AUTH, |
80
|
|
|
|
|
|
|
authType => NF_RIP_V2_AUTHTYPE_SIMPLE, |
81
|
|
|
|
|
|
|
authentication => '', |
82
|
|
|
|
|
|
|
@_, |
83
|
|
|
|
|
|
|
%params, |
84
|
|
|
|
|
|
|
); |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
0
|
|
|
0
|
1
|
0
|
sub getLength { 20 } |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
sub pack { |
90
|
11
|
|
|
11
|
1
|
1117
|
my $self = shift; |
91
|
|
|
|
|
|
|
|
92
|
11
|
100
|
|
|
|
38
|
if ($self->addressFamily == NF_RIP_V2_ADDRESSFAMILY_AUTH) { |
93
|
6
|
50
|
|
|
|
72
|
$self->raw($self->SUPER::pack('nna16', |
94
|
|
|
|
|
|
|
$self->addressFamily, |
95
|
|
|
|
|
|
|
$self->authType, |
96
|
|
|
|
|
|
|
$self->authentication |
97
|
|
|
|
|
|
|
)) or return; |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
} else { |
100
|
5
|
50
|
|
|
|
94
|
$self->raw($self->SUPER::pack('nna4a4a4N', |
101
|
|
|
|
|
|
|
$self->addressFamily, |
102
|
|
|
|
|
|
|
$self->routeTag, |
103
|
|
|
|
|
|
|
inetAton($self->address), |
104
|
|
|
|
|
|
|
inetAton($self->subnetMask), |
105
|
|
|
|
|
|
|
inetAton($self->nextHop), |
106
|
|
|
|
|
|
|
$self->metric |
107
|
|
|
|
|
|
|
)) or return; |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
11
|
|
|
|
|
670
|
return $self->raw; |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
sub unpack { |
114
|
1
|
|
|
1
|
1
|
15
|
my $self = shift; |
115
|
|
|
|
|
|
|
|
116
|
1
|
50
|
|
|
|
4
|
my ($addressFamily, $remain) = |
117
|
|
|
|
|
|
|
$self->SUPER::unpack('n a*', $self->raw) |
118
|
|
|
|
|
|
|
or return; |
119
|
|
|
|
|
|
|
|
120
|
1
|
50
|
|
|
|
37
|
if ($addressFamily == NF_RIP_V2_ADDRESSFAMILY_AUTH) { |
121
|
0
|
0
|
|
|
|
0
|
my ($authType, $authentication, $payload) = |
122
|
|
|
|
|
|
|
$self->SUPER::unpack('na16 a*', $remain) |
123
|
|
|
|
|
|
|
or return; |
124
|
|
|
|
|
|
|
|
125
|
0
|
|
|
|
|
0
|
$self->addressFamily($addressFamily); |
126
|
0
|
|
|
|
|
0
|
$self->authType($authType); |
127
|
0
|
|
|
|
|
0
|
$authentication =~ s/\0{0,}$//g; |
128
|
0
|
|
|
|
|
0
|
$self->authentication($authentication); |
129
|
|
|
|
|
|
|
|
130
|
0
|
|
|
|
|
0
|
$self->payload($payload); |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
} else { |
133
|
1
|
50
|
|
|
|
5
|
my ($routeTag, $address, $subnetMask, $nextHop, $metric, $payload) = |
134
|
|
|
|
|
|
|
$self->SUPER::unpack('na4a4a4N a*', $remain) |
135
|
|
|
|
|
|
|
or return; |
136
|
|
|
|
|
|
|
|
137
|
1
|
|
|
|
|
27
|
$self->addressFamily($addressFamily); |
138
|
1
|
|
|
|
|
13
|
$self->routeTag($routeTag); |
139
|
1
|
|
|
|
|
13
|
$self->address(inetNtoa($address)); |
140
|
1
|
|
|
|
|
26
|
$self->subnetMask(inetNtoa($subnetMask)); |
141
|
1
|
|
|
|
|
18
|
$self->nextHop(inetNtoa($nextHop)); |
142
|
1
|
|
|
|
|
17
|
$self->metric($metric); |
143
|
|
|
|
|
|
|
|
144
|
1
|
|
|
|
|
24
|
$self->payload($payload); |
145
|
|
|
|
|
|
|
} |
146
|
|
|
|
|
|
|
|
147
|
1
|
|
|
|
|
13
|
return $self; |
148
|
|
|
|
|
|
|
} |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
sub encapsulate { |
151
|
1
|
|
|
1
|
1
|
6
|
my $self = shift; |
152
|
|
|
|
|
|
|
|
153
|
1
|
50
|
|
|
|
8
|
return $self->nextLayer if $self->nextLayer; |
154
|
|
|
|
|
|
|
|
155
|
1
|
50
|
|
|
|
22
|
if ($self->payload) { |
156
|
0
|
|
|
|
|
0
|
return "RIP::v2"; |
157
|
|
|
|
|
|
|
} |
158
|
|
|
|
|
|
|
|
159
|
1
|
|
|
|
|
17
|
NF_LAYER_NONE; |
160
|
|
|
|
|
|
|
} |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
sub print { |
163
|
11
|
|
|
11
|
1
|
1122
|
my $self = shift; |
164
|
|
|
|
|
|
|
|
165
|
11
|
|
|
|
|
35
|
my $l = $self->layer; |
166
|
11
|
|
|
|
|
103
|
my $buf; |
167
|
|
|
|
|
|
|
|
168
|
11
|
100
|
|
|
|
1180
|
if ($self->addressFamily == NF_RIP_V2_ADDRESSFAMILY_AUTH) { |
169
|
6
|
|
|
|
|
76
|
$buf = sprintf |
170
|
|
|
|
|
|
|
"$l: addressFamily:0x%02x authType:%d\n". |
171
|
|
|
|
|
|
|
"$l: authentication:%s", |
172
|
|
|
|
|
|
|
$self->addressFamily, $self->authType, |
173
|
|
|
|
|
|
|
$self->authentication; |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
} else { |
176
|
5
|
|
|
|
|
103
|
$buf = sprintf |
177
|
|
|
|
|
|
|
"$l: addressFamily:%d routeTag:%d\n". |
178
|
|
|
|
|
|
|
"$l: address:%s subnetMask:%s nextHop:%s\n". |
179
|
|
|
|
|
|
|
"$l: metric:%d", |
180
|
|
|
|
|
|
|
$self->addressFamily, $self->routeTag, |
181
|
|
|
|
|
|
|
$self->address, $self->subnetMask, $self->nextHop, |
182
|
|
|
|
|
|
|
$self->metric; |
183
|
|
|
|
|
|
|
} |
184
|
|
|
|
|
|
|
|
185
|
11
|
|
|
|
|
1706
|
return $buf; |
186
|
|
|
|
|
|
|
} |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
1; |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
__END__ |