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