| 1 | # | ||||||||||||||||||||||||||||||||||||||||||
| 2 | # $Id: RIPng.pm 49 2009-05-31 13:15:34Z VinsWorldcom $ | ||||||||||||||||||||||||||||||||||||||||||
| 3 | # | ||||||||||||||||||||||||||||||||||||||||||
| 4 | package Net::Frame::Layer::RIPng; | ||||||||||||||||||||||||||||||||||||||||||
| 5 | 6 | ▶ | use strict; use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||
| 7 | 6 | our $VERSION = '1.02'; | |||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||
| 9 | 6 | ▶ | use Net::Frame::Layer qw(:consts :subs); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | 6 | ▶ | use Exporter; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | 6 | our @ISA = qw(Net::Frame::Layer Exporter); | |||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||
| 13 | 6 | ▶ | use Net::Frame::Layer::RIPng::v1 qw(:consts); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | 6 | my @consts; | |||||||||||||||||||||||||||||||||||||||||
| 15 | 6 | for my $c (sort(keys(%constant::declared))) { | |||||||||||||||||||||||||||||||||||||||||
| 16 | 655 | ▶ | if ($c =~ /^Net::Frame::Layer::RIPng::v1::/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 17 | 6 | $c =~ s/^Net::Frame::Layer::RIPng::v1:://; | |||||||||||||||||||||||||||||||||||||||||
| 18 | 6 | push @consts, $c | |||||||||||||||||||||||||||||||||||||||||
| 19 | } | ||||||||||||||||||||||||||||||||||||||||||
| 20 | } | ||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||
| 22 | 6 | our %EXPORT_TAGS = ( | |||||||||||||||||||||||||||||||||||||||||
| 23 | consts => [@consts, qw( | ||||||||||||||||||||||||||||||||||||||||||
| 24 | NF_RIPNG_DEST_HWADDR | ||||||||||||||||||||||||||||||||||||||||||
| 25 | NF_RIPNG_DEST_ADDR | ||||||||||||||||||||||||||||||||||||||||||
| 26 | NF_RIPNG_DEST_PORT | ||||||||||||||||||||||||||||||||||||||||||
| 27 | NF_RIPNG_COMMAND_REQUEST | ||||||||||||||||||||||||||||||||||||||||||
| 28 | NF_RIPNG_COMMAND_RESPONSE | ||||||||||||||||||||||||||||||||||||||||||
| 29 | )], | ||||||||||||||||||||||||||||||||||||||||||
| 30 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 31 | our @EXPORT_OK = ( | ||||||||||||||||||||||||||||||||||||||||||
| 32 | 6 | @{$EXPORT_TAGS{consts}}, | |||||||||||||||||||||||||||||||||||||||||
| 33 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||
| 35 | 6 | ▶ | use constant NF_RIPNG_DEST_HWADDR => '33:33:00:00:00:09'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 36 | 6 | ▶ | use constant NF_RIPNG_DEST_ADDR => 'ff02::9'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 37 | 6 | ▶ | use constant NF_RIPNG_DEST_PORT => 521; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 38 | 6 | ▶ | use constant NF_RIPNG_COMMAND_REQUEST => 1; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 39 | 6 | ▶ | use constant NF_RIPNG_COMMAND_RESPONSE => 2; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||
| 41 | 6 | our @AS = qw( | |||||||||||||||||||||||||||||||||||||||||
| 42 | command | ||||||||||||||||||||||||||||||||||||||||||
| 43 | version | ||||||||||||||||||||||||||||||||||||||||||
| 44 | reserved | ||||||||||||||||||||||||||||||||||||||||||
| 45 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 46 | 6 | __PACKAGE__->cgBuildIndices; | |||||||||||||||||||||||||||||||||||||||||
| 47 | 6 | __PACKAGE__->cgBuildAccessorsScalar(\@AS); | |||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||
| 49 | #no strict 'vars'; | ||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||
| 51 | 6 | $Net::Frame::Layer::UDP::Next->{521} = "RIPng"; | |||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||
| 53 | 1 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 54 | shift->SUPER::new( | ||||||||||||||||||||||||||||||||||||||||||
| 55 | 1 | command => NF_RIPNG_COMMAND_REQUEST, | |||||||||||||||||||||||||||||||||||||||||
| 56 | version => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 57 | reserved => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 58 | @_, | ||||||||||||||||||||||||||||||||||||||||||
| 59 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | ▶ | sub match { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
match: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | my ($with) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | my $sVer = $self->version; | |||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | my $wVer = $with->version; | |||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | my $sCmd = $self->command; | |||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | my $wCmd = $with->command; | |||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | ▶ | if (($sCmd == NF_RIPNG_COMMAND_REQUEST) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$sCmd == 1 and $wCmd == 2 and $sVer == $wVer
$sCmd == 1 and $wCmd == 2
MC/DC0%0/3
$sCmd == 1 and $wCmd == 2 and $sVer == $wVer
$sCmd == 1
$wCmd == 2
$sVer == $wVer
Truth table0%0/4
A and B and C
A= $sCmd == 1B= $wCmd == 2C= $sVer == $wVer
| |||||||||||||||||||||||||||||||||||||||||||
| 70 | && ($wCmd == NF_RIPNG_COMMAND_RESPONSE) | ||||||||||||||||||||||||||||||||||||||||||
| 71 | && ($sVer == $wVer)) { | ||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | 0; | |||||||||||||||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||
| 77 | # XXX: may be better, by keying on type also | ||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | ▶ | sub getKey { shift->layer } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getKey: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | ▶ | sub getKeyReverse { shift->layer } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getKeyReverse: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | ▶ | sub getLength { 4 } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getLength: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||
| 83 | 1 | ▶ | sub pack { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pack: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 84 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||
| 86 | 1 | ▶ | my $raw = $self->SUPER::pack('CCn', | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 87 | $self->command, | ||||||||||||||||||||||||||||||||||||||||||
| 88 | $self->version, | ||||||||||||||||||||||||||||||||||||||||||
| 89 | $self->reserved | ||||||||||||||||||||||||||||||||||||||||||
| 90 | ) or return; | ||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||
| 92 | 1 | return $self->raw($raw); | |||||||||||||||||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||
| 95 | 1 | ▶ | sub unpack { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
unpack: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 96 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||
| 98 | 1 | ▶ | my ($command, $version, $reserved, $payload) = | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 99 | $self->SUPER::unpack('CCn a*', $self->raw) | ||||||||||||||||||||||||||||||||||||||||||
| 100 | or return; | ||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||
| 102 | 1 | $self->command($command); | |||||||||||||||||||||||||||||||||||||||||
| 103 | 1 | $self->version($version); | |||||||||||||||||||||||||||||||||||||||||
| 104 | 1 | $self->reserved($reserved); | |||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||
| 106 | 1 | $self->payload($payload); | |||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||
| 108 | 1 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||
| 111 | 1 | ▶ | sub encapsulate { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
encapsulate: called CC=4 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 112 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||
| 114 | 1 | ▶ | return $self->nextLayer if $self->nextLayer; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||
| 116 | 1 | ▶ | if ($self->payload) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | ▶ | if ($self->version == 1) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | return 'RIPng::v1'; | |||||||||||||||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||
| 122 | 1 | NF_LAYER_NONE; | |||||||||||||||||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||
| 125 | 1 | ▶ | sub print { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
print: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 126 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||||
| 128 | 1 | my $l = $self->layer; | |||||||||||||||||||||||||||||||||||||||||
| 129 | 1 | my $buf = sprintf | |||||||||||||||||||||||||||||||||||||||||
| 130 | "$l: command:%d version:%d reserved:%d", | ||||||||||||||||||||||||||||||||||||||||||
| 131 | $self->command, $self->version, $self->reserved; | ||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||
| 133 | 1 | return $buf; | |||||||||||||||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||
| 136 | 6 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||
| 138 | __END__ | ||||||||||||||||||||||||||||||||||||||||||