ICMPv6/Option.pm

filter: Statementstmt 83.3% 30 / 36 Branchbran 50.0% 4 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 77.7% 7 / 9 Podpod 100% 5 / 5 totaltotal 79.3% 46 / 58 CC 5 SCAR 8.4
CC
5
Cov
77%
unpack
4.2
pack
2.0
getLength
2.0
CRAP 2.3
« ICMPv6/RouterAdvertisement.pm ↑ Summary ICMPv6/Echo.pm »
1 #
2 # $Id: Option.pm,v b9194b248a66 2017/10/06 16:26:50 gomor $
3 #
4 package Net::Frame::Layer::ICMPv6::Option;
5 3 ▶use strict; use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 3 ▶use Net::Frame::Layer qw(:consts :subs);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 3 our @ISA = qw(Net::Frame::Layer);
9  
10 3 our @AS = qw(
11 type
12 length
13 value
14 );
15 3 __PACKAGE__->cgBuildIndices;
16 3 __PACKAGE__->cgBuildAccessorsScalar(\@AS);
17  
18 3 ▶use Net::Frame::Layer::ICMPv6 qw(:consts);
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20 sub new {
21 shift->SUPER::new(
22 1 ▶ type => 0,
Subroutine new: called CC=1 SCAR=0.0
Pod documented
23 length => 0,
24 value => '',
25 @_,
26 );
27 }
28  
29 sub getLength {
30 0 ▶ my $self = shift;
Subroutine getLength: not called CC=1 SCAR=6.9
Pod documented
31  
32 0 return length($self->value) + 2;
33 }
34  
35 sub pack {
36 1 ▶ my $self = shift;
Subroutine pack: called CC=2 SCAR=7.1
Pod documented
37  
38 1 ▶ $self->raw($self->SUPER::pack('CCa*',
Branch: 1 branch
BranchTrueFalseTotal
$self->raw($self->SUPER::pack("CCa*", $self->type, $self->length, $self->value)) or return 0 1 1
39 $self->type, $self->length, $self->value,
40 )) or return;
41  
42 1 return $self->raw;
43 }
44  
45 sub unpack {
46 1 ▶ my $self = shift;
Subroutine unpack: called CC=4 SCAR=14.5
Pod documented
47  
48 1 ▶ my ($type, $length, $tail) = $self->SUPER::unpack('CC a*', $self->raw)
Branch: 1 branch
BranchTrueFalseTotal
() = $self->SUPER::unpack("CC a*", $self->raw) or return 0 1 1
49 or return;
50  
51 1 $self->type($type);
52 1 $self->length($length);
53  
54 # Dirty hack. Some systems does not set the length correctly
55 1 ▶ if ($type == NF_ICMPv6_OPTION_TARGETLINKLAYERADDRESS) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type == 2) 0 1 1
56 0 $length = 6;
57 }
58  
59 1 ▶ my ($value, $payload) = $self->SUPER::unpack("a$length a*", $tail)
Branch: 1 branch
BranchTrueFalseTotal
() = $self->SUPER::unpack("a$length a*", $tail) or return 0 1 1
60 or return;
61  
62 1 $self->value($value);
63 1 $self->payload($payload);
64  
65 1 return $self;
66 }
67  
68 sub print {
69 0 ▶ my $self = shift;
Subroutine print: not called CC=1 SCAR=6.9
Pod documented
70  
71 0 my $l = $self->layer;
72 0 sprintf "$l: type:%02x length:%02x value:%s",
73 $self->type, $self->length, CORE::unpack('H*', $self->value);
74 }
75  
76 3 1;
77  
78 __END__
« ICMPv6/RouterAdvertisement.pm ↑ Summary ICMPv6/Echo.pm »