RIP.pm

filter: Statementstmt 90.0% 136 / 151 Branchbran 37.5% 6 / 16 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 90.7% 39 / 43 Podpod 100% 9 / 9 totaltotal 83.3% 190 / 228 CC 10 SCAR 12.5
CC
10
Cov
82%
match
20.0
encapsulate
10.4
pack
2.0
CRAP 3.5
↑ Summary RIP/v2.pm »
1 #
2 # $Id: RIP.pm 49 2009-05-31 13:15:34Z VinsWorldcom $
3 #
4 package Net::Frame::Layer::RIP;
5 8 ▶use strict; use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 8 our $VERSION = '1.02';
8  
9 8 ▶use Net::Frame::Layer qw(:consts :subs);
Subroutine BEGIN: called CC=1 SCAR=0.0
10 8 ▶use Exporter;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 8 our @ISA = qw(Net::Frame::Layer Exporter);
12  
13 8 ▶use Net::Frame::Layer::RIP::v1 qw(:consts);
Subroutine BEGIN: called CC=1 SCAR=0.0
14 8 ▶use Net::Frame::Layer::RIP::v2 qw(:consts);
Subroutine BEGIN: called CC=1 SCAR=0.0
15 8 my @consts;
16 8 for my $c (sort(keys(%constant::declared))) {
17 1105 ▶ if ($c =~ /^Net::Frame::Layer::RIP::v[12]::/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($c =~ /^Net::Frame::Layer::RIP::v[12]::/) 48 1057 1105
18 48 $c =~ s/^Net::Frame::Layer::RIP::v[12]:://;
19 48 push @consts, $c
20 }
21 }
22  
23 8 our %EXPORT_TAGS = (
24 consts => [@consts, qw(
25 NF_RIP_V1_DEST_HWADDR
26 NF_RIP_V1_DEST_ADDR
27 NF_RIP_V1_DEST_PORT
28 NF_RIP_V2_DEST_HWADDR
29 NF_RIP_V2_DEST_ADDR
30 NF_RIP_V2_DEST_PORT
31 NF_RIP_V1_COMMAND_REQUEST
32 NF_RIP_V1_COMMAND_RESPONSE
33 NF_RIP_V1_COMMAND_TRACEON
34 NF_RIP_V1_COMMAND_TRACEOFF
35 NF_RIP_V1_COMMAND_SUNRESV
36 NF_RIP_V1_COMMAND_TRIGGEREDREQUEST
37 NF_RIP_V1_COMMAND_TRIGGEREDRESPONSE
38 NF_RIP_V1_COMMAND_TRIGGEREDACK
39 NF_RIP_V1_COMMAND_UPDATEREQUEST
40 NF_RIP_V1_COMMAND_UPDATERESPONSE
41 NF_RIP_V1_COMMAND_UPDATEACK
42 NF_RIP_V2_COMMAND_REQUEST
43 NF_RIP_V2_COMMAND_RESPONSE
44 NF_RIP_V2_COMMAND_TRACEON
45 NF_RIP_V2_COMMAND_TRACEOFF
46 NF_RIP_V2_COMMAND_SUNRESV
47 NF_RIP_V2_COMMAND_TRIGGEREDREQUEST
48 NF_RIP_V2_COMMAND_TRIGGEREDRESPONSE
49 NF_RIP_V2_COMMAND_TRIGGEREDACK
50 NF_RIP_V2_COMMAND_UPDATEREQUEST
51 NF_RIP_V2_COMMAND_UPDATERESPONSE
52 NF_RIP_V2_COMMAND_UPDATEACK
53 )],
54 );
55 our @EXPORT_OK = (
56 8 @{$EXPORT_TAGS{consts}},
57 );
58  
59 8 ▶use constant NF_RIP_V1_DEST_HWADDR => 'ff:ff:ff:ff:ff:ff';
Subroutine BEGIN: called CC=1 SCAR=0.0
60 8 ▶use constant NF_RIP_V1_DEST_ADDR => '255.255.255.255';
Subroutine BEGIN: called CC=1 SCAR=0.0
61 8 ▶use constant NF_RIP_V1_DEST_PORT => 520;
Subroutine BEGIN: called CC=1 SCAR=0.0
62 8 ▶use constant NF_RIP_V2_DEST_HWADDR => '01:00:5e:00:00:09';
Subroutine BEGIN: called CC=1 SCAR=0.0
63 8 ▶use constant NF_RIP_V2_DEST_ADDR => '224.0.0.9';
Subroutine BEGIN: called CC=1 SCAR=0.0
64 8 ▶use constant NF_RIP_V2_DEST_PORT => 520;
Subroutine BEGIN: called CC=1 SCAR=0.0
65 8 ▶use constant NF_RIP_V1_COMMAND_REQUEST => 1;
Subroutine BEGIN: called CC=1 SCAR=0.0
66 8 ▶use constant NF_RIP_V1_COMMAND_RESPONSE => 2;
Subroutine BEGIN: called CC=1 SCAR=0.0
67 8 ▶use constant NF_RIP_V1_COMMAND_TRACEON => 3;
Subroutine BEGIN: called CC=1 SCAR=0.0
68 8 ▶use constant NF_RIP_V1_COMMAND_TRACEOFF => 4;
Subroutine BEGIN: called CC=1 SCAR=0.0
69 8 ▶use constant NF_RIP_V1_COMMAND_SUNRESV => 5;
Subroutine BEGIN: called CC=1 SCAR=0.0
70 8 ▶use constant NF_RIP_V1_COMMAND_TRIGGEREDREQUEST => 6;
Subroutine BEGIN: called CC=1 SCAR=0.0
71 8 ▶use constant NF_RIP_V1_COMMAND_TRIGGEREDRESPONSE => 7;
Subroutine BEGIN: called CC=1 SCAR=0.0
72 8 ▶use constant NF_RIP_V1_COMMAND_TRIGGEREDACK => 8;
Subroutine BEGIN: called CC=1 SCAR=0.0
73 8 ▶use constant NF_RIP_V1_COMMAND_UPDATEREQUEST => 9;
Subroutine BEGIN: called CC=1 SCAR=0.0
74 8 ▶use constant NF_RIP_V1_COMMAND_UPDATERESPONSE => 10;
Subroutine BEGIN: called CC=1 SCAR=0.0
75 8 ▶use constant NF_RIP_V1_COMMAND_UPDATEACK => 11;
Subroutine BEGIN: called CC=1 SCAR=0.0
76 8 ▶use constant NF_RIP_V2_COMMAND_REQUEST => 1;
Subroutine BEGIN: called CC=1 SCAR=0.0
77 8 ▶use constant NF_RIP_V2_COMMAND_RESPONSE => 2;
Subroutine BEGIN: called CC=1 SCAR=0.0
78 8 ▶use constant NF_RIP_V2_COMMAND_TRACEON => 3;
Subroutine BEGIN: called CC=1 SCAR=0.0
79 8 ▶use constant NF_RIP_V2_COMMAND_TRACEOFF => 4;
Subroutine BEGIN: called CC=1 SCAR=0.0
80 8 ▶use constant NF_RIP_V2_COMMAND_SUNRESV => 5;
Subroutine BEGIN: called CC=1 SCAR=0.0
81 8 ▶use constant NF_RIP_V2_COMMAND_TRIGGEREDREQUEST => 6;
Subroutine BEGIN: called CC=1 SCAR=0.0
82 8 ▶use constant NF_RIP_V2_COMMAND_TRIGGEREDRESPONSE => 7;
Subroutine BEGIN: called CC=1 SCAR=0.0
83 8 ▶use constant NF_RIP_V2_COMMAND_TRIGGEREDACK => 8;
Subroutine BEGIN: called CC=1 SCAR=0.0
84 8 ▶use constant NF_RIP_V2_COMMAND_UPDATEREQUEST => 9;
Subroutine BEGIN: called CC=1 SCAR=0.0
85 8 ▶use constant NF_RIP_V2_COMMAND_UPDATERESPONSE => 10;
Subroutine BEGIN: called CC=1 SCAR=0.0
86 8 ▶use constant NF_RIP_V2_COMMAND_UPDATEACK => 11;
Subroutine BEGIN: called CC=1 SCAR=0.0
87  
88 8 our @AS = qw(
89 command
90 version
91 reserved
92 );
93 8 __PACKAGE__->cgBuildIndices;
94 8 __PACKAGE__->cgBuildAccessorsScalar(\@AS);
95  
96 #no strict 'vars';
97  
98 8 $Net::Frame::Layer::UDP::Next->{520} = "RIP";
99  
100 11 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod documented
101 shift->SUPER::new(
102 11 command => NF_RIP_V2_COMMAND_REQUEST,
103 version => 2,
104 reserved => 0,
105 @_,
106 );
107 }
108  
109 0 ▶sub match {
Subroutine match: not called CC=4 SCAR=30.0
Pod documented
110 0 my $self = shift;
111 0 my ($with) = @_;
112 0 my $sVer = $self->version;
113 0 my $wVer = $with->version;
114 0 my $sCmd = $self->command;
115 0 my $wCmd = $with->command;
116 0 ▶ if (($sCmd == NF_RIP_V1_COMMAND_REQUEST)
Branch: 1 branch
BranchTrueFalseTotal
if ($sCmd == 1 and $wCmd == 2 and $sVer == $wVer) 0 0 0
Condition0%0/6
$sCmd == 1 and $wCmd == 2 and $sVer == $wVer
!ll&&!rl&&r
000
$sCmd == 1 and $wCmd == 2
!ll&&!rl&&r
000
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
ABCresult
0XX0
10X0
1100
1111
117 && ($wCmd == NF_RIP_V1_COMMAND_RESPONSE)
118 && ($sVer == $wVer)) {
119 0 return 1;
120 }
121 0 0;
122 }
123  
124 # XXX: may be better, by keying on type also
125 0 ▶sub getKey { shift->layer }
Subroutine getKey: not called CC=1 SCAR=6.9
Pod documented
126 0 ▶sub getKeyReverse { shift->layer }
Subroutine getKeyReverse: not called CC=1 SCAR=6.9
Pod documented
127  
128 0 ▶sub getLength { 4 }
Subroutine getLength: not called CC=1 SCAR=6.9
Pod documented
129  
130 1 ▶sub pack {
Subroutine pack: called CC=2 SCAR=7.1
Pod documented
131 1 my $self = shift;
132  
133 1 ▶ my $raw = $self->SUPER::pack('CCn',
Branch: 1 branch
BranchTrueFalseTotal
my $raw = $self->SUPER::pack("CCn", $self->command, $self->version, $self->reserved) or return 1 0 1
134 $self->command,
135 $self->version,
136 $self->reserved
137 ) or return;
138  
139 1 return $self->raw($raw);
140 }
141  
142 1 ▶sub unpack {
Subroutine unpack: called CC=2 SCAR=7.0
Pod documented
143 1 my $self = shift;
144  
145 1 ▶ my ($command, $version, $reserved, $payload) =
Branch: 1 branch
BranchTrueFalseTotal
() = $self->SUPER::unpack("CCn a*", $self->raw) or return 1 0 1
146 $self->SUPER::unpack('CCn a*', $self->raw)
147 or return;
148  
149 1 $self->command($command);
150 1 $self->version($version);
151 1 $self->reserved($reserved);
152  
153 1 $self->payload($payload);
154  
155 1 return $self;
156 }
157  
158 1 ▶sub encapsulate {
Subroutine encapsulate: called CC=5 SCAR=23.4
Pod documented
159 1 my $self = shift;
160  
161 1 ▶ return $self->nextLayer if $self->nextLayer;
Branch: 1 branch
BranchTrueFalseTotal
if $self->nextLayer 0 1 1
162  
163 1 ▶ if ($self->payload) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->payload) 0 1 1
164 0 ▶ if ($self->version == 1) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->version == 1) { } 0 0 0
elsif ($self->version == 2) { } 0 0 0
165 0 return 'RIP::v1';
166 } elsif ($self->version == 2) {
167 0 return 'RIP::v2';
168 }
169 }
170  
171 1 NF_LAYER_NONE;
172 }
173  
174 1 ▶sub print {
Subroutine print: called CC=1 SCAR=0.0
Pod documented
175 1 my $self = shift;
176  
177 1 my $l = $self->layer;
178 1 my $buf = sprintf
179 "$l: command:%d version:%d reserved:%d",
180 $self->command, $self->version, $self->reserved;
181  
182 1 return $buf;
183 }
184  
185 8 1;
186  
187 __END__
↑ Summary RIP/v2.pm »