| 1 | # | ||||||||||||||||||||||||||||
| 2 | # $Id: DatabaseDesc.pm,v 1.3 2007/02/25 20:40:14 gomor Exp $ | ||||||||||||||||||||||||||||
| 3 | # | ||||||||||||||||||||||||||||
| 4 | package Net::Frame::Layer::OSPF::DatabaseDesc; | ||||||||||||||||||||||||||||
| 5 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 3 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 3 | ▶ | use Net::Frame::Layer qw(:consts :subs); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 3 | our @ISA = qw(Net::Frame::Layer); | |||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 3 | our @AS = qw( | |||||||||||||||||||||||||||
| 12 | interfaceMtu | ||||||||||||||||||||||||||||
| 13 | options | ||||||||||||||||||||||||||||
| 14 | flags | ||||||||||||||||||||||||||||
| 15 | ddSequenceNumber | ||||||||||||||||||||||||||||
| 16 | ); | ||||||||||||||||||||||||||||
| 17 | 3 | our @AA = qw( | |||||||||||||||||||||||||||
| 18 | lsaList | ||||||||||||||||||||||||||||
| 19 | ); | ||||||||||||||||||||||||||||
| 20 | 3 | __PACKAGE__->cgBuildIndices; | |||||||||||||||||||||||||||
| 21 | 3 | __PACKAGE__->cgBuildAccessorsScalar(\@AS); | |||||||||||||||||||||||||||
| 22 | 3 | __PACKAGE__->cgBuildAccessorsArray (\@AA); | |||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | 3 | ▶ | use Net::Frame::Layer::OSPF qw(:consts); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 25 | 3 | require Net::Frame::Layer::OSPF::Lsa; | |||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | sub new { | ||||||||||||||||||||||||||||
| 28 | shift->SUPER::new( | ||||||||||||||||||||||||||||
| 29 | 0 | ▶ | interfaceMtu => 1500, | ||||||||||||||||||||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 30 | options => 0, | ||||||||||||||||||||||||||||
| 31 | flags => 0, | ||||||||||||||||||||||||||||
| 32 | ddSequenceNumber => 1, | ||||||||||||||||||||||||||||
| 33 | lsaList => [], | ||||||||||||||||||||||||||||
| 34 | @_, | ||||||||||||||||||||||||||||
| 35 | ); | ||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | sub getLength { | ||||||||||||||||||||||||||||
| 39 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
getLength: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 40 | 0 | my $len = 8; | |||||||||||||||||||||||||||
| 41 | 0 | for ($self->lsaList) { | |||||||||||||||||||||||||||
| 42 | 0 | $len += $_->getLength; | |||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||
| 44 | 0 | $len; | |||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | sub pack { | ||||||||||||||||||||||||||||
| 48 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
pack: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | 0 | ▶ | my $raw = $self->SUPER::pack('nCCN', | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 51 | $self->interfaceMtu, $self->options, $self->flags, | ||||||||||||||||||||||||||||
| 52 | $self->ddSequenceNumber, | ||||||||||||||||||||||||||||
| 53 | ) or return undef; | ||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | 0 | for ($self->lsaList) { | |||||||||||||||||||||||||||
| 56 | 0 | ▶ | $raw .= $_->pack or return undef; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | 0 | $self->raw($raw); | |||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | sub unpack { | ||||||||||||||||||||||||||||
| 63 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
unpack: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | 0 | ▶ | my ($interfaceMtu, $options, $flags, $ddSequenceNumber, $payload) = | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 66 | $self->SUPER::unpack('nCCN a*', $self->raw) | ||||||||||||||||||||||||||||
| 67 | or return undef; | ||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | 0 | $self->interfaceMtu($interfaceMtu); | |||||||||||||||||||||||||||
| 70 | 0 | $self->options($options); | |||||||||||||||||||||||||||
| 71 | 0 | $self->flags($flags); | |||||||||||||||||||||||||||
| 72 | 0 | $self->ddSequenceNumber($ddSequenceNumber); | |||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | 0 | my @lsaList = (); | |||||||||||||||||||||||||||
| 75 | 0 | ▶ | if ($payload) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 76 | 0 | my $count; | |||||||||||||||||||||||||||
| 77 | 0 | ▶ | while ($payload || (++$count > 100)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$payload or ++$count > 100
MC/DC0%0/2
$payload or ++$count > 100
$payload
++$count > 100
Truth table0%0/3
A or B
A= $payloadB= ++$count > 100
| |||||||||||||||||||||||||||||
| 78 | 0 | ▶ | my $lsa = Net::Frame::Layer::OSPF::Lsa->new( | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 79 | raw => $payload, | ||||||||||||||||||||||||||||
| 80 | full => 0, | ||||||||||||||||||||||||||||
| 81 | ) or last; | ||||||||||||||||||||||||||||
| 82 | 0 | $lsa->unpack; | |||||||||||||||||||||||||||
| 83 | 0 | $payload = $lsa->payload; | |||||||||||||||||||||||||||
| 84 | 0 | push @lsaList, $lsa; | |||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | 0 | $self->lsaList(\@lsaList); | |||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | 0 | $self->payload($payload); | |||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | 0 | $self; | |||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||
| 95 | sub print { | ||||||||||||||||||||||||||||
| 96 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
print: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | 0 | my $l = $self->layer; | |||||||||||||||||||||||||||
| 99 | 0 | my $buf = sprintf | |||||||||||||||||||||||||||
| 100 | "$l: interfaceMtu:%d options:0x%02x flags:0x%02x\n". | ||||||||||||||||||||||||||||
| 101 | "$l: ddSequenceNumber:%d", | ||||||||||||||||||||||||||||
| 102 | $self->interfaceMtu, | ||||||||||||||||||||||||||||
| 103 | $self->options, | ||||||||||||||||||||||||||||
| 104 | $self->flags, | ||||||||||||||||||||||||||||
| 105 | $self->ddSequenceNumber, | ||||||||||||||||||||||||||||
| 106 | ; | ||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | 0 | for ($self->lsaList) { | |||||||||||||||||||||||||||
| 109 | 0 | $buf .= "\n".$_->print; | |||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||
| 112 | 0 | $buf; | |||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||
| 115 | 3 | 1; | |||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||
| 117 | __END__ | ||||||||||||||||||||||||||||