Packet/PPPoE.pm

filter: Statementstmt 40.4% 19 / 47 Branchbran 0.0% 0 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 36.3% 4 / 11 Podpod 100% 7 / 7 totaltotal 40.0% 30 / 75 CC 6 SCAR 19.8
CC
6
Cov
33%
pack
20.0
unpack
6.0
encapsulate
6.0
CRAP 7.2
« Packet/CDP/TypeAddresses.pm ↑ Summary Packet/CDP/TypeDeviceId.pm »
1 #
2 # $Id: PPPoE.pm 2002 2015-02-15 16:50:35Z gomor $
3 #
4 package Net::Packet::PPPoE;
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::Layer3;
9 1 our @ISA = qw(Net::Packet::Layer3);
10  
11 1 ▶use Net::Packet::Consts qw(:pppoe :layer);
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 require Bit::Vector;
13  
14 1 our @AS = qw(
15 version
16 type
17 code
18 sessionId
19 payloadLength
20 pppProtocol
21 );
22 1 __PACKAGE__->cgBuildIndices;
23 1 __PACKAGE__->cgBuildAccessorsScalar(\@AS);
24  
25 1 ▶no strict 'vars';
Subroutine BEGIN: called CC=1 SCAR=0.0
26  
27 0 ▶sub new {
Subroutine new: not called CC=1 SCAR=6.9
Pod documented
28 shift->SUPER::new(
29 0 version => 1,
30 type => 1,
31 code => 0,
32 sessionId => 1,
33 payloadLength => 0,
34 pppProtocol => NP_PPPoE_PPP_PROTOCOL_IPv4,
35 @_,
36 );
37 }
38  
39 0 ▶sub getLength { NP_PPPoE_HDR_LEN }
Subroutine getLength: not called CC=1 SCAR=6.9
Pod documented
40  
41 0 ▶sub getPayloadLength { shift->[$__payloadLength] }
Subroutine getPayloadLength: not called CC=1 SCAR=6.9
Pod documented
42  
43 0 ▶sub pack {
Subroutine pack: not called CC=4 SCAR=30.0
Pod documented
44 0 my $self = shift;
45  
46 0 my $version = Bit::Vector->new_Dec(4, $self->[$__version]);
47 0 my $type = Bit::Vector->new_Dec(4, $self->[$__type]);
48 0 my $v8 = $version->Concat_List($type);
49  
50 0 ▶ $self->[$__raw] = $self->SUPER::pack('CCnnn',
Branch: 1 branch
BranchTrueFalseTotal
$self->[$__raw] = $self->SUPER::pack("CCnnn", $v8->to_Dec, $self->[$__code], $self->[$__sessionId], $self->[$__payloadLength], $self->[$__pppProtocol]) or return undef 0 0 0
51 $v8->to_Dec,
52 $self->[$__code],
53 $self->[$__sessionId],
54 $self->[$__payloadLength],
55 $self->[$__pppProtocol],
56 ) or return undef;
57  
58 0 ▶ if (length($self->[$__payload])) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $self->[$__payload]) 0 0 0
59 0 ▶ $self->[$__raw] .= $self->SUPER::pack('a*', $self->[$__payload])
Branch: 1 branch
BranchTrueFalseTotal
$self->[$__raw] .= $self->SUPER::pack("a*", $self->[$__payload]) or return undef 0 0 0
60 or return undef;
61 }
62  
63 0 1;
64 }
65  
66 0 ▶sub unpack {
Subroutine unpack: not called CC=2 SCAR=17.9
Pod documented
67 0 my $self = shift;
68  
69 0 ▶ my ($versionType, $code, $sessionId, $payloadLength, $pppProtocol,
Branch: 1 branch
BranchTrueFalseTotal
() = $self->SUPER::unpack("CCnnn a*", $self->[$__raw]) or return undef 0 0 0
70 $payload) = $self->SUPER::unpack('CCnnn a*', $self->[$__raw])
71 or return undef;
72  
73 0 my $v8 = Bit::Vector->new_Dec(8, $versionType);
74 0 $self->version($v8->Chunk_Read(4, 0));
75 0 $self->type($v8->Chunk_Read(4, 4));
76  
77 0 $self->[$__code] = $code;
78 0 $self->[$__sessionId] = $sessionId;
79 0 $self->[$__payloadLength] = $payloadLength;
80 0 $self->[$__pppProtocol] = $pppProtocol;
81 0 $self->[$__payload] = $payload;
82  
83 0 1;
84 }
85  
86 0 ▶sub encapsulate {
Subroutine encapsulate: not called CC=2 SCAR=17.9
Pod documented
87 0 my $types = {
88 NP_PPPoE_PPP_PROTOCOL_IPv4() => NP_LAYER_IPv4(),
89 NP_PPPoE_PPP_PROTOCOL_PPPLCP() => NP_LAYER_PPPLCP(),
90 };
91  
92 0 ▶ $types->{shift->[$__pppProtocol]} || NP_LAYER_UNKNOWN();
Branch: 1 branch
BranchTrueFalseTotal
$$types{+(shift())->[$__pppProtocol]} or "UNKNOWN" 0 0 0
93 }
94  
95 0 ▶sub print {
Subroutine print: not called CC=1 SCAR=6.9
Pod documented
96 0 my $self = shift;
97  
98 0 my $l = $self->layer;
99 0 my $i = $self->is;
100 0 sprintf "$l:+$i: version:%d type:%d code:0x%02x sessionId:0x%04x\n".
101 "$l: $i: payloadLength:%d pppProtocol:0x%04x",
102 $self->[$__version], $self->[$__type], $self->[$__code],
103 $self->[$__sessionId], $self->[$__payloadLength], $self->[$__pppProtocol];
104 }
105  
106 1 1;
107  
108 __END__
« Packet/CDP/TypeAddresses.pm ↑ Summary Packet/CDP/TypeDeviceId.pm »