LLTD/Tlv.pm

filter: Statementstmt 87.1% 27 / 31 Branchbran 50.0% 3 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 75.0% 6 / 8 Podpod 100% 5 / 5 totaltotal 82.0% 41 / 50 SCAR 14.1
CC
4
Cov
81%
unpack
3.0
pack
2.0
getLength
2.0
CRAP 4.1
« LLTD.pm ↑ Summary LLTD/EmiteeDesc.pm »
1 #
2 # $Id: Tlv.pm,v 1.2 2007/03/15 18:24:19 gomor Exp $
3 #
4 package Net::Frame::Layer::LLTD::Tlv;
5 10 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 10 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 10 ▶use Net::Frame::Layer qw(:consts :subs);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 10 our @ISA = qw(Net::Frame::Layer);
10  
11 10 our @AS = qw(
12 type
13 length
14 value
15 );
16 10 __PACKAGE__->cgBuildIndices;
17 10 __PACKAGE__->cgBuildAccessorsScalar(\@AS);
18  
19 sub new {
20 shift->SUPER::new(
21 1 ▶ type => 0,
Subroutine new: called CC=1 SCAR=0.0
Pod documented
22 length => 0,
23 value => '',
24 @_,
25 );
26 }
27  
28 0 ▶sub getLength { 2 + shift->length }
Subroutine getLength: not called CC=1 SCAR=6.9
Pod documented
29  
30 sub pack {
31 1 ▶ my $self = shift;
Subroutine pack: called CC=2 SCAR=7.1
Pod documented
32  
33 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 undef 0 1 1
34 $self->type, $self->length, $self->value,
35 )) or return undef;
36  
37 1 $self->raw;
38 }
39  
40 sub unpack {
41 1 ▶ my $self = shift;
Subroutine unpack: called CC=3 SCAR=11.1
Pod documented
42  
43 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 undef 0 1 1
44 or return undef;
45  
46 1 my $bLen = $length;
47 1 ▶ my ($value, $payload) = $self->SUPER::unpack("a$bLen a*", $tail)
Branch: 1 branch
BranchTrueFalseTotal
() = $self->SUPER::unpack("a$bLen a*", $tail) or return undef 0 1 1
48 or return undef;
49  
50 1 $self->type($type);
51 1 $self->length($length);
52 1 $self->value($value);
53  
54 1 $self->payload($payload);
55  
56 1 $self;
57 }
58  
59 sub print {
60 0 ▶ my $self = shift;
Subroutine print: not called CC=1 SCAR=6.9
Pod documented
61  
62 0 my $l = $self->layer;
63 0 sprintf "$l: type:%02x length:%02x value:%s",
64 $self->type, $self->length, CORE::unpack('H*', $self->value);
65 }
66  
67 10 1;
68  
69 __END__
« LLTD.pm ↑ Summary LLTD/EmiteeDesc.pm »