OSPF/Lls.pm

filter: Statementstmt 85.7% 30 / 35 Branchbran 37.5% 3 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 77.7% 7 / 9 Podpod 100% 5 / 5 totaltotal 78.9% 45 / 57 CC 5 SCAR 9.9
CC
5
Cov
77%
pack
5.5
unpack
2.0
getLength
2.0
CRAP 2.7
« OSPF/Lsa/Router.pm ↑ Summary OSPF/Lsa/Opaque.pm »
1 #
2 # $Id: Lls.pm 73 2015-01-14 06:42:49Z gomor $
3 #
4 package Net::Frame::Layer::OSPF::Lls;
5 15 ▶use strict; use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 15 ▶use Net::Frame::Layer qw(:consts :subs);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 15 our @ISA = qw(Net::Frame::Layer);
9  
10 15 our @AS = qw(
11 checksum
12 dataLength
13 rawTlv
14 );
15 15 our @AA = qw(
16 tlvList
17 );
18 15 __PACKAGE__->cgBuildIndices;
19 15 __PACKAGE__->cgBuildAccessorsScalar(\@AS);
20 15 __PACKAGE__->cgBuildAccessorsScalar(\@AA);
21  
22 15 ▶use Net::Frame::Layer::OSPF qw(:consts);
Subroutine BEGIN: called CC=1 SCAR=0.0
23  
24 1 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod documented
25 shift->SUPER::new(
26 1 checksum => 0,
27 dataLength => 0,
28 tlvList => [],
29 @_,
30 );
31 }
32  
33 0 ▶sub getLength {
Subroutine getLength: not called CC=1 SCAR=6.9
Pod documented
34 #my $self = shift;
35 #my $len = 4;
36 #if ($self->rawTlv) {
37 #$len += length($self->rawTlv);
38 #}
39 #print "TLV LEN: $len\n";
40 #$len;
41 0 0;
42 }
43  
44 1 ▶sub pack {
Subroutine pack: called CC=4 SCAR=17.1
Pod documented
45 1 my $self = shift;
46  
47 1 ▶ my $raw = $self->SUPER::pack('nn', $self->checksum, $self->dataLength)
Branch: 1 branch
BranchTrueFalseTotal
my $raw = $self->SUPER::pack("nn", $self->checksum, $self->dataLength) or return undef 1 0 1
48 or return undef;
49  
50 1 ▶ if ($self->rawTlv) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->rawTlv) 0 1 1
51 0 ▶ $raw .= $self->SUPER::pack('a*', $self->rawTlv)
Branch: 1 branch
BranchTrueFalseTotal
$raw .= $self->SUPER::pack("a*", $self->rawTlv) or return undef 0 0 0
52 or return undef;
53 }
54  
55 1 $self->raw($raw);
56 }
57  
58 1 ▶sub unpack {
Subroutine unpack: called CC=2 SCAR=7.0
Pod documented
59 1 my $self = shift;
60  
61 1 ▶ my ($checksum, $dataLength, $payload) =
Branch: 1 branch
BranchTrueFalseTotal
() = $self->SUPER::unpack("nn a*", $self->raw) or return undef 1 0 1
62 $self->SUPER::unpack('nn a*', $self->raw)
63 or return undef;
64  
65 1 $self->checksum($checksum);
66 1 $self->dataLength($dataLength);
67  
68 # XXX: handle TLV
69 1 $self->rawTlv($payload);
70  
71 #$self->payload($payload);
72  
73 1 $self;
74 }
75  
76 0 ▶sub print {
Subroutine print: not called CC=1 SCAR=6.9
Pod documented
77 0 my $self = shift;
78  
79 0 my $l = $self->layer;
80 0 sprintf
81 "$l: checksum:0x%04x dataLength:%d\n".
82 "$l: rawTlv:%s",
83 $self->checksum,
84 $self->dataLength,
85 CORE::unpack('H*', $self->rawTlv),
86 ;
87 }
88  
89 15 1;
90  
91 __END__
« OSPF/Lsa/Router.pm ↑ Summary OSPF/Lsa/Opaque.pm »