line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# $Id: Hello.pm,v 1.3 2007/02/04 16:44:59 gomor Exp $ |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
package Net::Frame::Layer::OSPF::Hello; |
5
|
2
|
|
|
2
|
|
6
|
use strict; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
46
|
|
6
|
2
|
|
|
2
|
|
7
|
use warnings; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
50
|
|
7
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
6
|
use Net::Frame::Layer qw(:consts :subs); |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
363
|
|
9
|
|
|
|
|
|
|
our @ISA = qw(Net::Frame::Layer); |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our @AS = qw( |
12
|
|
|
|
|
|
|
networkMask |
13
|
|
|
|
|
|
|
helloInterval |
14
|
|
|
|
|
|
|
options |
15
|
|
|
|
|
|
|
routerPri |
16
|
|
|
|
|
|
|
routerDeadInterval |
17
|
|
|
|
|
|
|
designatedRouter |
18
|
|
|
|
|
|
|
backupDesignatedRouter |
19
|
|
|
|
|
|
|
lls |
20
|
|
|
|
|
|
|
); |
21
|
|
|
|
|
|
|
our @AA = qw( |
22
|
|
|
|
|
|
|
neighborList |
23
|
|
|
|
|
|
|
); |
24
|
|
|
|
|
|
|
__PACKAGE__->cgBuildIndices; |
25
|
|
|
|
|
|
|
__PACKAGE__->cgBuildAccessorsScalar(\@AS); |
26
|
|
|
|
|
|
|
__PACKAGE__->cgBuildAccessorsArray (\@AA); |
27
|
|
|
|
|
|
|
|
28
|
2
|
|
|
2
|
|
8
|
use Net::Frame::Layer::OSPF qw(:consts); |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
1089
|
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub new { |
31
|
|
|
|
|
|
|
shift->SUPER::new( |
32
|
1
|
|
|
1
|
1
|
12
|
networkMask => '255.255.255.0', |
33
|
|
|
|
|
|
|
helloInterval => 60, |
34
|
|
|
|
|
|
|
options => 0, |
35
|
|
|
|
|
|
|
routerPri => 0, |
36
|
|
|
|
|
|
|
routerDeadInterval => 120, |
37
|
|
|
|
|
|
|
designatedRouter => '0.0.0.0', |
38
|
|
|
|
|
|
|
backupDesignatedRouter => '0.0.0.0', |
39
|
|
|
|
|
|
|
neighborList => [], |
40
|
|
|
|
|
|
|
@_, |
41
|
|
|
|
|
|
|
); |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub getLength { |
45
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
46
|
0
|
|
|
|
|
0
|
my $len = 20; |
47
|
0
|
|
|
|
|
0
|
for ($self->neighborList) { |
48
|
0
|
|
|
|
|
0
|
$len += 4; |
49
|
|
|
|
|
|
|
} |
50
|
0
|
|
|
|
|
0
|
$len; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub pack { |
54
|
1
|
|
|
1
|
1
|
176
|
my $self = shift; |
55
|
|
|
|
|
|
|
|
56
|
1
|
50
|
|
|
|
4
|
my $raw = $self->SUPER::pack('a4nCCNa4a4', |
57
|
|
|
|
|
|
|
inetAton($self->networkMask), $self->helloInterval, $self->options, |
58
|
|
|
|
|
|
|
$self->routerPri, $self->routerDeadInterval, |
59
|
|
|
|
|
|
|
inetAton($self->designatedRouter), |
60
|
|
|
|
|
|
|
inetAton($self->backupDesignatedRouter), |
61
|
|
|
|
|
|
|
) or return undef; |
62
|
|
|
|
|
|
|
|
63
|
1
|
|
|
|
|
56
|
for ($self->neighborList) { |
64
|
0
|
0
|
|
|
|
0
|
$raw .= $self->SUPER::pack('a4', inetAton($_)) or return undef; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
1
|
|
|
|
|
14
|
$self->raw($raw); |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub unpack { |
71
|
1
|
|
|
1
|
1
|
9
|
my $self = shift; |
72
|
|
|
|
|
|
|
|
73
|
1
|
50
|
|
|
|
2
|
my ($netmask, $helloInt, $options, $pri, $deadInt, $desRouter, $backup, |
74
|
|
|
|
|
|
|
$payload) = $self->SUPER::unpack('a4nCCNa4a4 a*', $self->raw) |
75
|
|
|
|
|
|
|
or return undef; |
76
|
|
|
|
|
|
|
|
77
|
1
|
|
|
|
|
19
|
$self->networkMask(inetNtoa($netmask)); |
78
|
1
|
|
|
|
|
10
|
$self->helloInterval($helloInt); |
79
|
1
|
|
|
|
|
8
|
$self->options($options); |
80
|
1
|
|
|
|
|
6
|
$self->routerPri($pri); |
81
|
1
|
|
|
|
|
6
|
$self->routerDeadInterval($deadInt); |
82
|
1
|
|
|
|
|
6
|
$self->designatedRouter(inetNtoa($desRouter)); |
83
|
1
|
|
|
|
|
7
|
$self->backupDesignatedRouter(inetNtoa($backup)); |
84
|
|
|
|
|
|
|
|
85
|
1
|
|
|
|
|
8
|
my @neighborList = (); |
86
|
1
|
50
|
|
|
|
3
|
if ($payload) { |
87
|
0
|
|
|
|
|
0
|
while ($payload) { |
88
|
0
|
0
|
|
|
|
0
|
my ($neighbor, $tail) = $self->SUPER::unpack('a4 a*', $payload) |
89
|
|
|
|
|
|
|
or return undef; |
90
|
0
|
|
|
|
|
0
|
push @neighborList, inetNtoa($neighbor); |
91
|
0
|
|
|
|
|
0
|
$payload = $tail; |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
1
|
|
|
|
|
3
|
$self->neighborList(\@neighborList); |
96
|
|
|
|
|
|
|
|
97
|
1
|
|
|
|
|
10
|
$self->payload($payload); |
98
|
|
|
|
|
|
|
|
99
|
1
|
|
|
|
|
6
|
$self; |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
sub print { |
103
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
104
|
|
|
|
|
|
|
|
105
|
0
|
|
|
|
|
|
my $l = $self->layer; |
106
|
0
|
|
|
|
|
|
my $buf = sprintf |
107
|
|
|
|
|
|
|
"$l: networkMask:%s helloInterval:%d\n". |
108
|
|
|
|
|
|
|
"$l: options:0x%02x routerPri:0x%02x routerDeadInterval:%d\n". |
109
|
|
|
|
|
|
|
"$l: designatedRouter:%s backupDesignatedRouter:%s", |
110
|
|
|
|
|
|
|
$self->networkMask, |
111
|
|
|
|
|
|
|
$self->helloInterval, |
112
|
|
|
|
|
|
|
$self->options, |
113
|
|
|
|
|
|
|
$self->routerPri, |
114
|
|
|
|
|
|
|
$self->routerDeadInterval, |
115
|
|
|
|
|
|
|
$self->designatedRouter, |
116
|
|
|
|
|
|
|
$self->backupDesignatedRouter, |
117
|
|
|
|
|
|
|
; |
118
|
|
|
|
|
|
|
|
119
|
0
|
|
|
|
|
|
for ($self->neighborList) { |
120
|
0
|
|
|
|
|
|
$buf .= "\n$l: neighbor: $_"; |
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
|
123
|
0
|
0
|
|
|
|
|
if ($self->lls) { |
124
|
0
|
|
|
|
|
|
$buf .= "\n".$self->lls->print; |
125
|
|
|
|
|
|
|
} |
126
|
|
|
|
|
|
|
|
127
|
0
|
|
|
|
|
|
$buf; |
128
|
|
|
|
|
|
|
} |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
1; |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
__END__ |