line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# $Id: Record.pm 49 2009-05-31 13:15:34Z VinsWorldcom $ |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
package Net::Frame::Layer::ICMPv6::MLD::Report::Record; |
5
|
4
|
|
|
4
|
|
7583
|
use strict; use warnings; |
|
4
|
|
|
4
|
|
20
|
|
|
4
|
|
|
|
|
137
|
|
|
4
|
|
|
|
|
40
|
|
|
4
|
|
|
|
|
12
|
|
|
4
|
|
|
|
|
173
|
|
6
|
|
|
|
|
|
|
|
7
|
4
|
|
|
4
|
|
484
|
use Net::Frame::Layer qw(:consts :subs); |
|
4
|
|
|
|
|
99454
|
|
|
4
|
|
|
|
|
932
|
|
8
|
4
|
|
|
4
|
|
37
|
use Exporter; |
|
4
|
|
|
|
|
13
|
|
|
4
|
|
|
|
|
599
|
|
9
|
|
|
|
|
|
|
our @ISA = qw(Net::Frame::Layer Exporter); |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( |
12
|
|
|
|
|
|
|
consts => [qw( |
13
|
|
|
|
|
|
|
NF_MLD_REPORTv2TYPE_MODEINCLUDE |
14
|
|
|
|
|
|
|
NF_MLD_REPORTv2TYPE_MODEEXCLUDE |
15
|
|
|
|
|
|
|
NF_MLD_REPORTv2TYPE_CHANGEINCLUDE |
16
|
|
|
|
|
|
|
NF_MLD_REPORTv2TYPE_CHANGEEXCLUDE |
17
|
|
|
|
|
|
|
NF_MLD_REPORTv2TYPE_ALLOWNEW |
18
|
|
|
|
|
|
|
NF_MLD_REPORTv2TYPE_BLOCKOLD |
19
|
|
|
|
|
|
|
)], |
20
|
|
|
|
|
|
|
); |
21
|
|
|
|
|
|
|
our @EXPORT_OK = ( |
22
|
|
|
|
|
|
|
@{$EXPORT_TAGS{consts}}, |
23
|
|
|
|
|
|
|
); |
24
|
|
|
|
|
|
|
|
25
|
4
|
|
|
4
|
|
37
|
use constant NF_MLD_REPORTv2TYPE_MODEINCLUDE => 1; |
|
4
|
|
|
|
|
11
|
|
|
4
|
|
|
|
|
332
|
|
26
|
4
|
|
|
4
|
|
31
|
use constant NF_MLD_REPORTv2TYPE_MODEEXCLUDE => 2; |
|
4
|
|
|
|
|
22
|
|
|
4
|
|
|
|
|
271
|
|
27
|
4
|
|
|
4
|
|
32
|
use constant NF_MLD_REPORTv2TYPE_CHANGEINCLUDE => 3; |
|
4
|
|
|
|
|
12
|
|
|
4
|
|
|
|
|
260
|
|
28
|
4
|
|
|
4
|
|
62
|
use constant NF_MLD_REPORTv2TYPE_CHANGEEXCLUDE => 4; |
|
4
|
|
|
|
|
20
|
|
|
4
|
|
|
|
|
243
|
|
29
|
4
|
|
|
4
|
|
29
|
use constant NF_MLD_REPORTv2TYPE_ALLOWNEW => 5; |
|
4
|
|
|
|
|
13
|
|
|
4
|
|
|
|
|
255
|
|
30
|
4
|
|
|
4
|
|
31
|
use constant NF_MLD_REPORTv2TYPE_BLOCKOLD => 6; |
|
4
|
|
|
|
|
11
|
|
|
4
|
|
|
|
|
4530
|
|
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
our @AS = qw( |
33
|
|
|
|
|
|
|
type |
34
|
|
|
|
|
|
|
auxDataLen |
35
|
|
|
|
|
|
|
numSources |
36
|
|
|
|
|
|
|
multicastAddress |
37
|
|
|
|
|
|
|
auxData |
38
|
|
|
|
|
|
|
); |
39
|
|
|
|
|
|
|
our @AA = qw( |
40
|
|
|
|
|
|
|
sourceAddress |
41
|
|
|
|
|
|
|
); |
42
|
|
|
|
|
|
|
__PACKAGE__->cgBuildIndices; |
43
|
|
|
|
|
|
|
__PACKAGE__->cgBuildAccessorsScalar(\@AS); |
44
|
|
|
|
|
|
|
__PACKAGE__->cgBuildAccessorsArray(\@AA); |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
#no strict 'vars'; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub new { |
49
|
|
|
|
|
|
|
shift->SUPER::new( |
50
|
2
|
|
|
2
|
1
|
327
|
type => NF_MLD_REPORTv2TYPE_MODEINCLUDE, |
51
|
|
|
|
|
|
|
auxDataLen => 0, |
52
|
|
|
|
|
|
|
numSources => 0, |
53
|
|
|
|
|
|
|
multicastAddress => '::', |
54
|
|
|
|
|
|
|
sourceAddress => [], |
55
|
|
|
|
|
|
|
auxData => '', |
56
|
|
|
|
|
|
|
@_, |
57
|
|
|
|
|
|
|
); |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub getLength { |
61
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
62
|
0
|
|
|
|
|
0
|
my $len = 20 + length($self->auxData); |
63
|
0
|
|
|
|
|
0
|
$len += 16 for $self->sourceAddress; |
64
|
0
|
|
|
|
|
0
|
return $len; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub pack { |
68
|
1
|
|
|
1
|
1
|
522
|
my $self = shift; |
69
|
|
|
|
|
|
|
|
70
|
1
|
50
|
|
|
|
7
|
my $raw = $self->SUPER::pack('CCna16', |
71
|
|
|
|
|
|
|
$self->type, |
72
|
|
|
|
|
|
|
$self->auxDataLen, |
73
|
|
|
|
|
|
|
$self->numSources, |
74
|
|
|
|
|
|
|
inet6Aton($self->multicastAddress), |
75
|
|
|
|
|
|
|
) or return; |
76
|
|
|
|
|
|
|
|
77
|
1
|
|
|
|
|
127
|
for ($self->sourceAddress) { |
78
|
0
|
|
|
|
|
0
|
$raw .= inet6Aton($_); |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
1
|
50
|
|
|
|
34
|
if ($self->auxData ne "") { |
82
|
0
|
0
|
|
|
|
0
|
$raw .= $self->SUPER::pack('a*', |
83
|
|
|
|
|
|
|
$self->auxData, |
84
|
|
|
|
|
|
|
) or return; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
1
|
|
|
|
|
26
|
return $self->raw($raw); |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub unpack { |
91
|
1
|
|
|
1
|
1
|
24
|
my $self = shift; |
92
|
|
|
|
|
|
|
|
93
|
1
|
50
|
|
|
|
6
|
my ($type, $auxDataLen, $numSources, $multicastAddress, $payload) = |
94
|
|
|
|
|
|
|
$self->SUPER::unpack('CCna16 a*', $self->raw) |
95
|
|
|
|
|
|
|
or return; |
96
|
|
|
|
|
|
|
|
97
|
1
|
|
|
|
|
54
|
$self->type($type); |
98
|
1
|
|
|
|
|
20
|
$self->auxDataLen($auxDataLen); |
99
|
1
|
|
|
|
|
18
|
$self->numSources($numSources); |
100
|
1
|
|
|
|
|
19
|
$self->multicastAddress(inet6Ntoa($multicastAddress)); |
101
|
|
|
|
|
|
|
|
102
|
1
|
|
|
|
|
27
|
my @sourceAddress = (); |
103
|
1
|
|
|
|
|
8
|
for my $num (0..$numSources-1) { |
104
|
0
|
0
|
0
|
|
|
0
|
if (defined($payload) && (length($payload) >= 16)) { |
105
|
0
|
|
|
|
|
0
|
my $addr = unpack 'a16', $payload; |
106
|
0
|
|
|
|
|
0
|
push @sourceAddress, inet6Ntoa($addr); |
107
|
0
|
|
|
|
|
0
|
$payload = substr $payload, 16; |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
} |
110
|
1
|
|
|
|
|
8
|
$self->sourceAddress(\@sourceAddress); |
111
|
1
|
|
|
|
|
23
|
$self->auxData(""); |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
# auxDataLen is length in 32-bit words so extra math (/4, *4) |
114
|
1
|
0
|
33
|
|
|
18
|
if (($self->auxDataLen > 0) && defined($payload) && ((length($payload)/4) >= $self->auxDataLen)) { |
|
|
|
33
|
|
|
|
|
115
|
0
|
|
|
|
|
0
|
my $auxData = substr $payload, 0, $self->auxDataLen*4; |
116
|
0
|
|
|
|
|
0
|
$self->auxData($auxData); |
117
|
0
|
|
|
|
|
0
|
$payload = substr $payload, $self->auxDataLen*4 |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
|
120
|
1
|
|
|
|
|
27
|
$self->payload($payload); |
121
|
|
|
|
|
|
|
|
122
|
1
|
|
|
|
|
18
|
return $self; |
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
sub encapsulate { |
126
|
1
|
|
|
1
|
1
|
10
|
my $self = shift; |
127
|
|
|
|
|
|
|
|
128
|
1
|
50
|
|
|
|
18
|
return $self->nextLayer if $self->nextLayer; |
129
|
|
|
|
|
|
|
|
130
|
1
|
50
|
|
|
|
24
|
if ($self->payload) { |
131
|
0
|
|
|
|
|
0
|
return 'ICMPv6::MLD::Report::Record'; |
132
|
|
|
|
|
|
|
} |
133
|
|
|
|
|
|
|
|
134
|
1
|
|
|
|
|
21
|
NF_LAYER_NONE; |
135
|
|
|
|
|
|
|
} |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
sub computeLengths { |
138
|
1
|
|
|
1
|
1
|
398
|
my $self = shift; |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
# Calculate auxDataLen if auxData and auxDataLen = 0 |
141
|
1
|
50
|
33
|
|
|
5
|
if (($self->auxData ne "") && ($self->auxDataLen == 0)) { |
142
|
|
|
|
|
|
|
# auxDataLen is number of 32-bit words |
143
|
1
|
50
|
|
|
|
47
|
if (my $mod = (length($self->auxData) * 8) % 32) { |
144
|
1
|
|
|
|
|
22
|
my $pad = (32 - $mod)/8; |
145
|
1
|
|
|
|
|
11
|
my $auxData = $self->auxData; |
146
|
|
|
|
|
|
|
# Add padding if required to make 32-bit flush |
147
|
1
|
|
|
|
|
20
|
$auxData .= "\0"x$pad; |
148
|
1
|
|
|
|
|
4
|
$self->auxData($auxData) |
149
|
|
|
|
|
|
|
} |
150
|
1
|
|
|
|
|
20
|
$self->auxDataLen(length($self->auxData)/4) |
151
|
|
|
|
|
|
|
} |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
# Calculate numSources from sourceAddress array items |
154
|
1
|
50
|
33
|
|
|
32
|
if (scalar($self->sourceAddress) && ($self->numSources == 0)) { |
155
|
1
|
|
|
|
|
43
|
$self->numSources(scalar($self->sourceAddress)) |
156
|
|
|
|
|
|
|
} |
157
|
|
|
|
|
|
|
|
158
|
1
|
|
|
|
|
30
|
return 1; |
159
|
|
|
|
|
|
|
} |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
sub print { |
162
|
3
|
|
|
3
|
1
|
18
|
my $self = shift; |
163
|
|
|
|
|
|
|
|
164
|
3
|
|
|
|
|
18
|
my $l = $self->layer; |
165
|
3
|
|
|
|
|
60
|
my $buf = sprintf |
166
|
|
|
|
|
|
|
"$l: type:%d auxDataLen:%d numSources:%d\n". |
167
|
|
|
|
|
|
|
"$l: multicastAddress:%s", |
168
|
|
|
|
|
|
|
$self->type, $self->auxDataLen, $self->numSources, |
169
|
|
|
|
|
|
|
$self->multicastAddress; |
170
|
|
|
|
|
|
|
|
171
|
3
|
|
|
|
|
201
|
for ($self->sourceAddress) { |
172
|
4
|
|
|
|
|
79
|
$buf .= sprintf |
173
|
|
|
|
|
|
|
"\n$l: sourceAddress:%s", |
174
|
|
|
|
|
|
|
$_ |
175
|
|
|
|
|
|
|
} |
176
|
|
|
|
|
|
|
|
177
|
3
|
50
|
|
|
|
31
|
if ($self->auxData ne "\0") { |
178
|
3
|
|
|
|
|
64
|
$buf .= sprintf |
179
|
|
|
|
|
|
|
"\n$l: auxData:%s", |
180
|
|
|
|
|
|
|
$self->auxData |
181
|
|
|
|
|
|
|
} |
182
|
|
|
|
|
|
|
|
183
|
3
|
|
|
|
|
110
|
return $buf; |
184
|
|
|
|
|
|
|
} |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
1; |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
__END__ |