line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# $Id: ManagementAddresses.pm 1640 2013-03-28 17:58:27Z VinsWorldcom $ |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
package Net::Frame::Layer::CDP::ManagementAddresses; |
5
|
19
|
|
|
19
|
|
6866
|
use strict; use warnings; |
|
19
|
|
|
19
|
|
37
|
|
|
19
|
|
|
|
|
608
|
|
|
19
|
|
|
|
|
94
|
|
|
19
|
|
|
|
|
37
|
|
|
19
|
|
|
|
|
524
|
|
6
|
|
|
|
|
|
|
|
7
|
19
|
|
|
19
|
|
837
|
use Net::Frame::Layer qw(:consts :subs); |
|
19
|
|
|
|
|
73581
|
|
|
19
|
|
|
|
|
5903
|
|
8
|
|
|
|
|
|
|
our @ISA = qw(Net::Frame::Layer); |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our @AS = qw( |
11
|
|
|
|
|
|
|
type |
12
|
|
|
|
|
|
|
length |
13
|
|
|
|
|
|
|
numAddresses |
14
|
|
|
|
|
|
|
); |
15
|
|
|
|
|
|
|
our @AA = qw( |
16
|
|
|
|
|
|
|
addresses |
17
|
|
|
|
|
|
|
); |
18
|
|
|
|
|
|
|
__PACKAGE__->cgBuildIndices; |
19
|
|
|
|
|
|
|
__PACKAGE__->cgBuildAccessorsScalar(\@AS); |
20
|
|
|
|
|
|
|
__PACKAGE__->cgBuildAccessorsArray (\@AA); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
#no strict 'vars'; |
23
|
|
|
|
|
|
|
|
24
|
19
|
|
|
19
|
|
692
|
use Net::Frame::Layer::CDP::Constants qw(:consts); |
|
19
|
|
|
|
|
37
|
|
|
19
|
|
|
|
|
17310
|
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub new { |
27
|
|
|
|
|
|
|
shift->SUPER::new( |
28
|
2
|
|
|
2
|
1
|
238
|
type => NF_CDP_TYPE_MANAGEMENT_ADDR, |
29
|
|
|
|
|
|
|
length => 8, |
30
|
|
|
|
|
|
|
numAddresses => 0, |
31
|
|
|
|
|
|
|
addresses => [], |
32
|
|
|
|
|
|
|
@_, |
33
|
|
|
|
|
|
|
); |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub getLength { |
37
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
38
|
|
|
|
|
|
|
|
39
|
0
|
|
|
|
|
0
|
my $length = 8; |
40
|
0
|
|
|
|
|
0
|
$length += $_->getLength for $self->addresses; |
41
|
|
|
|
|
|
|
|
42
|
0
|
|
|
|
|
0
|
return $length |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub pack { |
46
|
1
|
|
|
1
|
1
|
241
|
my $self = shift; |
47
|
|
|
|
|
|
|
|
48
|
1
|
50
|
|
|
|
6
|
my $raw = $self->SUPER::pack('nnN', |
49
|
|
|
|
|
|
|
$self->type, |
50
|
|
|
|
|
|
|
$self->length, |
51
|
|
|
|
|
|
|
$self->numAddresses |
52
|
|
|
|
|
|
|
) or return; |
53
|
|
|
|
|
|
|
|
54
|
1
|
|
|
|
|
56
|
for ($self->addresses) { |
55
|
0
|
|
|
|
|
0
|
$raw .= $_->pack; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
1
|
|
|
|
|
22
|
return $self->raw($raw); |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub _unpackAddresses { |
62
|
1
|
|
|
1
|
|
2
|
my $self = shift; |
63
|
1
|
|
|
|
|
2
|
my ($payload) = @_; |
64
|
|
|
|
|
|
|
|
65
|
1
|
|
|
|
|
2
|
my @addressesList; |
66
|
1
|
|
33
|
|
|
8
|
while (defined($payload) && length($payload)) { |
67
|
0
|
|
|
|
|
0
|
my $addr = Net::Frame::Layer::CDP::Address->new(raw => $payload)->unpack; |
68
|
0
|
|
|
|
|
0
|
push @addressesList, $addr; |
69
|
0
|
|
|
|
|
0
|
$payload = $addr->payload; |
70
|
0
|
|
|
|
|
0
|
$addr->payload(undef); |
71
|
|
|
|
|
|
|
} |
72
|
1
|
|
|
|
|
3
|
$self->addresses(\@addressesList); |
73
|
1
|
|
|
|
|
10
|
return $payload; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub unpack { |
77
|
1
|
|
|
1
|
1
|
12
|
my $self = shift; |
78
|
|
|
|
|
|
|
|
79
|
1
|
50
|
|
|
|
4
|
my ($type, $length, $numAddresses, $tail) = |
80
|
|
|
|
|
|
|
$self->SUPER::unpack('nnN a*', $self->raw) |
81
|
|
|
|
|
|
|
or return; |
82
|
|
|
|
|
|
|
|
83
|
1
|
|
|
|
|
27
|
$self->type($type); |
84
|
1
|
|
|
|
|
10
|
$self->length($length); |
85
|
1
|
|
|
|
|
9
|
$self->numAddresses($numAddresses); |
86
|
|
|
|
|
|
|
|
87
|
1
|
|
|
|
|
8
|
my $valLen = $length - 8; # 4 + TLValue(4) then addresses array |
88
|
1
|
50
|
|
|
|
5
|
my ($addresses, $payload) = |
89
|
|
|
|
|
|
|
$self->SUPER::unpack("a$valLen a*", $tail) |
90
|
|
|
|
|
|
|
or return; |
91
|
|
|
|
|
|
|
|
92
|
1
|
|
|
|
|
13
|
$self->_unpackAddresses($addresses); |
93
|
|
|
|
|
|
|
|
94
|
1
|
|
|
|
|
6
|
$self->payload($payload); |
95
|
|
|
|
|
|
|
|
96
|
1
|
|
|
|
|
9
|
return $self; |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
sub computeLengths { |
100
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
101
|
|
|
|
|
|
|
|
102
|
0
|
|
|
|
|
0
|
my $length = 8; |
103
|
0
|
|
|
|
|
0
|
$length += $_->getLength for $self->addresses; |
104
|
0
|
|
|
|
|
0
|
$self->length($length); |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
# Calculate numAddresses from addresses array items |
107
|
0
|
0
|
0
|
|
|
0
|
if (scalar($self->addresses) && ($self->numAddresses == 0)) { |
108
|
0
|
|
|
|
|
0
|
$self->numAddresses(scalar($self->addresses)) |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
|
111
|
0
|
|
|
|
|
0
|
return 1; |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
sub print { |
115
|
3
|
|
|
3
|
1
|
13
|
my $self = shift; |
116
|
|
|
|
|
|
|
|
117
|
3
|
|
|
|
|
21
|
my $l = $self->layer; |
118
|
3
|
|
|
|
|
31
|
my $buf = sprintf |
119
|
|
|
|
|
|
|
"$l: type:0x%04x length:%d numAddresses:%d", |
120
|
|
|
|
|
|
|
$self->type, $self->length, $self->numAddresses; |
121
|
|
|
|
|
|
|
|
122
|
3
|
|
|
|
|
80
|
for ($self->addresses) { |
123
|
4
|
|
|
|
|
29
|
$buf .= "\n" . $_->print; |
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
|
126
|
3
|
|
|
|
|
583
|
return $buf; |
127
|
|
|
|
|
|
|
} |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
1; |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
__END__ |