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