| 1 | # | ||||||||||||||||||||||||||||||||||||||||||
| 2 | # $Id: v3Report.pm 49 2009-05-31 13:15:34Z VinsWorldcom $ | ||||||||||||||||||||||||||||||||||||||||||
| 3 | # | ||||||||||||||||||||||||||||||||||||||||||
| 4 | package Net::Frame::Layer::IGMP::v3Report; | ||||||||||||||||||||||||||||||||||||||||||
| 5 | 7 | ▶ | use strict; use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||
| 7 | 7 | ▶ | use Net::Frame::Layer qw(:consts :subs); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 7 | ▶ | use Exporter; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 7 | our @ISA = qw(Net::Frame::Layer Exporter); | |||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||
| 11 | 7 | our %EXPORT_TAGS = ( | |||||||||||||||||||||||||||||||||||||||||
| 12 | consts => [qw( | ||||||||||||||||||||||||||||||||||||||||||
| 13 | NF_IGMP_REPORTv3TYPE_MODEINCLUDE | ||||||||||||||||||||||||||||||||||||||||||
| 14 | NF_IGMP_REPORTv3TYPE_MODEEXCLUDE | ||||||||||||||||||||||||||||||||||||||||||
| 15 | NF_IGMP_REPORTv3TYPE_CHANGEINCLUDE | ||||||||||||||||||||||||||||||||||||||||||
| 16 | NF_IGMP_REPORTv3TYPE_CHANGEEXCLUDE | ||||||||||||||||||||||||||||||||||||||||||
| 17 | NF_IGMP_REPORTv3TYPE_ALLOWNEW | ||||||||||||||||||||||||||||||||||||||||||
| 18 | NF_IGMP_REPORTv3TYPE_BLOCKOLD | ||||||||||||||||||||||||||||||||||||||||||
| 19 | )], | ||||||||||||||||||||||||||||||||||||||||||
| 20 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 21 | our @EXPORT_OK = ( | ||||||||||||||||||||||||||||||||||||||||||
| 22 | 7 | @{$EXPORT_TAGS{consts}}, | |||||||||||||||||||||||||||||||||||||||||
| 23 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||
| 25 | 7 | ▶ | use constant NF_IGMP_REPORTv3TYPE_MODEINCLUDE => 1; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 26 | 7 | ▶ | use constant NF_IGMP_REPORTv3TYPE_MODEEXCLUDE => 2; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 27 | 7 | ▶ | use constant NF_IGMP_REPORTv3TYPE_CHANGEINCLUDE => 3; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 28 | 7 | ▶ | use constant NF_IGMP_REPORTv3TYPE_CHANGEEXCLUDE => 4; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 29 | 7 | ▶ | use constant NF_IGMP_REPORTv3TYPE_ALLOWNEW => 5; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 30 | 7 | ▶ | use constant NF_IGMP_REPORTv3TYPE_BLOCKOLD => 6; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||
| 32 | 7 | our @AS = qw( | |||||||||||||||||||||||||||||||||||||||||
| 33 | type | ||||||||||||||||||||||||||||||||||||||||||
| 34 | auxDataLen | ||||||||||||||||||||||||||||||||||||||||||
| 35 | numSources | ||||||||||||||||||||||||||||||||||||||||||
| 36 | multicastAddress | ||||||||||||||||||||||||||||||||||||||||||
| 37 | auxData | ||||||||||||||||||||||||||||||||||||||||||
| 38 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 39 | 7 | our @AA = qw( | |||||||||||||||||||||||||||||||||||||||||
| 40 | sourceAddress | ||||||||||||||||||||||||||||||||||||||||||
| 41 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 42 | 7 | __PACKAGE__->cgBuildIndices; | |||||||||||||||||||||||||||||||||||||||||
| 43 | 7 | __PACKAGE__->cgBuildAccessorsScalar(\@AS); | |||||||||||||||||||||||||||||||||||||||||
| 44 | 7 | __PACKAGE__->cgBuildAccessorsArray(\@AA); | |||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||
| 46 | #no strict 'vars'; | ||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||
| 48 | 3 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 49 | shift->SUPER::new( | ||||||||||||||||||||||||||||||||||||||||||
| 50 | 3 | type => NF_IGMP_REPORTv3TYPE_MODEINCLUDE, | |||||||||||||||||||||||||||||||||||||||||
| 51 | auxDataLen => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 52 | numSources => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 53 | multicastAddress => '0.0.0.0', | ||||||||||||||||||||||||||||||||||||||||||
| 54 | sourceAddress => [], | ||||||||||||||||||||||||||||||||||||||||||
| 55 | auxData => '', | ||||||||||||||||||||||||||||||||||||||||||
| 56 | @_, | ||||||||||||||||||||||||||||||||||||||||||
| 57 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | ▶ | sub getLength { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getLength: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | my $len = 8 + length($self->auxData); | |||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | $len += 4 for $self->sourceAddress; | |||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | return $len; | |||||||||||||||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||
| 67 | 1 | ▶ | sub pack { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pack: called CC=5 SCAR=20.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 68 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||
| 70 | 1 | ▶ | my $raw = $self->SUPER::pack('CCna4', | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 71 | $self->type, | ||||||||||||||||||||||||||||||||||||||||||
| 72 | $self->auxDataLen, | ||||||||||||||||||||||||||||||||||||||||||
| 73 | $self->numSources, | ||||||||||||||||||||||||||||||||||||||||||
| 74 | inetAton($self->multicastAddress), | ||||||||||||||||||||||||||||||||||||||||||
| 75 | ) or return; | ||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||
| 77 | 1 | for ($self->sourceAddress) { | |||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | $raw .= inetAton($_); | |||||||||||||||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||
| 81 | 1 | ▶ | if ($self->auxData ne "") { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | ▶ | $raw .= $self->SUPER::pack('a*', | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 83 | $self->auxData, | ||||||||||||||||||||||||||||||||||||||||||
| 84 | ) or return; | ||||||||||||||||||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||
| 87 | 1 | return $self->raw($raw); | |||||||||||||||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||
| 90 | 1 | ▶ | sub unpack { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
unpack: called CC=8 SCAR=28.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 91 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||
| 93 | 1 | ▶ | my ($type, $auxDataLen, $numSources, $multicastAddress, $payload) = | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 94 | $self->SUPER::unpack('CCna4 a*', $self->raw) | ||||||||||||||||||||||||||||||||||||||||||
| 95 | or return; | ||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||
| 97 | 1 | $self->type($type); | |||||||||||||||||||||||||||||||||||||||||
| 98 | 1 | $self->auxDataLen($auxDataLen); | |||||||||||||||||||||||||||||||||||||||||
| 99 | 1 | $self->numSources($numSources); | |||||||||||||||||||||||||||||||||||||||||
| 100 | 1 | $self->multicastAddress(inetNtoa($multicastAddress)); | |||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||
| 102 | 1 | my @sourceAddress = (); | |||||||||||||||||||||||||||||||||||||||||
| 103 | 1 | for my $num (0..$numSources-1) { | |||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | ▶ | if (defined($payload) && (length($payload) >= 4)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $payload and length $payload >= 4
MC/DC0%0/2
defined $payload and length $payload >= 4
defined $payload
length $payload >= 4
Truth table0%0/3
A and B
A= defined $payloadB= length $payload >= 4
| |||||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | my $addr = unpack 'a4', $payload; | |||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | push @sourceAddress, inetNtoa($addr); | |||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | $payload = substr $payload, 4; | |||||||||||||||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||||||||||||||||
| 110 | 1 | $self->sourceAddress(\@sourceAddress); | |||||||||||||||||||||||||||||||||||||||||
| 111 | 1 | $self->auxData(""); | |||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||
| 113 | # auxDataLen is length in 32-bit words so extra math (/4, *4) | ||||||||||||||||||||||||||||||||||||||||||
| 114 | 1 | ▶ | if (($self->auxDataLen > 0) && defined($payload) && ((length($payload)/4) >= $self->auxDataLen)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$self->auxDataLen > 0 and defined $payload and length($payload) / 4 >= $self->auxDataLen
$self->auxDataLen > 0 and defined $payload
MC/DC0%0/3
$self->auxDataLen > 0 and defined $payload and length($payload) / 4 >= $self->auxDataLen
$self->auxDataLen > 0
defined $payload
length($payload) / 4 >= $self->auxDataLen
Truth table25%1/4
A and B and C
A= $self->auxDataLen > 0B= defined $payloadC= length($payload) / 4 >= $self->auxDataLen
| |||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | my $auxData = substr $payload, 0, $self->auxDataLen*4; | |||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | $self->auxData($auxData); | |||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | $payload = substr $payload, $self->auxDataLen*4 | |||||||||||||||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||
| 120 | 1 | $self->payload($payload); | |||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||
| 122 | 1 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||
| 125 | 1 | ▶ | sub encapsulate { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
encapsulate: called CC=3 SCAR=12.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 126 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||||
| 128 | 1 | ▶ | return $self->nextLayer if $self->nextLayer; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||
| 130 | 1 | ▶ | if ($self->payload) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | return 'IGMP::v3Report'; | |||||||||||||||||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||
| 134 | 1 | NF_LAYER_NONE; | |||||||||||||||||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||
| 137 | 2 | ▶ | sub computeLengths { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
computeLengths: called CC=6 SCAR=18.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 138 | 2 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||
| 140 | # Calculate auxDataLen if auxData and auxDataLen = 0 | ||||||||||||||||||||||||||||||||||||||||||
| 141 | 2 | ▶ | if (($self->auxData ne "") && ($self->auxDataLen == 0)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$self->auxData ne "" and $self->auxDataLen == 0
MC/DC50%1/2
$self->auxData ne "" and $self->auxDataLen == 0
$self->auxData ne ""
$self->auxDataLen == 0
Truth table66%2/3
A and B
A= $self->auxData ne ""B= $self->auxDataLen == 0
| |||||||||||||||||||||||||||||||||||||||||||
| 142 | # auxDataLen is number of 32-bit words | ||||||||||||||||||||||||||||||||||||||||||
| 143 | 1 | ▶ | if (my $mod = (length($self->auxData) * 8) % 32) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 144 | 1 | my $pad = (32 - $mod)/8; | |||||||||||||||||||||||||||||||||||||||||
| 145 | 1 | my $auxData = $self->auxData; | |||||||||||||||||||||||||||||||||||||||||
| 146 | # Add padding if required to make 32-bit flush | ||||||||||||||||||||||||||||||||||||||||||
| 147 | 1 | $auxData .= "\0"x$pad; | |||||||||||||||||||||||||||||||||||||||||
| 148 | 1 | $self->auxData($auxData) | |||||||||||||||||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||||||||||||||||
| 150 | 1 | $self->auxDataLen(length($self->auxData)/4) | |||||||||||||||||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||||
| 153 | # Calculate numSources from sourceAddress array items | ||||||||||||||||||||||||||||||||||||||||||
| 154 | 2 | ▶ | if (scalar($self->sourceAddress) && ($self->numSources == 0)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
scalar $self->sourceAddress and $self->numSources == 0
MC/DC50%1/2
scalar $self->sourceAddress and $self->numSources == 0
scalar $self->sourceAddress
$self->numSources == 0
Truth table66%2/3
A and B
A= scalar $self->sourceAddressB= $self->numSources == 0
| |||||||||||||||||||||||||||||||||||||||||||
| 155 | 1 | $self->numSources(scalar($self->sourceAddress)) | |||||||||||||||||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||
| 158 | 2 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||
| 161 | 5 | ▶ | sub print { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
print: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 162 | 5 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||
| 164 | 5 | my $l = $self->layer; | |||||||||||||||||||||||||||||||||||||||||
| 165 | 5 | 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 | 5 | for ($self->sourceAddress) { | |||||||||||||||||||||||||||||||||||||||||
| 172 | 4 | $buf .= sprintf | |||||||||||||||||||||||||||||||||||||||||
| 173 | "\n$l: sourceAddress:%s", | ||||||||||||||||||||||||||||||||||||||||||
| 174 | $_ | ||||||||||||||||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||
| 177 | 5 | ▶ | if ($self->auxData ne "") { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 178 | 2 | $buf .= sprintf | |||||||||||||||||||||||||||||||||||||||||
| 179 | "\n$l: auxData:%s", | ||||||||||||||||||||||||||||||||||||||||||
| 180 | $self->auxData | ||||||||||||||||||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||||||||||||
| 183 | 5 | return $buf; | |||||||||||||||||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||||||||||
| 186 | 7 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||
| 188 | __END__ | ||||||||||||||||||||||||||||||||||||||||||