Packet/CDP/TypeDeviceId.pm

filter: Statementstmt 46.8% 15 / 32 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 42.8% 3 / 7 Podpod 100% 4 / 4 totaltotal 44.9% 22 / 49 CC 4 SCAR 17.0
CC
4
Cov
39%
unpack
12.0
pack
6.0
new
2.0
CRAP 5.5
« Packet/PPPoE.pm ↑ Summary Packet/Layer7.pm »
1 #
2 # $Id: TypeDeviceId.pm 2002 2015-02-15 16:50:35Z gomor $
3 #
4 package Net::Packet::CDP::TypeDeviceId;
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::CDP::Type;
9 1 our @ISA = qw(Net::Packet::CDP::Type);
10  
11 1 ▶use Net::Packet::Consts qw(:cdp);
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 1 our @AS = qw(
14 deviceId
15 );
16 1 __PACKAGE__->cgBuildIndices;
17 1 __PACKAGE__->cgBuildAccessorsScalar(\@AS);
18  
19 #no strict 'vars';
20  
21 0 ▶sub new {
Subroutine new: not called CC=1 SCAR=6.9
Pod documented
22 shift->SUPER::new(
23 0 type => NP_CDP_TYPE_DEVICE_ID,
24 length => 8,
25 deviceId => 'GGGG',
26 @_,
27 );
28 }
29  
30 0 ▶sub pack {
Subroutine pack: not called CC=2 SCAR=17.9
Pod documented
31 0 my $self = shift;
32  
33 0 ▶ $self->raw($self->SUPER::pack('nna*',
Branch: 1 branch
BranchTrueFalseTotal
$self->raw($self->SUPER::pack("nna*", $self->type, $self->length, $self->deviceId)) or return undef 0 0 0
34 $self->type,
35 $self->length,
36 $self->deviceId,
37 )) or return undef;
38  
39 0 1;
40 }
41  
42 0 ▶sub unpack {
Subroutine unpack: not called CC=3 SCAR=24.8
Pod documented
43 0 my $self = shift;
44  
45 0 ▶ my ($type, $length, $tail) = $self->SUPER::unpack('nna*', $self->raw)
Branch: 1 branch
BranchTrueFalseTotal
() = $self->SUPER::unpack("nna*", $self->raw) or return undef 0 0 0
46 or return undef;
47  
48 0 $self->type($type);
49 0 $self->length($length);
50  
51 0 my $deviceIdLen = $length - 4;
52  
53 0 ▶ my ($deviceId, $payload) = $self->SUPER::unpack("a$deviceIdLen a*", $tail)
Branch: 1 branch
BranchTrueFalseTotal
() = $self->SUPER::unpack("a$deviceIdLen a*", $tail) or return undef 0 0 0
54 or return undef;
55  
56 0 $self->deviceId($deviceId);
57 0 $self->payload($payload);
58  
59 0 1;
60 }
61  
62 0 ▶sub print {
Subroutine print: not called CC=1 SCAR=6.9
Pod documented
63 0 my $self = shift;
64  
65 0 my $i = $self->is;
66 0 my $l = $self->layer;
67 0 sprintf "$l: $i: type:0x%04x length:%d\n".
68 "$l: $i: deviceId:%s",
69 $self->type, $self->length, $self->deviceId;
70 }
71  
72 1 1;
73  
74 __END__
« Packet/PPPoE.pm ↑ Summary Packet/Layer7.pm »