File Coverage

blib/lib/Net/Frame/Layer/LLTD/RecveeDesc.pm
Criterion Covered Total %
statement 24 28 85.7
branch 2 4 50.0
condition n/a
subroutine 6 8 75.0
pod 5 5 100.0
total 37 45 82.2


line stmt bran cond sub pod time code
1             #
2             # $Id: RecveeDesc.pm 12 2015-01-14 06:29:59Z gomor $
3             #
4             package Net::Frame::Layer::LLTD::RecveeDesc;
5 9     9   39 use strict; use warnings;
  9     9   13  
  9         275  
  9         36  
  9         11  
  9         244  
6              
7 9     9   40 use Net::Frame::Layer qw(:consts :subs);
  9         11  
  9         4846  
8             our @ISA = qw(Net::Frame::Layer);
9              
10             our @AS = qw(
11             type
12             realSourceAddress
13             sourceAddress
14             destinationAddress
15             );
16             __PACKAGE__->cgBuildIndices;
17             __PACKAGE__->cgBuildAccessorsScalar(\@AS);
18              
19             sub new {
20             shift->SUPER::new(
21 1     1 1 29 type => 0,
22             realSourceAddress => 'ff:ff:ff:ff:ff:ff',
23             sourceAddress => 'ff:ff:ff:ff:ff:ff',
24             destinationAddress => 'ff:ff:ff:ff:ff:ff',
25             @_,
26             );
27             }
28              
29 0     0 1 0 sub getLength { 20 }
30              
31             sub pack {
32 1     1 1 287 my $self = shift;
33              
34 1         4 (my $realSourceAddress = $self->realSourceAddress) =~ s/://g;
35 1         30 (my $sourceAddress = $self->sourceAddress) =~ s/://g;
36 1         12 (my $destinationAddress = $self->destinationAddress) =~ s/://g;
37              
38 1 50       11 $self->raw($self->SUPER::pack('nH12H12H12',
39             $self->type,
40             $realSourceAddress,
41             $sourceAddress,
42             $destinationAddress,
43             )) or return undef;
44              
45 1         39 $self->raw;
46             }
47              
48             sub unpack {
49 1     1 1 9 my $self = shift;
50              
51 1 50       3 my ($type, $realMac, $srcMac, $dstMac, $payload) =
52             $self->SUPER::unpack('nH12H12H12 a*', $self->raw)
53             or return undef;
54              
55 1         28 $self->type($type);
56 1         10 $self->realSourceAddress(convertMac($realMac));
57 1         18 $self->sourceAddress(convertMac($srcMac));
58 1         19 $self->destinationAddress(convertMac($dstMac));
59              
60 1         16 $self->payload($payload);
61              
62 1         8 $self;
63             }
64              
65             sub print {
66 0     0 1   my $self = shift;
67              
68 0           my $l = $self->layer;
69 0           sprintf
70             "$l: type:%02x realSourceAddress: %s\n".
71             "$l: sourceAddress: %s\n".
72             "$l: destinationAddress: %s",
73             $self->type,
74             $self->realSourceAddress,
75             $self->sourceAddress,
76             $self->destinationAddress;
77             }
78              
79             1;
80              
81             __END__