LLC/SNAP.pm

filter: Statementstmt 80.4% 33 / 41 Branchbran 25.0% 2 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 72.7% 8 / 11 Podpod 100% 6 / 6 totaltotal 74.2% 49 / 66 SCAR 17.2
CC
5
Cov
71%
encapsulate
12.0
pack
2.0
unpack
2.0
CRAP 5.6
↑ Summary LLC.pm »
1 #
2 # $Id: SNAP.pm 16 2010-06-03 12:46:53Z gomor $
3 #
4 package Net::Frame::Layer::LLC::SNAP;
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 ▶use Net::Frame::Layer qw(:consts);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 our @ISA = qw(Net::Frame::Layer);
10  
11 1 our @AS = qw(
12 oui
13 pid
14 );
15 1 __PACKAGE__->cgBuildIndices;
16 1 __PACKAGE__->cgBuildAccessorsScalar(\@AS);
17  
18 1 ▶no strict 'vars';
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20 1 ▶use Net::Frame::Layer::LLC qw(:consts);
Subroutine BEGIN: called CC=1 SCAR=0.0
21 1 require Bit::Vector;
22  
23 sub new {
24 shift->SUPER::new(
25 1 ▶ oui => NF_LLC_SNAP_OUI_CISCO,
Subroutine new: called CC=1 SCAR=0.0
Pod documented
26 pid => NF_LLC_SNAP_PID_CDP,
27 @_,
28 );
29 }
30  
31 0 ▶sub getLength { NF_LLC_SNAP_HDR_LEN }
Subroutine getLength: not called CC=1 SCAR=6.9
Pod documented
32  
33 sub pack {
34 1 ▶ my $self = shift;
Subroutine pack: called CC=2 SCAR=7.0
Pod documented
35  
36 1 my $oui = Bit::Vector->new_Dec(24, $self->[$__oui]);
37  
38 1 ▶ $self->[$__raw] = $self->SUPER::pack('B24n',
Branch: 1 branch
BranchTrueFalseTotal
$self->[$__raw] = $self->SUPER::pack("B24n", $oui->to_Bin, $self->[$__pid]) or return undef 0 1 1
39 $oui->to_Bin,
40 $self->[$__pid],
41 ) or return undef;
42  
43 1 $self->[$__raw];
44 }
45  
46 sub unpack {
47 1 ▶ my $self = shift;
Subroutine unpack: called CC=2 SCAR=7.0
Pod documented
48  
49 1 ▶ my ($oui, $pid, $payload) = $self->SUPER::unpack('B24n a*', $self->[$__raw])
Branch: 1 branch
BranchTrueFalseTotal
() = $self->SUPER::unpack("B24n a*", $self->[$__raw]) or return undef 0 1 1
50 or return undef;
51  
52 1 my $v24 = Bit::Vector->new_Bin(24, $oui);
53 1 $self->[$__oui] = $v24->to_Dec;
54 1 $self->[$__pid] = $pid;
55  
56 1 $self->[$__payload] = $payload;
57  
58 1 $self;
59 }
60  
61 sub encapsulate {
62 0 ▶ my $self = shift;
Subroutine encapsulate: not called CC=3 SCAR=24.8
Pod documented
63  
64 0 ▶ return $self->[$__nextLayer] if $self->[$__nextLayer];
Branch: 1 branch
BranchTrueFalseTotal
if $self->[$__nextLayer] 0 0 0
65  
66 0 my $types = {
67 NF_LLC_SNAP_PID_CDP() => 'CDP',
68 NF_LLC_SNAP_PID_STP() => 'STP',
69 NF_LLC_SNAP_PID_IPX() => 'IPX',
70 };
71  
72 0 ▶ $types->{$self->[$__pid]} || NF_LAYER_UNKNOWN;
Branch: 1 branch
BranchTrueFalseTotal
$$types{$self->[$__pid]} or 1 0 0 0
73 }
74  
75 sub print {
76 0 ▶ my $self = shift;
Subroutine print: not called CC=1 SCAR=6.9
Pod documented
77  
78 0 my $l = $self->layer;
79 0 sprintf "$l: oui:0x%06x pid:0x%04x",
80 $self->[$__oui], $self->[$__pid];
81 }
82  
83 1 1;
84  
85 __END__
↑ Summary LLC.pm »