| 1 | # | ||||||||||
| 2 | # $Id: Tlv.pm 12 2015-01-14 06:29:59Z gomor $ | ||||||||||
| 3 | # | ||||||||||
| 4 | package Net::Frame::Layer::LLTD::Tlv; | ||||||||||
| 5 | 10 | ▶ | use strict; use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | 10 | ▶ | use Net::Frame::Layer qw(:consts :subs); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 10 | our @ISA = qw(Net::Frame::Layer); | |||||||||
| 9 | |||||||||||
| 10 | 10 | our @AS = qw( | |||||||||
| 11 | type | ||||||||||
| 12 | length | ||||||||||
| 13 | value | ||||||||||
| 14 | ); | ||||||||||
| 15 | 10 | __PACKAGE__->cgBuildIndices; | |||||||||
| 16 | 10 | __PACKAGE__->cgBuildAccessorsScalar(\@AS); | |||||||||
| 17 | |||||||||||
| 18 | 1 | ▶ | sub new { | ||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 19 | shift->SUPER::new( | ||||||||||
| 20 | 1 | type => 0, | |||||||||
| 21 | length => 0, | ||||||||||
| 22 | value => '', | ||||||||||
| 23 | @_, | ||||||||||
| 24 | ); | ||||||||||
| 25 | } | ||||||||||
| 26 | |||||||||||
| 27 | 0 | ▶ | sub getLength { 2 + shift->length } | ||||||||
|
Subroutine
getLength: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 28 | |||||||||||
| 29 | 1 | ▶ | sub pack { | ||||||||
|
Subroutine
pack: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||
| 30 | 1 | my $self = shift; | |||||||||
| 31 | |||||||||||
| 32 | 1 | ▶ | $self->raw($self->SUPER::pack('CCa*', | ||||||||
|
Branch: 1 branch
| |||||||||||
| 33 | $self->type, $self->length, $self->value, | ||||||||||
| 34 | )) or return undef; | ||||||||||
| 35 | |||||||||||
| 36 | 1 | $self->raw; | |||||||||
| 37 | } | ||||||||||
| 38 | |||||||||||
| 39 | 1 | ▶ | sub unpack { | ||||||||
|
Subroutine
unpack: called CC=3 SCAR=11.1
Pod
documented
| |||||||||||
| 40 | 1 | my $self = shift; | |||||||||
| 41 | |||||||||||
| 42 | 1 | ▶ | my ($type, $length, $tail) = $self->SUPER::unpack('CC a*', $self->raw) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 43 | or return undef; | ||||||||||
| 44 | |||||||||||
| 45 | 1 | my $bLen = $length; | |||||||||
| 46 | 1 | ▶ | my ($value, $payload) = $self->SUPER::unpack("a$bLen a*", $tail) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 47 | or return undef; | ||||||||||
| 48 | |||||||||||
| 49 | 1 | $self->type($type); | |||||||||
| 50 | 1 | $self->length($length); | |||||||||
| 51 | 1 | $self->value($value); | |||||||||
| 52 | |||||||||||
| 53 | 1 | $self->payload($payload); | |||||||||
| 54 | |||||||||||
| 55 | 1 | $self; | |||||||||
| 56 | } | ||||||||||
| 57 | |||||||||||
| 58 | 0 | ▶ | sub print { | ||||||||
|
Subroutine
print: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 59 | 0 | my $self = shift; | |||||||||
| 60 | |||||||||||
| 61 | 0 | my $l = $self->layer; | |||||||||
| 62 | 0 | sprintf "$l: type:%02x length:%02x value:%s", | |||||||||
| 63 | $self->type, $self->length, CORE::unpack('H*', $self->value); | ||||||||||
| 64 | } | ||||||||||
| 65 | |||||||||||
| 66 | 10 | 1; | |||||||||
| 67 | |||||||||||
| 68 | __END__ | ||||||||||