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