Frame/Layer/PPP.pm

filter: Statementstmt 98.3% 60 / 61 Branchbran 50.0% 3 / 6 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 94.1% 16 / 17 Podpod 100% 6 / 6 totaltotal 92.4% 86 / 93 CC 5 SCAR 4.4
CC
5
Cov
93%
encapsulate
3.2
pack
2.0
unpack
2.0
CRAP 1.6
« Frame/Layer/ETH.pm ↑ Summary Frame/Layer/NULL.pm »
1 #
2 # $Id: PPP.pm,v ce68fbcc7f6d 2019/05/23 05:58:40 gomor $
3 #
4 package Net::Frame::Layer::PPP;
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 ▶use Net::Frame::Layer qw(:consts);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 3 require Exporter;
10 3 our @ISA = qw(Net::Frame::Layer Exporter);
11  
12 3 our %EXPORT_TAGS = (
13 consts => [qw(
14 NF_PPP_HDR_LEN
15 NF_PPP_PROTOCOL_IPv4
16 NF_PPP_PROTOCOL_DDP
17 NF_PPP_PROTOCOL_IPX
18 NF_PPP_PROTOCOL_IPv6
19 NF_PPP_PROTOCOL_CDP
20 NF_PPP_PROTOCOL_PPPLCP
21 )],
22 );
23 our @EXPORT_OK = (
24 3 @{$EXPORT_TAGS{consts}},
25 );
26  
27 3 ▶use constant NF_PPP_HDR_LEN => 4;
Subroutine BEGIN: called CC=1 SCAR=0.0
28 3 ▶use constant NF_PPP_PROTOCOL_IPv4 => 0x0021;
Subroutine BEGIN: called CC=1 SCAR=0.0
29 3 ▶use constant NF_PPP_PROTOCOL_DDP => 0x0029;
Subroutine BEGIN: called CC=1 SCAR=0.0
30 3 ▶use constant NF_PPP_PROTOCOL_IPX => 0x002b;
Subroutine BEGIN: called CC=1 SCAR=0.0
31 3 ▶use constant NF_PPP_PROTOCOL_IPv6 => 0x0057;
Subroutine BEGIN: called CC=1 SCAR=0.0
32 3 ▶use constant NF_PPP_PROTOCOL_CDP => 0x0207;
Subroutine BEGIN: called CC=1 SCAR=0.0
33 3 ▶use constant NF_PPP_PROTOCOL_PPPLCP => 0xc021;
Subroutine BEGIN: called CC=1 SCAR=0.0
34  
35 3 our @AS = qw(
36 address
37 control
38 protocol
39 );
40 3 __PACKAGE__->cgBuildIndices;
41 3 __PACKAGE__->cgBuildAccessorsScalar(\@AS);
42  
43 3 ▶no strict 'vars';
Subroutine BEGIN: called CC=1 SCAR=0.0
44  
45 1 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod documented
46 shift->SUPER::new(
47 1 address => 0xff,
48 control => 0x03,
49 protocol => NF_PPP_PROTOCOL_IPv4,
50 @_,
51 );
52 }
53  
54 0 ▶sub getLength { NF_PPP_HDR_LEN }
Subroutine getLength: not called CC=1 SCAR=6.9
Pod documented
55  
56 1 ▶sub pack {
Subroutine pack: called CC=2 SCAR=7.1
Pod documented
57 1 my $self = shift;
58  
59 1 ▶ $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 1 0 1
60 $self->[$__control], $self->[$__protocol])
61 or return undef;
62  
63 1 $self->[$__raw];
64 }
65  
66 1 ▶sub unpack {
Subroutine unpack: called CC=2 SCAR=7.0
Pod documented
67 1 my $self = shift;
68  
69 1 ▶ my ($address, $control, $protocol, $payload) =
Branch: 1 branch
BranchTrueFalseTotal
() = $self->SUPER::unpack("CCn a*", $self->[$__raw]) or return undef 1 0 1
70 $self->SUPER::unpack('CCn a*', $self->[$__raw])
71 or return undef;
72  
73 1 $self->[$__address] = $address;
74 1 $self->[$__control] = $control;
75 1 $self->[$__protocol] = $protocol;
76 1 $self->[$__payload] = $payload;
77  
78 1 $self;
79 }
80  
81 3 our $Next = {
82 NF_PPP_PROTOCOL_IPv4() => 'IPv4',
83 NF_PPP_PROTOCOL_DDP() => 'DDP',
84 NF_PPP_PROTOCOL_IPX() => 'IPX',
85 NF_PPP_PROTOCOL_IPv6() => 'IPv6',
86 NF_PPP_PROTOCOL_CDP() => 'CDP',
87 NF_PPP_PROTOCOL_PPPLCP() => 'PPPLCP',
88 };
89  
90 1 ▶sub encapsulate {
Subroutine encapsulate: called CC=3 SCAR=11.7
Pod documented
91 1 my $self = shift;
92  
93 1 ▶ return $self->[$__nextLayer] if $self->[$__nextLayer];
Branch: 1 branch
BranchTrueFalseTotal
if $self->[$__nextLayer] 0 1 1
94  
95 1 ▶ return $Next->{$self->[$__protocol]} || NF_LAYER_UNKNOWN;
Condition50%1/2
$$Next{$self->[$__protocol]} || 1
l!l
10
MC/DC0%0/1
$$Next{$self->[$__protocol]} || 1
$$Next{$self->[$__protocol]}
Truth table50%1/2
A
A= $$Next{$self->[$__protocol]}
Aresult
11
00
96 }
97  
98 1 ▶sub print {
Subroutine print: called CC=1 SCAR=0.0
Pod documented
99 1 my $self = shift;
100  
101 1 my $l = $self->layer;
102 1 sprintf "$l: address:0x%02x control:0x%02x protocol:0x%04x",
103 $self->[$__address], $self->[$__control], $self->[$__protocol];
104 }
105  
106 3 1;
107  
108 __END__
« Frame/Layer/ETH.pm ↑ Summary Frame/Layer/NULL.pm »