line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# $Id: HSRP.pm 49 2009-05-31 13:15:34Z VinsWorldcom $ |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
package Net::Frame::Layer::HSRP; |
5
|
2
|
|
|
2
|
|
16170
|
use strict; use warnings; |
|
2
|
|
|
2
|
|
4
|
|
|
2
|
|
|
|
|
249
|
|
|
2
|
|
|
|
|
10
|
|
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
103
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '1.00'; |
8
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
2156
|
use Net::Frame::Layer qw(:consts :subs); |
|
2
|
|
|
|
|
179059
|
|
|
2
|
|
|
|
|
604
|
|
10
|
2
|
|
|
2
|
|
21
|
use Exporter; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
233
|
|
11
|
|
|
|
|
|
|
our @ISA = qw(Net::Frame::Layer Exporter); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( |
14
|
|
|
|
|
|
|
consts => [qw( |
15
|
|
|
|
|
|
|
NF_HSRP_ALLHSRPRTRS |
16
|
|
|
|
|
|
|
NF_HSRP_ALLHSRPRTRS_MAC |
17
|
|
|
|
|
|
|
NF_HSRP_UDP_PORT |
18
|
|
|
|
|
|
|
NF_HSRP_VERSION_1 |
19
|
|
|
|
|
|
|
NF_HSRP_OPCODE_HELLO |
20
|
|
|
|
|
|
|
NF_HSRP_OPCODE_COUP |
21
|
|
|
|
|
|
|
NF_HSRP_OPCODE_RESIGN |
22
|
|
|
|
|
|
|
NF_HSRP_STATE_INITIAL |
23
|
|
|
|
|
|
|
NF_HSRP_STATE_LEARN |
24
|
|
|
|
|
|
|
NF_HSRP_STATE_LISTEN |
25
|
|
|
|
|
|
|
NF_HSRP_STATE_SPEAK |
26
|
|
|
|
|
|
|
NF_HSRP_STATE_STANDBY |
27
|
|
|
|
|
|
|
NF_HSRP_STATE_ACTIVE |
28
|
|
|
|
|
|
|
)], |
29
|
|
|
|
|
|
|
); |
30
|
|
|
|
|
|
|
our @EXPORT_OK = ( |
31
|
|
|
|
|
|
|
@{$EXPORT_TAGS{consts}}, |
32
|
|
|
|
|
|
|
); |
33
|
|
|
|
|
|
|
|
34
|
2
|
|
|
2
|
|
11
|
use constant NF_HSRP_ALLHSRPRTRS => '224.0.0.2'; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
110
|
|
35
|
2
|
|
|
2
|
|
9
|
use constant NF_HSRP_ALLHSRPRTRS_MAC => '01:00:5e:00:00:02'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
83
|
|
36
|
2
|
|
|
2
|
|
11
|
use constant NF_HSRP_UDP_PORT => 1985; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
79
|
|
37
|
2
|
|
|
2
|
|
10
|
use constant NF_HSRP_VERSION_1 => 0; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
80
|
|
38
|
2
|
|
|
2
|
|
11
|
use constant NF_HSRP_OPCODE_HELLO => 0; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
79
|
|
39
|
2
|
|
|
2
|
|
18
|
use constant NF_HSRP_OPCODE_COUP => 1; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
90
|
|
40
|
2
|
|
|
2
|
|
9
|
use constant NF_HSRP_OPCODE_RESIGN => 2; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
74
|
|
41
|
2
|
|
|
2
|
|
9
|
use constant NF_HSRP_STATE_INITIAL => 0; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
95
|
|
42
|
2
|
|
|
2
|
|
16
|
use constant NF_HSRP_STATE_LEARN => 1; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
98
|
|
43
|
2
|
|
|
2
|
|
20
|
use constant NF_HSRP_STATE_LISTEN => 2; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
85
|
|
44
|
2
|
|
|
2
|
|
10
|
use constant NF_HSRP_STATE_SPEAK => 4; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
75
|
|
45
|
2
|
|
|
2
|
|
10
|
use constant NF_HSRP_STATE_STANDBY => 8; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
95
|
|
46
|
2
|
|
|
2
|
|
9
|
use constant NF_HSRP_STATE_ACTIVE => 16; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
1423
|
|
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
our @AS = qw( |
49
|
|
|
|
|
|
|
version |
50
|
|
|
|
|
|
|
opcode |
51
|
|
|
|
|
|
|
state |
52
|
|
|
|
|
|
|
helloTime |
53
|
|
|
|
|
|
|
holdTime |
54
|
|
|
|
|
|
|
priority |
55
|
|
|
|
|
|
|
group |
56
|
|
|
|
|
|
|
reserved |
57
|
|
|
|
|
|
|
authData |
58
|
|
|
|
|
|
|
virtualIp |
59
|
|
|
|
|
|
|
); |
60
|
|
|
|
|
|
|
__PACKAGE__->cgBuildIndices; |
61
|
|
|
|
|
|
|
__PACKAGE__->cgBuildAccessorsScalar(\@AS); |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
#no strict 'vars'; |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
$Net::Frame::Layer::UDP::Next->{1985} = "HSRP"; |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub new { |
68
|
|
|
|
|
|
|
shift->SUPER::new( |
69
|
1
|
|
|
1
|
1
|
25
|
version => NF_HSRP_VERSION_1, |
70
|
|
|
|
|
|
|
opcode => NF_HSRP_OPCODE_HELLO, |
71
|
|
|
|
|
|
|
state => NF_HSRP_STATE_STANDBY, |
72
|
|
|
|
|
|
|
helloTime => 3, |
73
|
|
|
|
|
|
|
holdTime => 10, |
74
|
|
|
|
|
|
|
priority => 100, |
75
|
|
|
|
|
|
|
group => 1, |
76
|
|
|
|
|
|
|
reserved => 0, |
77
|
|
|
|
|
|
|
authData => "cisco\0\0\0", |
78
|
|
|
|
|
|
|
virtualIp => '127.0.0.1', |
79
|
|
|
|
|
|
|
@_, |
80
|
|
|
|
|
|
|
); |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
0
|
|
|
0
|
1
|
0
|
sub getLength { 20 } |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub pack { |
86
|
1
|
|
|
1
|
1
|
374
|
my $self = shift; |
87
|
|
|
|
|
|
|
|
88
|
1
|
50
|
|
|
|
5
|
my $raw = $self->SUPER::pack('CCCCCCCCa8a4', |
89
|
|
|
|
|
|
|
$self->version, |
90
|
|
|
|
|
|
|
$self->opcode, |
91
|
|
|
|
|
|
|
$self->state, |
92
|
|
|
|
|
|
|
$self->helloTime, |
93
|
|
|
|
|
|
|
$self->holdTime, |
94
|
|
|
|
|
|
|
$self->priority, |
95
|
|
|
|
|
|
|
$self->group, |
96
|
|
|
|
|
|
|
$self->reserved, |
97
|
|
|
|
|
|
|
$self->authData, |
98
|
|
|
|
|
|
|
inetAton($self->virtualIp) |
99
|
|
|
|
|
|
|
) or return; |
100
|
|
|
|
|
|
|
|
101
|
1
|
|
|
|
|
128
|
return $self->raw($raw); |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
sub unpack { |
105
|
1
|
|
|
1
|
1
|
13
|
my $self = shift; |
106
|
|
|
|
|
|
|
|
107
|
1
|
50
|
|
|
|
3
|
my ($version, $opcode, $state, $helloTime, $holdTime, |
108
|
|
|
|
|
|
|
$priority, $group, $reserved, $authData, $virtualIp, $payload) = |
109
|
|
|
|
|
|
|
$self->SUPER::unpack('CCCCCCCCa8a4 a*', $self->raw) |
110
|
|
|
|
|
|
|
or return; |
111
|
|
|
|
|
|
|
|
112
|
1
|
|
|
|
|
33
|
$self->version($version); |
113
|
1
|
|
|
|
|
9
|
$self->opcode($opcode); |
114
|
1
|
|
|
|
|
10
|
$self->state($state); |
115
|
1
|
|
|
|
|
8
|
$self->helloTime($helloTime); |
116
|
1
|
|
|
|
|
8
|
$self->holdTime($holdTime); |
117
|
1
|
|
|
|
|
9
|
$self->priority($priority); |
118
|
1
|
|
|
|
|
8
|
$self->group($group); |
119
|
1
|
|
|
|
|
8
|
$self->reserved($reserved); |
120
|
1
|
|
|
|
|
8
|
$self->authData($authData); |
121
|
1
|
|
|
|
|
11
|
$self->virtualIp(inetNtoa($virtualIp)); |
122
|
|
|
|
|
|
|
|
123
|
1
|
|
|
|
|
22
|
$self->payload($payload); |
124
|
|
|
|
|
|
|
|
125
|
1
|
|
|
|
|
8
|
return $self; |
126
|
|
|
|
|
|
|
} |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
sub encapsulate { |
129
|
1
|
|
|
1
|
1
|
7
|
my $self = shift; |
130
|
|
|
|
|
|
|
|
131
|
1
|
50
|
|
|
|
8
|
return $self->nextLayer if $self->nextLayer; |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
# if ($self->payload) { |
134
|
|
|
|
|
|
|
# if ($self->version == 1) { |
135
|
|
|
|
|
|
|
# return 'HSRP::v1'; |
136
|
|
|
|
|
|
|
# } elsif ($self->version == 2) { |
137
|
|
|
|
|
|
|
# return 'HSRP::v2'; |
138
|
|
|
|
|
|
|
# } |
139
|
|
|
|
|
|
|
# } |
140
|
|
|
|
|
|
|
|
141
|
1
|
|
|
|
|
14
|
NF_LAYER_NONE; |
142
|
|
|
|
|
|
|
} |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
sub print { |
145
|
1
|
|
|
1
|
1
|
5
|
my $self = shift; |
146
|
|
|
|
|
|
|
|
147
|
1
|
|
|
|
|
6
|
my $l = $self->layer; |
148
|
1
|
|
|
|
|
14
|
my $buf = sprintf |
149
|
|
|
|
|
|
|
"$l: version:%d opcode:%d state:%d helloTime:%d\n". |
150
|
|
|
|
|
|
|
"$l: holdTime:%d priority:%d group:%d reserved:%d\n". |
151
|
|
|
|
|
|
|
"$l: authData:%s\n". |
152
|
|
|
|
|
|
|
"$l: virtualIp:%s", |
153
|
|
|
|
|
|
|
$self->version, $self->opcode, $self->state, $self->helloTime, |
154
|
|
|
|
|
|
|
$self->holdTime, $self->priority, $self->group, $self->reserved, |
155
|
|
|
|
|
|
|
$self->authData, |
156
|
|
|
|
|
|
|
$self->virtualIp; |
157
|
|
|
|
|
|
|
|
158
|
1
|
|
|
|
|
582
|
return $buf; |
159
|
|
|
|
|
|
|
} |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
1; |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
__END__ |