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

filter: Statementstmt 93.8% 121 / 129 Branchbran 25.0% 2 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 92.5% 37 / 40 Podpod 100% 6 / 6 totaltotal 90.7% 166 / 183 CC 5 SCAR 6.4
CC
5
Cov
90%
encapsulate
12.0
pack
2.0
unpack
2.0
CRAP 1.9
↑ Summary
1 #
2 # $Id: GRE.pm 23 2015-01-20 18:48:56Z gomor $
3 #
4 package Net::Frame::Layer::GRE;
5 3 ▶use strict; use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 3 our $VERSION = '1.05';
8  
9 3 ▶use Net::Frame::Layer qw(:consts);
Subroutine BEGIN: called CC=1 SCAR=0.0
10 3 ▶use Exporter;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 3 our @ISA = qw(Net::Frame::Layer Exporter);
12  
13 3 our %EXPORT_TAGS = (
14 consts => [qw(
15 NF_GRE_HDR_LEN
16 NF_GRE_TYPE_IPv4
17 NF_GRE_TYPE_X25
18 NF_GRE_TYPE_ARP
19 NF_GRE_TYPE_CGMP
20 NF_GRE_TYPE_80211
21 NF_GRE_TYPE_PPPIPCP
22 NF_GRE_TYPE_RARP
23 NF_GRE_TYPE_DDP
24 NF_GRE_TYPE_AARP
25 NF_GRE_TYPE_PPPCCP
26 NF_GRE_TYPE_WCP
27 NF_GRE_TYPE_8021Q
28 NF_GRE_TYPE_IPX
29 NF_GRE_TYPE_STP
30 NF_GRE_TYPE_IPv6
31 NF_GRE_TYPE_WLCCP
32 NF_GRE_TYPE_MPLS
33 NF_GRE_TYPE_PPPoED
34 NF_GRE_TYPE_PPPoES
35 NF_GRE_TYPE_8021X
36 NF_GRE_TYPE_AoE
37 NF_GRE_TYPE_80211I
38 NF_GRE_TYPE_LLDP
39 NF_GRE_TYPE_LLTD
40 NF_GRE_TYPE_LOOP
41 NF_GRE_TYPE_VLAN
42 NF_GRE_TYPE_PPPPAP
43 NF_GRE_TYPE_PPPCHAP
44 )],
45 );
46 our @EXPORT_OK = (
47 3 @{$EXPORT_TAGS{consts}},
48 );
49  
50 3 ▶use constant NF_GRE_HDR_LEN => 4;
Subroutine BEGIN: called CC=1 SCAR=0.0
51 3 ▶use constant NF_GRE_TYPE_IPv4 => 0x0800;
Subroutine BEGIN: called CC=1 SCAR=0.0
52 3 ▶use constant NF_GRE_TYPE_X25 => 0x0805;
Subroutine BEGIN: called CC=1 SCAR=0.0
53 3 ▶use constant NF_GRE_TYPE_ARP => 0x0806;
Subroutine BEGIN: called CC=1 SCAR=0.0
54 3 ▶use constant NF_GRE_TYPE_CGMP => 0x2001;
Subroutine BEGIN: called CC=1 SCAR=0.0
55 3 ▶use constant NF_GRE_TYPE_80211 => 0x2452;
Subroutine BEGIN: called CC=1 SCAR=0.0
56 3 ▶use constant NF_GRE_TYPE_PPPIPCP => 0x8021;
Subroutine BEGIN: called CC=1 SCAR=0.0
57 3 ▶use constant NF_GRE_TYPE_RARP => 0x8035;
Subroutine BEGIN: called CC=1 SCAR=0.0
58 3 ▶use constant NF_GRE_TYPE_DDP => 0x809b;
Subroutine BEGIN: called CC=1 SCAR=0.0
59 3 ▶use constant NF_GRE_TYPE_AARP => 0x80f3;
Subroutine BEGIN: called CC=1 SCAR=0.0
60 3 ▶use constant NF_GRE_TYPE_PPPCCP => 0x80fd;
Subroutine BEGIN: called CC=1 SCAR=0.0
61 3 ▶use constant NF_GRE_TYPE_WCP => 0x80ff;
Subroutine BEGIN: called CC=1 SCAR=0.0
62 3 ▶use constant NF_GRE_TYPE_8021Q => 0x8100;
Subroutine BEGIN: called CC=1 SCAR=0.0
63 3 ▶use constant NF_GRE_TYPE_IPX => 0x8137;
Subroutine BEGIN: called CC=1 SCAR=0.0
64 3 ▶use constant NF_GRE_TYPE_STP => 0x8181;
Subroutine BEGIN: called CC=1 SCAR=0.0
65 3 ▶use constant NF_GRE_TYPE_IPv6 => 0x86dd;
Subroutine BEGIN: called CC=1 SCAR=0.0
66 3 ▶use constant NF_GRE_TYPE_WLCCP => 0x872d;
Subroutine BEGIN: called CC=1 SCAR=0.0
67 3 ▶use constant NF_GRE_TYPE_MPLS => 0x8847;
Subroutine BEGIN: called CC=1 SCAR=0.0
68 3 ▶use constant NF_GRE_TYPE_PPPoED => 0x8863;
Subroutine BEGIN: called CC=1 SCAR=0.0
69 3 ▶use constant NF_GRE_TYPE_PPPoES => 0x8864;
Subroutine BEGIN: called CC=1 SCAR=0.0
70 3 ▶use constant NF_GRE_TYPE_8021X => 0x888e;
Subroutine BEGIN: called CC=1 SCAR=0.0
71 3 ▶use constant NF_GRE_TYPE_AoE => 0x88a2;
Subroutine BEGIN: called CC=1 SCAR=0.0
72 3 ▶use constant NF_GRE_TYPE_80211I => 0x88c7;
Subroutine BEGIN: called CC=1 SCAR=0.0
73 3 ▶use constant NF_GRE_TYPE_LLDP => 0x88cc;
Subroutine BEGIN: called CC=1 SCAR=0.0
74 3 ▶use constant NF_GRE_TYPE_LLTD => 0x88d9;
Subroutine BEGIN: called CC=1 SCAR=0.0
75 3 ▶use constant NF_GRE_TYPE_LOOP => 0x9000;
Subroutine BEGIN: called CC=1 SCAR=0.0
76 3 ▶use constant NF_GRE_TYPE_VLAN => 0x9100;
Subroutine BEGIN: called CC=1 SCAR=0.0
77 3 ▶use constant NF_GRE_TYPE_PPPPAP => 0xc023;
Subroutine BEGIN: called CC=1 SCAR=0.0
78 3 ▶use constant NF_GRE_TYPE_PPPCHAP => 0xc223;
Subroutine BEGIN: called CC=1 SCAR=0.0
79  
80 3 our @AS = qw(
81 flags
82 protocol
83 );
84 3 __PACKAGE__->cgBuildIndices;
85 3 __PACKAGE__->cgBuildAccessorsScalar(\@AS);
86  
87 3 ▶no strict 'vars';
Subroutine BEGIN: called CC=1 SCAR=0.0
88  
89 1 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod documented
90 shift->SUPER::new(
91 1 flags => 0,
92 protocol => NF_GRE_TYPE_IPv4,
93 @_,
94 );
95 }
96  
97 0 ▶sub getLength { NF_GRE_HDR_LEN }
Subroutine getLength: not called CC=1 SCAR=6.9
Pod documented
98  
99 1 ▶sub pack {
Subroutine pack: called CC=2 SCAR=7.1
Pod documented
100 1 my $self = shift;
101  
102 1 ▶ $self->[$__raw] = $self->SUPER::pack('nn',
Branch: 1 branch
BranchTrueFalseTotal
$self->[$__raw] = $self->SUPER::pack("nn", $self->[$__flags], $self->[$__protocol]) or return undef 1 0 1
103 $self->[$__flags],
104 $self->[$__protocol],
105 ) or return undef;
106  
107 1 $self->[$__raw];
108 }
109  
110 1 ▶sub unpack {
Subroutine unpack: called CC=2 SCAR=7.0
Pod documented
111 1 my $self = shift;
112  
113 1 ▶ my ($flags, $protocol, $payload) =
Branch: 1 branch
BranchTrueFalseTotal
() = $self->SUPER::unpack("nn a*", $self->[$__raw]) or return undef 1 0 1
114 $self->SUPER::unpack('nn a*', $self->[$__raw])
115 or return undef;
116  
117 1 $self->[$__flags] = $flags;
118 1 $self->[$__protocol] = $protocol;
119 1 $self->[$__payload] = $payload;
120  
121 1 $self;
122 }
123  
124 0 ▶sub encapsulate {
Subroutine encapsulate: not called CC=3 SCAR=24.8
Pod documented
125 0 my $self = shift;
126  
127 0 ▶ return $self->[$__nextLayer] if $self->[$__nextLayer];
Branch: 1 branch
BranchTrueFalseTotal
if $self->[$__nextLayer] 0 0 0
128  
129 0 my $types = {
130 NF_GRE_TYPE_IPv4() => 'IPv4',
131 NF_GRE_TYPE_X25() => 'X25',
132 NF_GRE_TYPE_ARP() => 'ARP',
133 NF_GRE_TYPE_CGMP() => 'CGMP',
134 NF_GRE_TYPE_80211() => '80211',
135 NF_GRE_TYPE_PPPIPCP() => 'PPPIPCP',
136 NF_GRE_TYPE_RARP() => 'RARP',
137 NF_GRE_TYPE_DDP () => 'DDP',
138 NF_GRE_TYPE_AARP() => 'AARP',
139 NF_GRE_TYPE_PPPCCP() => 'PPPCCP',
140 NF_GRE_TYPE_WCP() => 'WCP',
141 NF_GRE_TYPE_8021Q() => '8021Q',
142 NF_GRE_TYPE_IPX() => 'IPX',
143 NF_GRE_TYPE_STP() => 'STP',
144 NF_GRE_TYPE_IPv6() => 'IPv6',
145 NF_GRE_TYPE_WLCCP() => 'WLCCP',
146 NF_GRE_TYPE_MPLS() => 'MPLS',
147 NF_GRE_TYPE_PPPoED() => 'PPPoED',
148 NF_GRE_TYPE_PPPoES() => 'PPPoES',
149 NF_GRE_TYPE_8021X() => '8021X',
150 NF_GRE_TYPE_AoE() => 'AoE',
151 NF_GRE_TYPE_80211I() => '80211I',
152 NF_GRE_TYPE_LLDP() => 'LLDP',
153 NF_GRE_TYPE_LLTD() => 'LLTD',
154 NF_GRE_TYPE_LOOP() => 'LOOP',
155 NF_GRE_TYPE_VLAN() => 'VLAN',
156 NF_GRE_TYPE_PPPPAP() => 'PPPPAP',
157 NF_GRE_TYPE_PPPCHAP() => 'PPPCHAP',
158 };
159  
160 0 ▶ $types->{$self->[$__protocol]} || NF_LAYER_UNKNOWN;
Branch: 1 branch
BranchTrueFalseTotal
$$types{$self->[$__protocol]} or 1 0 0 0
161 }
162  
163 0 ▶sub print {
Subroutine print: not called CC=1 SCAR=6.9
Pod documented
164 0 my $self = shift;
165  
166 0 my $l = $self->layer;
167 0 sprintf "$l: flags:0x%04x protocol:0x%04x",
168 $self->[$__flags], $self->[$__protocol];
169 }
170  
171 3 1;
172  
173 __END__
↑ Summary