| 1 | # | ||||||||||||||||||||||||||||
| 2 | # $Id: Network.pm 73 2015-01-14 06:42:49Z gomor $ | ||||||||||||||||||||||||||||
| 3 | # | ||||||||||||||||||||||||||||
| 4 | package Net::Frame::Layer::OSPF::Lsa::Network; | ||||||||||||||||||||||||||||
| 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 | netmask | ||||||||||||||||||||||||||||
| 12 | ); | ||||||||||||||||||||||||||||
| 13 | 15 | our @AA = qw( | |||||||||||||||||||||||||||
| 14 | routerList | ||||||||||||||||||||||||||||
| 15 | ); | ||||||||||||||||||||||||||||
| 16 | 15 | __PACKAGE__->cgBuildIndices; | |||||||||||||||||||||||||||
| 17 | 15 | __PACKAGE__->cgBuildAccessorsScalar(\@AS); | |||||||||||||||||||||||||||
| 18 | 15 | __PACKAGE__->cgBuildAccessorsArray (\@AA); | |||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 15 | ▶ | use Net::Frame::Layer::OSPF qw(:consts); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | 1 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 23 | shift->SUPER::new( | ||||||||||||||||||||||||||||
| 24 | 1 | netmask => '255.255.255.0', | |||||||||||||||||||||||||||
| 25 | routerList => [], | ||||||||||||||||||||||||||||
| 26 | @_, | ||||||||||||||||||||||||||||
| 27 | ); | ||||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | 0 | ▶ | sub getLength { | ||||||||||||||||||||||||||
|
Subroutine
getLength: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 31 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 32 | 0 | my $len = 4; | |||||||||||||||||||||||||||
| 33 | 0 | $len += 4 for $self->routerList; | |||||||||||||||||||||||||||
| 34 | 0 | $len; | |||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | 1 | ▶ | sub pack { | ||||||||||||||||||||||||||
|
Subroutine
pack: called CC=4 SCAR=16.9
Pod
documented
| |||||||||||||||||||||||||||||
| 38 | 1 | my $self = shift; | |||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | 1 | ▶ | my $raw = $self->SUPER::pack('a4', inetAton($self->netmask)) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 41 | or return undef; | ||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | 1 | for ($self->routerList) { | |||||||||||||||||||||||||||
| 44 | 0 | ▶ | $raw .= $self->SUPER::pack('a4', inetAton($_)) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 45 | or return undef; | ||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | 1 | $self->raw($raw); | |||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | 1 | ▶ | sub unpack { | ||||||||||||||||||||||||||
|
Subroutine
unpack: called CC=5 SCAR=19.8
Pod
documented
| |||||||||||||||||||||||||||||
| 52 | 1 | my $self = shift; | |||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | 1 | ▶ | my ($netmask, $payload) = $self->SUPER::unpack('a4 a*', $self->raw) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 55 | or return undef; | ||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | 1 | $self->netmask(inetNtoa($netmask)); | |||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | 1 | my @routerList; | |||||||||||||||||||||||||||
| 60 | 1 | ▶ | while ($payload && length($payload) > 3) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$payload and length $payload > 3
MC/DC0%0/2
$payload and length $payload > 3
$payload
length $payload > 3
Truth table33%1/3
A and B
A= $payloadB= length $payload > 3
| |||||||||||||||||||||||||||||
| 61 | 0 | my $ip; | |||||||||||||||||||||||||||
| 62 | 0 | ▶ | ($ip, $payload) = $self->SUPER::unpack('a4 a*', $payload) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 63 | or return undef; | ||||||||||||||||||||||||||||
| 64 | 0 | push @routerList, inetNtoa($ip); | |||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||
| 66 | 1 | $self->routerList(\@routerList); | |||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | 1 | $self->payload($payload); | |||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | 1 | $self; | |||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | 0 | ▶ | sub print { | ||||||||||||||||||||||||||
|
Subroutine
print: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 74 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | 0 | my $l = $self->layer; | |||||||||||||||||||||||||||
| 77 | 0 | my $buf = sprintf | |||||||||||||||||||||||||||
| 78 | "$l: netmask:%s", | ||||||||||||||||||||||||||||
| 79 | $self->netmask, | ||||||||||||||||||||||||||||
| 80 | ; | ||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | 0 | for ($self->routerList) { | |||||||||||||||||||||||||||
| 83 | 0 | $buf .= sprintf "\n$l: router: %s", $_; | |||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | 0 | $buf; | |||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | 15 | 1; | |||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | __END__ | ||||||||||||||||||||||||||||