LLC.pm

filter: Statementstmt 91.3% 84 / 92 Branchbran 25.0% 2 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 87.5% 21 / 24 Podpod 100% 6 / 6 totaltotal 86.9% 113 / 130 SCAR 16.2
CC
5
Cov
86%
encapsulate
12.0
pack
2.0
unpack
2.0
CRAP 5.1
« LLC/SNAP.pm ↑ Summary
1 #
2 # $Id: LLC.pm 16 2010-06-03 12:46:53Z gomor $
3 #
4 package Net::Frame::Layer::LLC;
5 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 4 our $VERSION = '1.02';
9  
10 4 ▶use Net::Frame::Layer qw(:consts);
Subroutine BEGIN: called CC=1 SCAR=0.0
11 4 require Exporter;
12 4 our @ISA = qw(Net::Frame::Layer Exporter);
13  
14 4 our %EXPORT_TAGS = (
15 consts => [qw(
16 NF_LLC_HDR_LEN
17 NF_LLC_DSAP_STP
18 NF_LLC_SSAP_STP
19 NF_LLC_DSAP_SNAP
20 NF_LLC_SSAP_SNAP
21 NF_LLC_DSAP_IPX
22 NF_LLC_SSAP_IPX
23 NF_LLC_DSAP_HPEXTLLC
24 NF_LLC_SSAP_HPEXTLLC
25 NF_LLC_SNAP_HDR_LEN
26 NF_LLC_SNAP_OUI_CISCO
27 NF_LLC_SNAP_PID_CDP
28 NF_LLC_SNAP_PID_STP
29 NF_LLC_SNAP_PID_IPX
30 )],
31 );
32 our @EXPORT_OK = (
33 4 @{$EXPORT_TAGS{consts}},
34 );
35  
36 4 ▶use constant NF_LLC_HDR_LEN => 3;
Subroutine BEGIN: called CC=1 SCAR=0.0
37 4 ▶use constant NF_LLC_DSAP_STP => 0x21;
Subroutine BEGIN: called CC=1 SCAR=0.0
38 4 ▶use constant NF_LLC_SSAP_STP => 0x21;
Subroutine BEGIN: called CC=1 SCAR=0.0
39 4 ▶use constant NF_LLC_DSAP_SNAP => 0x55;
Subroutine BEGIN: called CC=1 SCAR=0.0
40 4 ▶use constant NF_LLC_SSAP_SNAP => 0x55;
Subroutine BEGIN: called CC=1 SCAR=0.0
41 4 ▶use constant NF_LLC_DSAP_IPX => 0x70;
Subroutine BEGIN: called CC=1 SCAR=0.0
42 4 ▶use constant NF_LLC_SSAP_IPX => 0x70;
Subroutine BEGIN: called CC=1 SCAR=0.0
43 4 ▶use constant NF_LLC_DSAP_HPEXTLLC => 0x7c;
Subroutine BEGIN: called CC=1 SCAR=0.0
44 4 ▶use constant NF_LLC_SSAP_HPEXTLLC => 0x7c;
Subroutine BEGIN: called CC=1 SCAR=0.0
45  
46 4 ▶use constant NF_LLC_SNAP_HDR_LEN => 5;
Subroutine BEGIN: called CC=1 SCAR=0.0
47 4 ▶use constant NF_LLC_SNAP_OUI_CISCO => 0x00000c;
Subroutine BEGIN: called CC=1 SCAR=0.0
48 4 ▶use constant NF_LLC_SNAP_PID_CDP => 0x2000;
Subroutine BEGIN: called CC=1 SCAR=0.0
49 4 ▶use constant NF_LLC_SNAP_PID_STP => 0x010b;
Subroutine BEGIN: called CC=1 SCAR=0.0
50 4 ▶use constant NF_LLC_SNAP_PID_IPX => 0x8137;
Subroutine BEGIN: called CC=1 SCAR=0.0
51  
52 4 our @AS = qw(
53 dsap
54 ig
55 ssap
56 cr
57 control
58 );
59 4 __PACKAGE__->cgBuildIndices;
60 4 __PACKAGE__->cgBuildAccessorsScalar(\@AS);
61  
62 4 ▶no strict 'vars';
Subroutine BEGIN: called CC=1 SCAR=0.0
63  
64 4 require Bit::Vector;
65  
66 sub new {
67 shift->SUPER::new(
68 1 ▶ dsap => NF_LLC_DSAP_SNAP,
Subroutine new: called CC=1 SCAR=0.0
Pod documented
69 ig => 1,
70 ssap => NF_LLC_SSAP_SNAP,
71 cr => 1,
72 control => 0x03,
73 @_,
74 );
75 }
76  
77 0 ▶sub getLength { NF_LLC_HDR_LEN }
Subroutine getLength: not called CC=1 SCAR=6.9
Pod documented
78  
79 sub pack {
80 1 ▶ my $self = shift;
Subroutine pack: called CC=2 SCAR=7.0
Pod documented
81  
82 1 my $dsap = Bit::Vector->new_Dec(7, $self->[$__dsap]);
83 1 my $ig = Bit::Vector->new_Dec(1, $self->[$__ig]);
84 1 my $ssap = Bit::Vector->new_Dec(7, $self->[$__ssap]);
85 1 my $cr = Bit::Vector->new_Dec(1, $self->[$__cr]);
86 1 my $v16 = $dsap->Concat_List($ig, $ssap, $cr);
87  
88 1 ▶ $self->[$__raw] = $self->SUPER::pack('nC',
Branch: 1 branch
BranchTrueFalseTotal
$self->[$__raw] = $self->SUPER::pack("nC", $v16->to_Dec, $self->[$__control]) or return undef 0 1 1
89 $v16->to_Dec,
90 $self->[$__control],
91 ) or return undef;
92  
93 1 $self->[$__raw];
94 }
95  
96 sub unpack {
97 1 ▶ my $self = shift;
Subroutine unpack: called CC=2 SCAR=6.9
Pod documented
98  
99 1 ▶ my ($dsapIgSsapCr, $control, $payload) =
Branch: 1 branch
BranchTrueFalseTotal
() = $self->SUPER::unpack("nC a*", $self->[$__raw]) or return undef 0 1 1
100 $self->SUPER::unpack('nC a*', $self->[$__raw])
101 or return undef;
102  
103 1 my $v16 = Bit::Vector->new_Dec(16, $dsapIgSsapCr);
104 1 $self->[$__dsap] = $v16->Chunk_Read(7, 9);
105 1 $self->[$__ig] = $v16->Chunk_Read(1, 8);
106 1 $self->[$__ssap] = $v16->Chunk_Read(7, 1);
107 1 $self->[$__cr] = $v16->Chunk_Read(1, 0);
108  
109 1 $self->[$__control] = $control;
110  
111 1 $self->[$__payload] = $payload;
112  
113 1 $self;
114 }
115  
116 sub encapsulate {
117 0 ▶ my $self = shift;
Subroutine encapsulate: not called CC=3 SCAR=24.8
Pod documented
118  
119 0 ▶ return $self->[$__nextLayer] if $self->[$__nextLayer];
Branch: 1 branch
BranchTrueFalseTotal
if $self->[$__nextLayer] 0 0 0
120  
121 0 my $types = {
122 NF_LLC_DSAP_STP() => 'STP',
123 NF_LLC_DSAP_IPX() => 'IPX',
124 NF_LLC_DSAP_SNAP() => 'LLC::SNAP',
125 NF_LLC_DSAP_HPEXTLLC() => 'HPEXTLLC',
126 };
127  
128 0 ▶ $types->{$self->[$__dsap]} || NF_LAYER_UNKNOWN;
Branch: 1 branch
BranchTrueFalseTotal
$$types{$self->[$__dsap]} or 1 0 0 0
129 }
130  
131 sub print {
132 0 ▶ my $self = shift;
Subroutine print: not called CC=1 SCAR=6.9
Pod documented
133  
134 0 my $l = $self->layer;
135 0 sprintf "$l: dsap:0x%02x ig:%d ssap:0x%02x cr:%d control:0x%02x",
136 $self->[$__dsap], $self->[$__ig], $self->[$__ssap], $self->[$__cr],
137 $self->[$__control];
138 }
139  
140 4 1;
141  
142 __END__
« LLC/SNAP.pm ↑ Summary