blib/lib/Net/Frame/Layer/PPPLCP.pm

filter: Statementstmt 86.9% 40 / 46 Branchbran 50.0% 2 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 69.2% 9 / 13 Podpod 100% 7 / 7 totaltotal 82.8% 58 / 70 CC 3 SCAR 4.3
CC
3
Cov
84%
pack
2.0
unpack
2.0
getLength
2.0
CRAP 1.5
↑ Summary
1 #
2 # $Id: PPPLCP.pm,v 1.1 2007/04/01 17:14:36 gomor Exp $
3 #
4 package Net::Frame::Layer::PPPLCP;
5 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 3 our $VERSION = '1.00';
9  
10 3 ▶use Net::Frame::Layer qw(:consts);
Subroutine BEGIN: called CC=1 SCAR=0.0
11 3 require Exporter;
12 3 our @ISA = qw(Net::Frame::Layer Exporter);
13  
14 3 our %EXPORT_TAGS = (
15 consts => [qw(
16 NF_PPPLCP_HDR_LEN
17 NF_PPPLCP_CODE_ECHO_REQUEST
18 NF_PPPLCP_CODE_ECHO_REPLY
19 )],
20 );
21 our @EXPORT_OK = (
22 3 @{$EXPORT_TAGS{consts}},
23 );
24  
25 3 ▶use constant NF_PPPLCP_HDR_LEN => 8;
Subroutine BEGIN: called CC=1 SCAR=0.0
26 3 ▶use constant NF_PPPLCP_CODE_ECHO_REQUEST => 0x09;
Subroutine BEGIN: called CC=1 SCAR=0.0
27 3 ▶use constant NF_PPPLCP_CODE_ECHO_REPLY => 0x0a;
Subroutine BEGIN: called CC=1 SCAR=0.0
28  
29 3 our @AS = qw(
30 code
31 identifier
32 length
33 magicNumber
34 );
35 3 __PACKAGE__->cgBuildIndices;
36 3 __PACKAGE__->cgBuildAccessorsScalar(\@AS);
37  
38 sub new {
39 shift->SUPER::new(
40 1 ▶ code => NF_PPPLCP_CODE_ECHO_REQUEST,
Subroutine new: called CC=1 SCAR=0.0
Pod documented
41 identifier => 1,
42 length => NF_PPPLCP_HDR_LEN,
43 magicNumber => 0xffffffff,
44 @_,
45 );
46 }
47  
48 0 ▶sub getLength { shift->length }
Subroutine getLength: not called CC=1 SCAR=6.9
Pod documented
49  
50 0 ▶sub getPayloadLength { shift->getLength - NF_PPPLCP_HDR_LEN }
Subroutine getPayloadLength: not called CC=1 SCAR=6.9
Pod documented
51  
52 sub pack {
53 1 ▶ my $self = shift;
Subroutine pack: called CC=2 SCAR=7.1
Pod documented
54  
55 1 ▶ $self->raw($self->SUPER::pack('CCnN',
Branch: 1 branch
BranchTrueFalseTotal
$self->raw($self->SUPER::pack("CCnN", $self->code, $self->identifier, $self->length, $self->magicNumber)) or return undef 0 1 1
56 $self->code,
57 $self->identifier,
58 $self->length,
59 $self->magicNumber,
60 )) or return undef;
61  
62 1 $self->raw;
63 }
64  
65 sub unpack {
66 1 ▶ my $self = shift;
Subroutine unpack: called CC=2 SCAR=7.0
Pod documented
67  
68 1 ▶ my ($code, $identifier, $length, $magicNumber, $payload) =
Branch: 1 branch
BranchTrueFalseTotal
() = $self->SUPER::unpack("CCnN a*", $self->raw) or return undef 0 1 1
69 $self->SUPER::unpack('CCnN a*', $self->raw)
70 or return undef;
71  
72 1 $self->code($code);
73 1 $self->identifier($identifier);
74 1 $self->length($length);
75 1 $self->magicNumber($magicNumber);
76  
77 1 $self->payload($payload);
78  
79 1 $self;
80 }
81  
82 0 ▶sub encapsulate { shift->nextLayer }
Subroutine encapsulate: not called CC=1 SCAR=6.9
Pod documented
83  
84 sub print {
85 0 ▶ my $self = shift;
Subroutine print: not called CC=1 SCAR=6.9
Pod documented
86  
87 0 my $l = $self->layer;
88 0 sprintf "$l: code:0x%02x identifier:0x%02x length:%d magicNumber:0x%04x",
89 $self->code,
90 $self->identifier,
91 $self->length,
92 $self->magicNumber,
93 ;
94 }
95  
96 3 1;
97  
98 __END__
↑ Summary