Packet/PPP.pm

filter: Statementstmt 47.5% 19 / 40 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 30.7% 4 / 13 Podpod 100% 8 / 8 totaltotal 46.2% 31 / 67 CC 4 SCAR 11.8
CC
4
Cov
41%
pack
6.0
unpack
6.0
encapsulate
6.0
CRAP 3.2
« Packet/PPPLCP.pm ↑ Summary Packet/Layer3.pm »
1 #
2 # $Id: PPP.pm 2002 2015-02-15 16:50:35Z gomor $
3 #
4 package Net::Packet::PPP;
5 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 require Net::Packet::Layer2;
9 1 our @ISA = qw(Net::Packet::Layer2);
10  
11 1 ▶use Net::Packet::Consts qw(:ppp :layer);
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 require Bit::Vector;
13  
14 1 our @AS = qw(
15 address
16 control
17 protocol
18 );
19 1 __PACKAGE__->cgBuildIndices;
20 1 __PACKAGE__->cgBuildAccessorsScalar(\@AS);
21  
22 1 ▶no strict 'vars';
Subroutine BEGIN: called CC=1 SCAR=0.0
23  
24 0 ▶sub new {
Subroutine new: not called CC=1 SCAR=6.9
Pod documented
25 shift->SUPER::new(
26 0 address => 0xff,
27 control => 0x03,
28 protocol => NP_PPP_PROTOCOL_IPv4,
29 @_,
30 );
31 }
32  
33 0 ▶sub getLength { NP_PPP_HDR_LEN }
Subroutine getLength: not called CC=1 SCAR=6.9
Pod documented
34  
35 0 ▶sub pack {
Subroutine pack: not called CC=2 SCAR=17.9
Pod documented
36 0 my $self = shift;
37  
38 0 ▶ $self->[$__raw] = $self->SUPER::pack('CCn', $self->[$__address],
Branch: 1 branch
BranchTrueFalseTotal
$self->[$__raw] = $self->SUPER::pack("CCn", $self->[$__address], $self->[$__control], $self->[$__protocol]) or return undef 0 0 0
39 $self->[$__control], $self->[$__protocol])
40 or return undef;
41  
42 0 1;
43 }
44  
45 0 ▶sub unpack {
Subroutine unpack: not called CC=2 SCAR=17.9
Pod documented
46 0 my $self = shift;
47  
48 0 ▶ my ($address, $control, $protocol, $payload) =
Branch: 1 branch
BranchTrueFalseTotal
() = $self->SUPER::unpack("CCn a*", $self->[$__raw]) or return undef 0 0 0
49 $self->SUPER::unpack('CCn a*', $self->[$__raw])
50 or return undef;
51  
52 0 $self->[$__address] = $address;
53 0 $self->[$__control] = $control;
54 0 $self->[$__protocol] = $protocol;
55 0 $self->[$__payload] = $payload;
56  
57 0 1;
58 }
59  
60 0 ▶sub encapsulate {
Subroutine encapsulate: not called CC=2 SCAR=17.9
Pod documented
61 0 my $types = {
62 NP_PPP_PROTOCOL_IPv4() => NP_LAYER_IPv4(),
63 NP_PPP_PROTOCOL_PPPLCP() => NP_LAYER_PPPLCP(),
64 };
65  
66 0 ▶ $types->{shift->[$__protocol]} || NP_LAYER_UNKNOWN();
Branch: 1 branch
BranchTrueFalseTotal
$$types{+(shift())->[$__protocol]} or "UNKNOWN" 0 0 0
67 }
68  
69 0 ▶sub print {
Subroutine print: not called CC=1 SCAR=6.9
Pod documented
70 0 my $self = shift;
71  
72 0 my $l = $self->layer;
73 0 my $i = $self->is;
74 0 sprintf "$l:+$i: address:0x%02x control:0x%02x protocol:0x%04x",
75 $self->[$__address], $self->[$__control], $self->[$__protocol];
76 }
77  
78 #
79 # Helpers
80 #
81  
82 0 ▶sub _isProtocol { shift->[$__protocol] == shift() }
Subroutine _isProtocol: not called CC=1 SCAR=6.9
83 0 ▶sub isProtocolIpv4 { shift->_isProtocol(NP_PPP_PROTOCOL_IPv4) }
Subroutine isProtocolIpv4: not called CC=1 SCAR=6.9
Pod documented
84 0 ▶sub isProtocolPpplcp { shift->_isProtocol(NP_PPP_PROTOCOL_PPPLCP) }
Subroutine isProtocolPpplcp: not called CC=1 SCAR=6.9
Pod documented
85  
86 1 1;
87  
88 __END__
« Packet/PPPLCP.pm ↑ Summary Packet/Layer3.pm »