OSPF/Hello.pm

filter: Statementstmt 67.8% 38 / 56 Branchbran 21.4% 3 / 14 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 77.7% 7 / 9 Podpod 100% 5 / 5 totaltotal 63.1% 53 / 84 SCAR 29.8
CC
11
Cov
59%
print
12.0
unpack
6.4
getLength
6.0
CRAP 19.6
« OSPF/DatabaseDesc.pm ↑ Summary OSPF/Lsa/Network.pm »
1 #
2 # $Id: Hello.pm,v 1.4 2007/03/13 18:17:50 gomor Exp $
3 #
4 package Net::Frame::Layer::OSPF::Hello;
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 ▶use Net::Frame::Layer qw(:consts :subs);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 15 our @ISA = qw(Net::Frame::Layer);
10  
11 15 our @AS = qw(
12 networkMask
13 helloInterval
14 options
15 routerPri
16 routerDeadInterval
17 designatedRouter
18 backupDesignatedRouter
19 lls
20 );
21 15 our @AA = qw(
22 neighborList
23 );
24 15 __PACKAGE__->cgBuildIndices;
25 15 __PACKAGE__->cgBuildAccessorsScalar(\@AS);
26 15 __PACKAGE__->cgBuildAccessorsArray (\@AA);
27  
28 15 ▶use Net::Frame::Layer::OSPF qw(:consts);
Subroutine BEGIN: called CC=1 SCAR=0.0
29  
30 sub new {
31 shift->SUPER::new(
32 1 ▶ networkMask => '255.255.255.0',
Subroutine new: called CC=1 SCAR=0.0
Pod documented
33 helloInterval => 60,
34 options => 0,
35 routerPri => 0,
36 routerDeadInterval => 120,
37 designatedRouter => '0.0.0.0',
38 backupDesignatedRouter => '0.0.0.0',
39 neighborList => [],
40 @_,
41 );
42 }
43  
44 sub getLength {
45 0 ▶ my $self = shift;
Subroutine getLength: not called CC=2 SCAR=17.9
Pod documented
46 0 my $len = 20;
47 0 for ($self->neighborList) {
48 0 $len += 4;
49 }
50 0 $len;
51 }
52  
53 sub pack {
54 1 ▶ my $self = shift;
Subroutine pack: called CC=4 SCAR=16.9
Pod documented
55  
56 1 ▶ my $raw = $self->SUPER::pack('a4nCCNa4a4',
Branch: 1 branch
BranchTrueFalseTotal
my $raw = $self->SUPER::pack("a4nCCNa4a4", inetAton($self->networkMask), $self->helloInterval, $self->options, $self->routerPri, $self->routerDeadInterval, inetAton($self->designatedRouter), inetAton($self->backupDesignatedRouter)) or return undef 0 1 1
57 inetAton($self->networkMask), $self->helloInterval, $self->options,
58 $self->routerPri, $self->routerDeadInterval,
59 inetAton($self->designatedRouter),
60 inetAton($self->backupDesignatedRouter),
61 ) or return undef;
62  
63 1 for ($self->neighborList) {
64 0 ▶ $raw .= $self->SUPER::pack('a4', inetAton($_)) or return undef;
Branch: 1 branch
BranchTrueFalseTotal
$raw .= $self->SUPER::pack("a4", inetAton($_)) or return undef 0 0 0
65 }
66  
67 1 $self->raw($raw);
68 }
69  
70 sub unpack {
71 1 ▶ my $self = shift;
Subroutine unpack: called CC=5 SCAR=18.6
Pod documented
72  
73 1 ▶ my ($netmask, $helloInt, $options, $pri, $deadInt, $desRouter, $backup,
Branch: 1 branch
BranchTrueFalseTotal
() = $self->SUPER::unpack("a4nCCNa4a4 a*", $self->raw) or return undef 0 1 1
74 $payload) = $self->SUPER::unpack('a4nCCNa4a4 a*', $self->raw)
75 or return undef;
76  
77 1 $self->networkMask(inetNtoa($netmask));
78 1 $self->helloInterval($helloInt);
79 1 $self->options($options);
80 1 $self->routerPri($pri);
81 1 $self->routerDeadInterval($deadInt);
82 1 $self->designatedRouter(inetNtoa($desRouter));
83 1 $self->backupDesignatedRouter(inetNtoa($backup));
84  
85 1 my @neighborList = ();
86 1 ▶ if ($payload) {
Branch: 1 branch
BranchTrueFalseTotal
if ($payload) 0 1 1
87 0 ▶ while ($payload) {
Branch: 1 branch
BranchTrueFalseTotal
if ($payload) 0 0 0
88 0 ▶ my ($neighbor, $tail) = $self->SUPER::unpack('a4 a*', $payload)
Branch: 1 branch
BranchTrueFalseTotal
() = $self->SUPER::unpack("a4 a*", $payload) or return undef 0 0 0
89 or return undef;
90 0 push @neighborList, inetNtoa($neighbor);
91 0 $payload = $tail;
92 }
93 }
94  
95 1 $self->neighborList(\@neighborList);
96  
97 1 $self->payload($payload);
98  
99 1 $self;
100 }
101  
102 sub print {
103 0 ▶ my $self = shift;
Subroutine print: not called CC=3 SCAR=24.8
Pod documented
104  
105 0 my $l = $self->layer;
106 0 my $buf = sprintf
107 "$l: networkMask:%s helloInterval:%d\n".
108 "$l: options:0x%02x routerPri:0x%02x routerDeadInterval:%d\n".
109 "$l: designatedRouter:%s backupDesignatedRouter:%s",
110 $self->networkMask,
111 $self->helloInterval,
112 $self->options,
113 $self->routerPri,
114 $self->routerDeadInterval,
115 $self->designatedRouter,
116 $self->backupDesignatedRouter,
117 ;
118  
119 0 for ($self->neighborList) {
120 0 $buf .= "\n$l: neighbor: $_";
121 }
122  
123 0 ▶ if ($self->lls) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->lls) 0 0 0
124 0 $buf .= "\n".$self->lls->print;
125 }
126  
127 0 $buf;
128 }
129  
130 15 1;
131  
132 __END__
« OSPF/DatabaseDesc.pm ↑ Summary OSPF/Lsa/Network.pm »