| 1 | # | ||||||||||
| 2 | # $Id: Lls.pm,v 1.2 2007/03/13 18:19:39 gomor Exp $ | ||||||||||
| 3 | # | ||||||||||
| 4 | package Net::Frame::Layer::OSPF::Lls; | ||||||||||
| 5 | 15 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 15 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | 15 | ▶ | use Net::Frame::Layer qw(:consts :subs); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 15 | our @ISA = qw(Net::Frame::Layer); | |||||||||
| 10 | |||||||||||
| 11 | 15 | our @AS = qw( | |||||||||
| 12 | checksum | ||||||||||
| 13 | dataLength | ||||||||||
| 14 | rawTlv | ||||||||||
| 15 | ); | ||||||||||
| 16 | 15 | our @AA = qw( | |||||||||
| 17 | tlvList | ||||||||||
| 18 | ); | ||||||||||
| 19 | 15 | __PACKAGE__->cgBuildIndices; | |||||||||
| 20 | 15 | __PACKAGE__->cgBuildAccessorsScalar(\@AS); | |||||||||
| 21 | 15 | __PACKAGE__->cgBuildAccessorsScalar(\@AA); | |||||||||
| 22 | |||||||||||
| 23 | 15 | ▶ | use Net::Frame::Layer::OSPF qw(:consts); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 24 | |||||||||||
| 25 | sub new { | ||||||||||
| 26 | shift->SUPER::new( | ||||||||||
| 27 | 1 | ▶ | checksum => 0, | ||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 28 | dataLength => 0, | ||||||||||
| 29 | tlvList => [], | ||||||||||
| 30 | @_, | ||||||||||
| 31 | ); | ||||||||||
| 32 | } | ||||||||||
| 33 | |||||||||||
| 34 | sub getLength { | ||||||||||
| 35 | #my $self = shift; | ||||||||||
| 36 | #my $len = 4; | ||||||||||
| 37 | #if ($self->rawTlv) { | ||||||||||
| 38 | #$len += length($self->rawTlv); | ||||||||||
| 39 | #} | ||||||||||
| 40 | #print "TLV LEN: $len\n"; | ||||||||||
| 41 | #$len; | ||||||||||
| 42 | 0 | ▶ | 0; | ||||||||
|
Subroutine
getLength: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 43 | } | ||||||||||
| 44 | |||||||||||
| 45 | sub pack { | ||||||||||
| 46 | 1 | ▶ | my $self = shift; | ||||||||
|
Subroutine
pack: called CC=4 SCAR=17.1
Pod
documented
| |||||||||||
| 47 | |||||||||||
| 48 | 1 | ▶ | my $raw = $self->SUPER::pack('nn', $self->checksum, $self->dataLength) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 49 | or return undef; | ||||||||||
| 50 | |||||||||||
| 51 | 1 | ▶ | if ($self->rawTlv) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 52 | 0 | ▶ | $raw .= $self->SUPER::pack('a*', $self->rawTlv) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 53 | or return undef; | ||||||||||
| 54 | } | ||||||||||
| 55 | |||||||||||
| 56 | 1 | $self->raw($raw); | |||||||||
| 57 | } | ||||||||||
| 58 | |||||||||||
| 59 | sub unpack { | ||||||||||
| 60 | 1 | ▶ | my $self = shift; | ||||||||
|
Subroutine
unpack: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||
| 61 | |||||||||||
| 62 | 1 | ▶ | my ($checksum, $dataLength, $payload) = | ||||||||
|
Branch: 1 branch
| |||||||||||
| 63 | $self->SUPER::unpack('nn a*', $self->raw) | ||||||||||
| 64 | or return undef; | ||||||||||
| 65 | |||||||||||
| 66 | 1 | $self->checksum($checksum); | |||||||||
| 67 | 1 | $self->dataLength($dataLength); | |||||||||
| 68 | |||||||||||
| 69 | # XXX: handle TLV | ||||||||||
| 70 | 1 | $self->rawTlv($payload); | |||||||||
| 71 | |||||||||||
| 72 | #$self->payload($payload); | ||||||||||
| 73 | |||||||||||
| 74 | 1 | $self; | |||||||||
| 75 | } | ||||||||||
| 76 | |||||||||||
| 77 | sub print { | ||||||||||
| 78 | 0 | ▶ | my $self = shift; | ||||||||
|
Subroutine
print: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 79 | |||||||||||
| 80 | 0 | my $l = $self->layer; | |||||||||
| 81 | 0 | sprintf | |||||||||
| 82 | "$l: checksum:0x%04x dataLength:%d\n". | ||||||||||
| 83 | "$l: rawTlv:%s", | ||||||||||
| 84 | $self->checksum, | ||||||||||
| 85 | $self->dataLength, | ||||||||||
| 86 | CORE::unpack('H*', $self->rawTlv), | ||||||||||
| 87 | ; | ||||||||||
| 88 | } | ||||||||||
| 89 | |||||||||||
| 90 | 15 | 1; | |||||||||
| 91 | |||||||||||
| 92 | __END__ | ||||||||||