| 1 | # | ||||||||||||||||||||||||||||||||||||
| 2 | # $Id: OSPF.pm 73 2015-01-14 06:42:49Z gomor $ | ||||||||||||||||||||||||||||||||||||
| 3 | # | ||||||||||||||||||||||||||||||||||||
| 4 | package Net::Frame::Layer::OSPF; | ||||||||||||||||||||||||||||||||||||
| 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 | our $VERSION = '1.01'; | |||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||
| 9 | 15 | ▶ | use Net::Frame::Layer qw(:consts :subs); | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 10 | 15 | require Exporter; | |||||||||||||||||||||||||||||||||||
| 11 | 15 | our @ISA = qw(Net::Frame::Layer Exporter); | |||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||
| 13 | 15 | our %EXPORT_TAGS = ( | |||||||||||||||||||||||||||||||||||
| 14 | consts => [qw( | ||||||||||||||||||||||||||||||||||||
| 15 | NF_OSPF_HDR_LEN | ||||||||||||||||||||||||||||||||||||
| 16 | NF_OSPF_TYPE_HELLO | ||||||||||||||||||||||||||||||||||||
| 17 | NF_OSPF_TYPE_DATABASEDESC | ||||||||||||||||||||||||||||||||||||
| 18 | NF_OSPF_TYPE_LINKSTATEREQUEST | ||||||||||||||||||||||||||||||||||||
| 19 | NF_OSPF_TYPE_LINKSTATEUPDATE | ||||||||||||||||||||||||||||||||||||
| 20 | NF_OSPF_TYPE_LINKSTATEACK | ||||||||||||||||||||||||||||||||||||
| 21 | NF_OSPF_AUTHTYPE_NULL | ||||||||||||||||||||||||||||||||||||
| 22 | NF_OSPF_AUTHTYPE_SIMPLE | ||||||||||||||||||||||||||||||||||||
| 23 | NF_OSPF_AUTHTYPE_CRYPTO | ||||||||||||||||||||||||||||||||||||
| 24 | NF_OSPF_LSA_HDR_LEN | ||||||||||||||||||||||||||||||||||||
| 25 | NF_OSPF_LSTYPE_ROUTER | ||||||||||||||||||||||||||||||||||||
| 26 | NF_OSPF_LSTYPE_NETWORK | ||||||||||||||||||||||||||||||||||||
| 27 | NF_OSPF_LSTYPE_SUMMARYIP | ||||||||||||||||||||||||||||||||||||
| 28 | NF_OSPF_LSTYPE_SUMMARYASBR | ||||||||||||||||||||||||||||||||||||
| 29 | NF_OSPF_LSTYPE_ASEXTERNAL | ||||||||||||||||||||||||||||||||||||
| 30 | NF_OSPF_LSTYPE_OPAQUELINKLOCAL | ||||||||||||||||||||||||||||||||||||
| 31 | NF_OSPF_LSTYPE_OPAQUEAREALOCAL | ||||||||||||||||||||||||||||||||||||
| 32 | NF_OSPF_LSTYPE_OPAQUEDOMAIN | ||||||||||||||||||||||||||||||||||||
| 33 | NF_OSPF_HELLO_OPTIONS_UNK | ||||||||||||||||||||||||||||||||||||
| 34 | NF_OSPF_HELLO_OPTIONS_E | ||||||||||||||||||||||||||||||||||||
| 35 | NF_OSPF_HELLO_OPTIONS_MC | ||||||||||||||||||||||||||||||||||||
| 36 | NF_OSPF_HELLO_OPTIONS_NP | ||||||||||||||||||||||||||||||||||||
| 37 | NF_OSPF_HELLO_OPTIONS_EA | ||||||||||||||||||||||||||||||||||||
| 38 | NF_OSPF_HELLO_OPTIONS_DC | ||||||||||||||||||||||||||||||||||||
| 39 | NF_OSPF_HELLO_OPTIONS_O | ||||||||||||||||||||||||||||||||||||
| 40 | NF_OSPF_HELLO_OPTIONS_DN | ||||||||||||||||||||||||||||||||||||
| 41 | NF_OSPF_DATABASEDESC_OPTIONS_DN | ||||||||||||||||||||||||||||||||||||
| 42 | NF_OSPF_DATABASEDESC_OPTIONS_0 | ||||||||||||||||||||||||||||||||||||
| 43 | NF_OSPF_DATABASEDESC_OPTIONS_DC | ||||||||||||||||||||||||||||||||||||
| 44 | NF_OSPF_DATABASEDESC_OPTIONS_L | ||||||||||||||||||||||||||||||||||||
| 45 | NF_OSPF_DATABASEDESC_OPTIONS_NP | ||||||||||||||||||||||||||||||||||||
| 46 | NF_OSPF_DATABASEDESC_OPTIONS_MC | ||||||||||||||||||||||||||||||||||||
| 47 | NF_OSPF_DATABASEDESC_OPTIONS_E | ||||||||||||||||||||||||||||||||||||
| 48 | NF_OSPF_DATABASEDESC_FLAGS_MS | ||||||||||||||||||||||||||||||||||||
| 49 | NF_OSPF_DATABASEDESC_FLAGS_M | ||||||||||||||||||||||||||||||||||||
| 50 | NF_OSPF_DATABASEDESC_FLAGS_I | ||||||||||||||||||||||||||||||||||||
| 51 | )], | ||||||||||||||||||||||||||||||||||||
| 52 | ); | ||||||||||||||||||||||||||||||||||||
| 53 | our @EXPORT_OK = ( | ||||||||||||||||||||||||||||||||||||
| 54 | 15 | @{$EXPORT_TAGS{consts}}, | |||||||||||||||||||||||||||||||||||
| 55 | ); | ||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||
| 57 | 15 | ▶ | use constant NF_OSPF_HDR_LEN => 24; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 58 | 15 | ▶ | use constant NF_OSPF_LSA_HDR_LEN => 20; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||
| 60 | 15 | ▶ | use constant NF_OSPF_TYPE_HELLO => 0x01; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 61 | 15 | ▶ | use constant NF_OSPF_TYPE_DATABASEDESC => 0x02; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 62 | 15 | ▶ | use constant NF_OSPF_TYPE_LINKSTATEREQUEST => 0x03; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 63 | 15 | ▶ | use constant NF_OSPF_TYPE_LINKSTATEUPDATE => 0x04; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 64 | 15 | ▶ | use constant NF_OSPF_TYPE_LINKSTATEACK => 0x05; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||
| 66 | 15 | ▶ | use constant NF_OSPF_AUTHTYPE_NULL => 0x0000; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 67 | 15 | ▶ | use constant NF_OSPF_AUTHTYPE_SIMPLE => 0x0001; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 68 | 15 | ▶ | use constant NF_OSPF_AUTHTYPE_CRYPTO => 0x0002; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||
| 70 | 15 | ▶ | use constant NF_OSPF_LSTYPE_ROUTER => 0x01; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 71 | 15 | ▶ | use constant NF_OSPF_LSTYPE_NETWORK => 0x02; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 72 | 15 | ▶ | use constant NF_OSPF_LSTYPE_SUMMARYIP => 0x03; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 73 | 15 | ▶ | use constant NF_OSPF_LSTYPE_SUMMARYASBR => 0x04; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 74 | 15 | ▶ | use constant NF_OSPF_LSTYPE_ASEXTERNAL => 0x05; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 75 | 15 | ▶ | use constant NF_OSPF_LSTYPE_OPAQUELINKLOCAL => 0x0a; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 76 | 15 | ▶ | use constant NF_OSPF_LSTYPE_OPAQUEAREALOCAL => 0x0b; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 77 | 15 | ▶ | use constant NF_OSPF_LSTYPE_OPAQUEDOMAIN => 0x0c; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||
| 79 | 15 | ▶ | use constant NF_OSPF_HELLO_OPTIONS_UNK => 0x01; # Not in RFC 2328 | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 80 | 15 | ▶ | use constant NF_OSPF_HELLO_OPTIONS_E => 0x02; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 81 | 15 | ▶ | use constant NF_OSPF_HELLO_OPTIONS_MC => 0x04; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 82 | 15 | ▶ | use constant NF_OSPF_HELLO_OPTIONS_NP => 0x08; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 83 | 15 | ▶ | use constant NF_OSPF_HELLO_OPTIONS_EA => 0x10; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 84 | 15 | ▶ | use constant NF_OSPF_HELLO_OPTIONS_DC => 0x20; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 85 | 15 | ▶ | use constant NF_OSPF_HELLO_OPTIONS_O => 0x40; # Not in RFC 2328 | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 86 | 15 | ▶ | use constant NF_OSPF_HELLO_OPTIONS_DN => 0x80; # Not in RFC 2328 | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||
| 88 | 15 | ▶ | use constant NF_OSPF_DATABASEDESC_OPTIONS_DN => 0x01; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 89 | 15 | ▶ | use constant NF_OSPF_DATABASEDESC_OPTIONS_0 => 0x02; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 90 | 15 | ▶ | use constant NF_OSPF_DATABASEDESC_OPTIONS_DC => 0x04; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 91 | 15 | ▶ | use constant NF_OSPF_DATABASEDESC_OPTIONS_L => 0x08; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 92 | 15 | ▶ | use constant NF_OSPF_DATABASEDESC_OPTIONS_NP => 0x10; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 93 | 15 | ▶ | use constant NF_OSPF_DATABASEDESC_OPTIONS_MC => 0x20; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 94 | 15 | ▶ | use constant NF_OSPF_DATABASEDESC_OPTIONS_E => 0x40; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||
| 96 | 15 | ▶ | use constant NF_OSPF_DATABASEDESC_FLAGS_MS => 0x01; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 97 | 15 | ▶ | use constant NF_OSPF_DATABASEDESC_FLAGS_M => 0x02; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 98 | 15 | ▶ | use constant NF_OSPF_DATABASEDESC_FLAGS_I => 0x04; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||
| 100 | 15 | our @AS = qw( | |||||||||||||||||||||||||||||||||||
| 101 | version | ||||||||||||||||||||||||||||||||||||
| 102 | type | ||||||||||||||||||||||||||||||||||||
| 103 | length | ||||||||||||||||||||||||||||||||||||
| 104 | routerId | ||||||||||||||||||||||||||||||||||||
| 105 | areaId | ||||||||||||||||||||||||||||||||||||
| 106 | checksum | ||||||||||||||||||||||||||||||||||||
| 107 | authType | ||||||||||||||||||||||||||||||||||||
| 108 | authData | ||||||||||||||||||||||||||||||||||||
| 109 | packet | ||||||||||||||||||||||||||||||||||||
| 110 | ); | ||||||||||||||||||||||||||||||||||||
| 111 | 15 | __PACKAGE__->cgBuildIndices; | |||||||||||||||||||||||||||||||||||
| 112 | 15 | __PACKAGE__->cgBuildAccessorsScalar(\@AS); | |||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||
| 114 | 15 | require Net::Frame::Layer::OSPF::Hello; | |||||||||||||||||||||||||||||||||||
| 115 | 15 | require Net::Frame::Layer::OSPF::DatabaseDesc; | |||||||||||||||||||||||||||||||||||
| 116 | 15 | require Net::Frame::Layer::OSPF::LinkStateUpdate; | |||||||||||||||||||||||||||||||||||
| 117 | 15 | require Net::Frame::Layer::OSPF::LinkStateRequest; | |||||||||||||||||||||||||||||||||||
| 118 | 15 | require Net::Frame::Layer::OSPF::LinkStateAck; | |||||||||||||||||||||||||||||||||||
| 119 | 15 | require Net::Frame::Layer::OSPF::Lls; | |||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||
| 121 | 1 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||
| 122 | shift->SUPER::new( | ||||||||||||||||||||||||||||||||||||
| 123 | 1 | version => 2, | |||||||||||||||||||||||||||||||||||
| 124 | type => 0, | ||||||||||||||||||||||||||||||||||||
| 125 | length => NF_OSPF_HDR_LEN, | ||||||||||||||||||||||||||||||||||||
| 126 | routerId => '127.0.0.1', | ||||||||||||||||||||||||||||||||||||
| 127 | areaId => '127.0.0.1', | ||||||||||||||||||||||||||||||||||||
| 128 | checksum => 0, | ||||||||||||||||||||||||||||||||||||
| 129 | authType => NF_OSPF_AUTHTYPE_NULL, | ||||||||||||||||||||||||||||||||||||
| 130 | authData => "0000000000000000", | ||||||||||||||||||||||||||||||||||||
| 131 | @_, | ||||||||||||||||||||||||||||||||||||
| 132 | ); | ||||||||||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||
| 135 | 0 | ▶ | sub match { | ||||||||||||||||||||||||||||||||||
|
Subroutine
match: not called CC=15 SCAR=54.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||
| 136 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||
| 137 | 0 | my ($with) = @_; | |||||||||||||||||||||||||||||||||||
| 138 | 0 | ▶ | if ($self->packet && $with->packet) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->packet and $with->packet
MC/DC0%0/2
$self->packet and $with->packet
$self->packet
$with->packet
Truth table0%0/3
A and B
A= $self->packetB= $with->packet
| |||||||||||||||||||||||||||||||||||||
| 139 | 0 | my $s = $self->packet->layer; | |||||||||||||||||||||||||||||||||||
| 140 | 0 | my $sHdr = $self->packet; | |||||||||||||||||||||||||||||||||||
| 141 | 0 | my $w = $with->packet->layer; | |||||||||||||||||||||||||||||||||||
| 142 | 0 | my $wHdr = $with->packet; | |||||||||||||||||||||||||||||||||||
| 143 | 0 | ▶ | if (($s eq 'OSPF::Hello') && ($w eq 'OSPF::DatabaseDesc')) { | ||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition0%0/3
$s eq "OSPF::Hello" and $w eq "OSPF::DatabaseDesc"
MC/DC0%0/2
$s eq "OSPF::Hello" and $w eq "OSPF::DatabaseDesc"
$s eq "OSPF::Hello"
$w eq "OSPF::DatabaseDesc"
Truth table0%0/3
A and B
A= $s eq "OSPF::Hello"B= $w eq "OSPF::DatabaseDesc"
| |||||||||||||||||||||||||||||||||||||
| 144 | 0 | return 1; | |||||||||||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||||||||||
| 146 | ▶ | elsif (($s eq 'OSPF::DatabaseDesc') && ($w eq 'OSPF::DatabaseDesc')) { | |||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$s eq "OSPF::DatabaseDesc" and $w eq "OSPF::DatabaseDesc"
MC/DC0%0/2
$s eq "OSPF::DatabaseDesc" and $w eq "OSPF::DatabaseDesc"
$s eq "OSPF::DatabaseDesc"
$w eq "OSPF::DatabaseDesc"
Truth table0%0/3
A and B
A= $s eq "OSPF::DatabaseDesc"B= $w eq "OSPF::DatabaseDesc"
| |||||||||||||||||||||||||||||||||||||
| 147 | 0 | ▶ | if ($sHdr->flags == 0x07 && $wHdr->flags == 0x02) { | ||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition0%0/3
$sHdr->flags == 7 and $wHdr->flags == 2
MC/DC0%0/2
$sHdr->flags == 7 and $wHdr->flags == 2
$sHdr->flags == 7
$wHdr->flags == 2
Truth table0%0/3
A and B
A= $sHdr->flags == 7B= $wHdr->flags == 2
| |||||||||||||||||||||||||||||||||||||
| 148 | 0 | return 1; | |||||||||||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||||||||||
| 150 | ▶ | elsif ($sHdr->flags == 0x03 && $wHdr->flags == 0x00) { | |||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$sHdr->flags == 3 and $wHdr->flags == 0
MC/DC0%0/2
$sHdr->flags == 3 and $wHdr->flags == 0
$sHdr->flags == 3
$wHdr->flags == 0
Truth table0%0/3
A and B
A= $sHdr->flags == 3B= $wHdr->flags == 0
| |||||||||||||||||||||||||||||||||||||
| 151 | 0 | return 1; | |||||||||||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||||||||||
| 153 | ▶ | elsif ($sHdr->flags == 0x01 && $wHdr->flags == 0x00) { | |||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$sHdr->flags == 1 and $wHdr->flags == 0
MC/DC0%0/2
$sHdr->flags == 1 and $wHdr->flags == 0
$sHdr->flags == 1
$wHdr->flags == 0
Truth table0%0/3
A and B
A= $sHdr->flags == 1B= $wHdr->flags == 0
| |||||||||||||||||||||||||||||||||||||
| 154 | 0 | return 1; | |||||||||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||||||||||
| 157 | ▶ | elsif (($s eq 'OSPF::LinkStateRequest') | |||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$s eq "OSPF::LinkStateRequest" and $w eq "OSPF::LinkStateRequest"
MC/DC0%0/2
$s eq "OSPF::LinkStateRequest" and $w eq "OSPF::LinkStateRequest"
$s eq "OSPF::LinkStateRequest"
$w eq "OSPF::LinkStateRequest"
Truth table0%0/3
A and B
A= $s eq "OSPF::LinkStateRequest"B= $w eq "OSPF::LinkStateRequest"
| |||||||||||||||||||||||||||||||||||||
| 158 | && ($w eq 'OSPF::LinkStateRequest')) { | ||||||||||||||||||||||||||||||||||||
| 159 | 0 | return 1; | |||||||||||||||||||||||||||||||||||
| 160 | } | ||||||||||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||||||||||
| 162 | 0 | 0; | |||||||||||||||||||||||||||||||||||
| 163 | } | ||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||
| 165 | 0 | ▶ | sub getLength { shift->length } | ||||||||||||||||||||||||||||||||||
|
Subroutine
getLength: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||
| 167 | 0 | ▶ | sub computeLengths { | ||||||||||||||||||||||||||||||||||
|
Subroutine
computeLengths: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||
| 168 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||
| 169 | 0 | my $len = $self->getLength; | |||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||||
| 171 | # If packet is not a ref, it is not an object, but a raw data (LinkStateAck) | ||||||||||||||||||||||||||||||||||||
| 172 | 0 | ▶ | if ($self->packet && ! ref($self->packet)) { | ||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
$self->packet and not ref $self->packet
MC/DC0%0/2
$self->packet and not ref $self->packet
$self->packet
not ref $self->packet
Truth table0%0/3
A and not(B)
A= $self->packetB= not ref $self->packet
| |||||||||||||||||||||||||||||||||||||
| 173 | 0 | $len += length($self->packet); | |||||||||||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||||||||||
| 175 | # Else, standard object | ||||||||||||||||||||||||||||||||||||
| 176 | elsif ($self->packet) { | ||||||||||||||||||||||||||||||||||||
| 177 | 0 | $len += $self->packet->getLength; | |||||||||||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||||||||||
| 179 | 0 | $self->length($len); | |||||||||||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||||||
| 182 | 0 | ▶ | sub computeChecksums { | ||||||||||||||||||||||||||||||||||
|
Subroutine
computeChecksums: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||
| 183 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||
| 185 | # When simple password auth is used, we MUST calculate | ||||||||||||||||||||||||||||||||||||
| 186 | # the checksum without the plaintext password | ||||||||||||||||||||||||||||||||||||
| 187 | 0 | my $authData = $self->authData; | |||||||||||||||||||||||||||||||||||
| 188 | 0 | $self->authData("0000000000000000"); | |||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||
| 190 | 0 | $self->checksum(0); | |||||||||||||||||||||||||||||||||||
| 191 | 0 | $self->checksum(inetChecksum($self->pack)); | |||||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||||
| 193 | # Restore the simple password | ||||||||||||||||||||||||||||||||||||
| 194 | 0 | $self->authData($authData); | |||||||||||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||
| 197 | 1 | ▶ | sub pack { | ||||||||||||||||||||||||||||||||||
|
Subroutine
pack: called CC=5 SCAR=20.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||
| 198 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||
| 200 | 1 | ▶ | my $raw = $self->SUPER::pack('CCna4a4nnH16', | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 201 | $self->version, $self->type, $self->length, | ||||||||||||||||||||||||||||||||||||
| 202 | inetAton($self->routerId), inetAton($self->areaId), | ||||||||||||||||||||||||||||||||||||
| 203 | $self->checksum, $self->authType, $self->authData, | ||||||||||||||||||||||||||||||||||||
| 204 | ) or return undef; | ||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||
| 206 | 1 | ▶ | if ($self->packet && ref($self->packet)) { | ||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%1/3
$self->packet and ref $self->packet
MC/DC0%0/2
$self->packet and ref $self->packet
$self->packet
ref $self->packet
Truth table33%1/3
A and B
A= $self->packetB= ref $self->packet
| |||||||||||||||||||||||||||||||||||||
| 207 | 0 | $raw .= $self->packet->pack; | |||||||||||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||||||||||
| 209 | elsif ($self->packet) { | ||||||||||||||||||||||||||||||||||||
| 210 | 0 | $raw .= $self->packet; | |||||||||||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||||||
| 213 | 1 | $self->raw($raw); | |||||||||||||||||||||||||||||||||||
| 214 | } | ||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||
| 216 | 1 | ▶ | sub unpack { | ||||||||||||||||||||||||||||||||||
|
Subroutine
unpack: called CC=15 SCAR=45.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||
| 217 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||||
| 219 | 1 | ▶ | my ($version, $type, $length, $routerId, $areaId, $checksum, | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 220 | $authType, $authData, $payload) = | ||||||||||||||||||||||||||||||||||||
| 221 | $self->SUPER::unpack('CCna4a4nnH16 a*', $self->raw) | ||||||||||||||||||||||||||||||||||||
| 222 | or return undef; | ||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||
| 224 | 1 | $self->version($version); | |||||||||||||||||||||||||||||||||||
| 225 | 1 | $self->type($type); | |||||||||||||||||||||||||||||||||||
| 226 | 1 | $self->length($length); | |||||||||||||||||||||||||||||||||||
| 227 | 1 | $self->routerId(inetNtoa($routerId)); | |||||||||||||||||||||||||||||||||||
| 228 | 1 | $self->areaId(inetNtoa($areaId)); | |||||||||||||||||||||||||||||||||||
| 229 | 1 | $self->checksum($checksum); | |||||||||||||||||||||||||||||||||||
| 230 | 1 | $self->authType($authType); | |||||||||||||||||||||||||||||||||||
| 231 | 1 | $self->authData($authData); | |||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||
| 233 | 1 | my $keep = $length - NF_OSPF_HDR_LEN; | |||||||||||||||||||||||||||||||||||
| 234 | 1 | my $tail = substr($payload, 0, $keep); | |||||||||||||||||||||||||||||||||||
| 235 | 1 | $payload = substr($payload, $keep); | |||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||
| 237 | # Handle type of OSPF frame | ||||||||||||||||||||||||||||||||||||
| 238 | 1 | my $next; | |||||||||||||||||||||||||||||||||||
| 239 | 1 | ▶ | if ($tail) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 240 | 0 | ▶ | if ($type == NF_OSPF_TYPE_HELLO) { | ||||||||||||||||||||||||||||||||||
|
Branch: 5 branches
| |||||||||||||||||||||||||||||||||||||
| 241 | 0 | $next = Net::Frame::Layer::OSPF::Hello->new(raw => $tail); | |||||||||||||||||||||||||||||||||||
| 242 | } | ||||||||||||||||||||||||||||||||||||
| 243 | elsif ($type == NF_OSPF_TYPE_DATABASEDESC) { | ||||||||||||||||||||||||||||||||||||
| 244 | 0 | $next = Net::Frame::Layer::OSPF::DatabaseDesc->new(raw => $tail); | |||||||||||||||||||||||||||||||||||
| 245 | } | ||||||||||||||||||||||||||||||||||||
| 246 | elsif ($type == NF_OSPF_TYPE_LINKSTATEUPDATE) { | ||||||||||||||||||||||||||||||||||||
| 247 | 0 | $next = Net::Frame::Layer::OSPF::LinkStateUpdate->new(raw => $tail); | |||||||||||||||||||||||||||||||||||
| 248 | } | ||||||||||||||||||||||||||||||||||||
| 249 | elsif ($type == NF_OSPF_TYPE_LINKSTATEREQUEST) { | ||||||||||||||||||||||||||||||||||||
| 250 | 0 | $next = Net::Frame::Layer::OSPF::LinkStateRequest->new(raw => $tail); | |||||||||||||||||||||||||||||||||||
| 251 | } | ||||||||||||||||||||||||||||||||||||
| 252 | elsif ($type == NF_OSPF_TYPE_LINKSTATEACK) { | ||||||||||||||||||||||||||||||||||||
| 253 | 0 | $next = Net::Frame::Layer::OSPF::LinkStateAck->new(raw => $tail); | |||||||||||||||||||||||||||||||||||
| 254 | } | ||||||||||||||||||||||||||||||||||||
| 255 | } | ||||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||||
| 257 | 1 | ▶ | if ($next) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 258 | 0 | $next->unpack; | |||||||||||||||||||||||||||||||||||
| 259 | 0 | my $newPayload = $next->payload; | |||||||||||||||||||||||||||||||||||
| 260 | 0 | ▶ | if ($payload) { $newPayload .= $payload } | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 261 | 0 | $next->payload($newPayload); | |||||||||||||||||||||||||||||||||||
| 262 | 0 | $self->packet($next); | |||||||||||||||||||||||||||||||||||
| 263 | 0 | $payload = $next->payload; | |||||||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||||||||
| 265 | 0 | ▶ | if ($payload) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 266 | # Handle special options for OSPF::Hello frame | ||||||||||||||||||||||||||||||||||||
| 267 | 0 | ▶ | if ($next->layer eq 'OSPF::Hello') { | ||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||
| 268 | 0 | ▶ | if ($next->options & NF_OSPF_HELLO_OPTIONS_EA) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 269 | 0 | my $lls = Net::Frame::Layer::OSPF::Lls->new(raw => $payload); | |||||||||||||||||||||||||||||||||||
| 270 | 0 | $lls->unpack; | |||||||||||||||||||||||||||||||||||
| 271 | 0 | $next->lls($lls); | |||||||||||||||||||||||||||||||||||
| 272 | 0 | $payload = $lls->payload; | |||||||||||||||||||||||||||||||||||
| 273 | } | ||||||||||||||||||||||||||||||||||||
| 274 | } | ||||||||||||||||||||||||||||||||||||
| 275 | # Handle special options for OSPF::DatabaseDesc frame | ||||||||||||||||||||||||||||||||||||
| 276 | elsif ($next->layer eq 'OSPF::DatabaseDesc') { | ||||||||||||||||||||||||||||||||||||
| 277 | # XXX: ugly hack, should rework | ||||||||||||||||||||||||||||||||||||
| 278 | 0 | ▶ | if ($next->options == 0x52) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 279 | 0 | my $lls = Net::Frame::Layer::OSPF::Lls->new(raw => $payload); | |||||||||||||||||||||||||||||||||||
| 280 | 0 | $lls->unpack; | |||||||||||||||||||||||||||||||||||
| 281 | 0 | $next->lls($lls); | |||||||||||||||||||||||||||||||||||
| 282 | 0 | $payload = $lls->payload; | |||||||||||||||||||||||||||||||||||
| 283 | } | ||||||||||||||||||||||||||||||||||||
| 284 | } | ||||||||||||||||||||||||||||||||||||
| 285 | } | ||||||||||||||||||||||||||||||||||||
| 286 | } | ||||||||||||||||||||||||||||||||||||
| 287 | else { | ||||||||||||||||||||||||||||||||||||
| 288 | 1 | $payload = $tail.$payload; | |||||||||||||||||||||||||||||||||||
| 289 | } | ||||||||||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||||||||||
| 291 | 1 | $self->payload($payload); | |||||||||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||||||||||
| 293 | 1 | $self; | |||||||||||||||||||||||||||||||||||
| 294 | } | ||||||||||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||||||||||
| 296 | 0 | ▶ | sub encapsulate { shift->nextLayer } | ||||||||||||||||||||||||||||||||||
|
Subroutine
encapsulate: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||||||||||
| 298 | 0 | ▶ | sub print { | ||||||||||||||||||||||||||||||||||
|
Subroutine
print: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||
| 299 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||||||||||
| 301 | 0 | my $l = $self->layer; | |||||||||||||||||||||||||||||||||||
| 302 | 0 | my $buf = sprintf "$l: version:%d type:0x%02x length:%d\n". | |||||||||||||||||||||||||||||||||||
| 303 | "$l: routerId:%s areaId:%s\n". | ||||||||||||||||||||||||||||||||||||
| 304 | "$l: checksum:0x%04x authType:0x%04x\n". | ||||||||||||||||||||||||||||||||||||
| 305 | "$l: authData:%s", | ||||||||||||||||||||||||||||||||||||
| 306 | $self->version, $self->type, $self->length, | ||||||||||||||||||||||||||||||||||||
| 307 | $self->routerId, $self->areaId, $self->checksum, | ||||||||||||||||||||||||||||||||||||
| 308 | $self->authType, $self->authData; | ||||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||
| 310 | 0 | ▶ | if ($self->packet && ref($self->packet)) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->packet and ref $self->packet
MC/DC0%0/2
$self->packet and ref $self->packet
$self->packet
ref $self->packet
Truth table0%0/3
A and B
A= $self->packetB= ref $self->packet
| |||||||||||||||||||||||||||||||||||||
| 311 | 0 | $buf .= "\n".$self->packet->print; | |||||||||||||||||||||||||||||||||||
| 312 | } | ||||||||||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||||||||||
| 314 | 0 | $buf; | |||||||||||||||||||||||||||||||||||
| 315 | } | ||||||||||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||||||||||
| 317 | 15 | 1; | |||||||||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||||||||||
| 319 | __END__ | ||||||||||||||||||||||||||||||||||||