Frame/Layer/NULL.pm

filter: Statementstmt 99.0% 100 / 101 Branchbran 50.0% 3 / 6 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 96.7% 30 / 31 Podpod 100% 6 / 6 totaltotal 95.2% 140 / 147 CC 5 SCAR 2.9
CC
5
Cov
95%
encapsulate
3.2
pack
2.0
unpack
2.0
CRAP 1.3
« Frame/Layer/PPP.pm ↑ Summary Frame/Layer/SLL.pm »
1 #
2 # $Id: NULL.pm,v ce68fbcc7f6d 2019/05/23 05:58:40 gomor $
3 #
4 package Net::Frame::Layer::NULL;
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_NULL_HDR_LEN
15 NF_NULL_TYPE_IPv4
16 NF_NULL_TYPE_ARP
17 NF_NULL_TYPE_CGMP
18 NF_NULL_TYPE_80211
19 NF_NULL_TYPE_DDP
20 NF_NULL_TYPE_AARP
21 NF_NULL_TYPE_WCP
22 NF_NULL_TYPE_8021Q
23 NF_NULL_TYPE_IPX
24 NF_NULL_TYPE_STP
25 NF_NULL_TYPE_IPv6
26 NF_NULL_TYPE_WLCCP
27 NF_NULL_TYPE_PPPoED
28 NF_NULL_TYPE_PPPoES
29 NF_NULL_TYPE_8021X
30 NF_NULL_TYPE_AoE
31 NF_NULL_TYPE_LLDP
32 NF_NULL_TYPE_LOOP
33 NF_NULL_TYPE_VLAN
34 NF_NULL_TYPE_ETH
35 )],
36 );
37 our @EXPORT_OK = (
38 3 @{$EXPORT_TAGS{consts}},
39 );
40  
41 3 ▶use constant NF_NULL_HDR_LEN => 4;
Subroutine BEGIN: called CC=1 SCAR=0.0
42 3 ▶use constant NF_NULL_TYPE_IPv4 => 0x02000000;
Subroutine BEGIN: called CC=1 SCAR=0.0
43 3 ▶use constant NF_NULL_TYPE_ARP => 0x06080000;
Subroutine BEGIN: called CC=1 SCAR=0.0
44 3 ▶use constant NF_NULL_TYPE_CGMP => 0x01200000;
Subroutine BEGIN: called CC=1 SCAR=0.0
45 3 ▶use constant NF_NULL_TYPE_80211 => 0x52240000;
Subroutine BEGIN: called CC=1 SCAR=0.0
46 3 ▶use constant NF_NULL_TYPE_DDP => 0x9b800000;
Subroutine BEGIN: called CC=1 SCAR=0.0
47 3 ▶use constant NF_NULL_TYPE_AARP => 0xf3800000;
Subroutine BEGIN: called CC=1 SCAR=0.0
48 3 ▶use constant NF_NULL_TYPE_WCP => 0xff800000;
Subroutine BEGIN: called CC=1 SCAR=0.0
49 3 ▶use constant NF_NULL_TYPE_8021Q => 0x00810000;
Subroutine BEGIN: called CC=1 SCAR=0.0
50 3 ▶use constant NF_NULL_TYPE_IPX => 0x37810000;
Subroutine BEGIN: called CC=1 SCAR=0.0
51 3 ▶use constant NF_NULL_TYPE_STP => 0x81810000;
Subroutine BEGIN: called CC=1 SCAR=0.0
52 3 ▶use constant NF_NULL_TYPE_IPv6 => 0x1c000000;
Subroutine BEGIN: called CC=1 SCAR=0.0
53 3 ▶use constant NF_NULL_TYPE_WLCCP => 0x2d870000;
Subroutine BEGIN: called CC=1 SCAR=0.0
54 3 ▶use constant NF_NULL_TYPE_PPPoED => 0x63880000;
Subroutine BEGIN: called CC=1 SCAR=0.0
55 3 ▶use constant NF_NULL_TYPE_PPPoES => 0x64880000;
Subroutine BEGIN: called CC=1 SCAR=0.0
56 3 ▶use constant NF_NULL_TYPE_8021X => 0x8e880000;
Subroutine BEGIN: called CC=1 SCAR=0.0
57 3 ▶use constant NF_NULL_TYPE_AoE => 0xa2880000;
Subroutine BEGIN: called CC=1 SCAR=0.0
58 3 ▶use constant NF_NULL_TYPE_LLDP => 0xcc880000;
Subroutine BEGIN: called CC=1 SCAR=0.0
59 3 ▶use constant NF_NULL_TYPE_LOOP => 0x00900000;
Subroutine BEGIN: called CC=1 SCAR=0.0
60 3 ▶use constant NF_NULL_TYPE_VLAN => 0x00910000;
Subroutine BEGIN: called CC=1 SCAR=0.0
61 3 ▶use constant NF_NULL_TYPE_ETH => 0x58650000;
Subroutine BEGIN: called CC=1 SCAR=0.0
62  
63 3 our @AS = qw(
64 type
65 );
66 3 __PACKAGE__->cgBuildIndices;
67 3 __PACKAGE__->cgBuildAccessorsScalar(\@AS);
68  
69 3 ▶no strict 'vars';
Subroutine BEGIN: called CC=1 SCAR=0.0
70  
71 1 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod documented
72 shift->SUPER::new(
73 1 type => NF_NULL_TYPE_IPv4,
74 @_,
75 );
76 }
77  
78 0 ▶sub getLength { NF_NULL_HDR_LEN }
Subroutine getLength: not called CC=1 SCAR=6.9
Pod documented
79  
80 1 ▶sub pack {
Subroutine pack: called CC=2 SCAR=7.1
Pod documented
81 1 my $self = shift;
82 1 ▶ $self->[$__raw] = $self->SUPER::pack('N', $self->[$__type])
Branch: 1 branch
BranchTrueFalseTotal
$self->[$__raw] = $self->SUPER::pack("N", $self->[$__type]) or return undef 1 0 1
83 or return undef;
84 1 $self->[$__raw];
85 }
86  
87 1 ▶sub unpack {
Subroutine unpack: called CC=2 SCAR=7.0
Pod documented
88 1 my $self = shift;
89  
90 1 ▶ my ($type, $payload) = $self->SUPER::unpack('N a*', $self->[$__raw])
Branch: 1 branch
BranchTrueFalseTotal
() = $self->SUPER::unpack("N a*", $self->[$__raw]) or return undef 1 0 1
91 or return undef;
92  
93 1 $self->[$__type] = $type;
94 1 $self->[$__payload] = $payload;
95  
96 1 $self;
97 }
98  
99 3 our $Next = {
100 NF_NULL_TYPE_IPv4() => 'IPv4',
101 NF_NULL_TYPE_ARP() => 'ARP',
102 NF_NULL_TYPE_CGMP() => 'CGMP',
103 NF_NULL_TYPE_80211() => '80211',
104 NF_NULL_TYPE_DDP() => 'DDP',
105 NF_NULL_TYPE_AARP() => 'AARP',
106 NF_NULL_TYPE_WCP() => 'WCP',
107 NF_NULL_TYPE_8021Q() => '8021Q',
108 NF_NULL_TYPE_IPX() => 'IPX',
109 NF_NULL_TYPE_STP() => 'STP',
110 NF_NULL_TYPE_IPv6() => 'IPv6',
111 NF_NULL_TYPE_WLCCP() => 'WLCCP',
112 NF_NULL_TYPE_PPPoED() => 'PPPoED',
113 NF_NULL_TYPE_PPPoES() => 'PPPoES',
114 NF_NULL_TYPE_8021X() => '8021X',
115 NF_NULL_TYPE_AoE() => 'AoE',
116 NF_NULL_TYPE_LLDP() => 'LLDP',
117 NF_NULL_TYPE_LOOP() => 'LOOP',
118 NF_NULL_TYPE_VLAN() => 'VLAN',
119 NF_NULL_TYPE_ETH() => 'ETH',
120 };
121  
122 1 ▶sub encapsulate {
Subroutine encapsulate: called CC=3 SCAR=11.7
Pod documented
123 1 my $self = shift;
124  
125 1 ▶ return $self->[$__nextLayer] if $self->[$__nextLayer];
Branch: 1 branch
BranchTrueFalseTotal
if $self->[$__nextLayer] 0 1 1
126  
127 1 ▶ return $Next->{$self->[$__type]} || NF_LAYER_UNKNOWN;
Condition50%1/2
$$Next{$self->[$__type]} || 1
l!l
10
MC/DC0%0/1
$$Next{$self->[$__type]} || 1
$$Next{$self->[$__type]}
Truth table50%1/2
A
A= $$Next{$self->[$__type]}
Aresult
11
00
128 }
129  
130 1 ▶sub print {
Subroutine print: called CC=1 SCAR=0.0
Pod documented
131 1 my $self = shift;
132  
133 1 my $l = $self->layer;
134 1 sprintf "$l: type:0x%08x", $self->type;
135 }
136  
137 3 1;
138  
139 __END__
« Frame/Layer/PPP.pm ↑ Summary Frame/Layer/SLL.pm »