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