LLTD.pm

filter: Statementstmt 93.0% 186 / 200 Branchbran 27.2% 6 / 22 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 94.6% 53 / 56 Podpod 100% 6 / 6 totaltotal 87.2% 252 / 289 SCAR 26.0
CC
13
Cov
86%
unpack
14.2
getLength
6.0
print
6.0
CRAP 13.5
« LLTD/Hello.pm ↑ Summary LLTD/Tlv.pm »
1 #
2 # $Id: LLTD.pm,v 1.2 2007/03/15 18:22:53 gomor Exp $
3 #
4 package Net::Frame::Layer::LLTD;
5 10 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 10 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 10 our $VERSION = '1.00';
9  
10 10 ▶use Net::Frame::Layer qw(:consts :subs);
Subroutine BEGIN: called CC=1 SCAR=0.0
11 10 require Exporter;
12 10 our @ISA = qw(Net::Frame::Layer Exporter);
13  
14 10 our %EXPORT_TAGS = (
15 consts => [qw(
16 NF_LLTD_TOS_TOPOLOGY_DISCOVERY
17 NF_LLTD_TOS_QUICK_DISCOVERY
18 NF_LLTD_TOS_QOS_DIAGNOSTICS
19 NF_LLTD_FUNCTION_DISCOVER
20 NF_LLTD_FUNCTION_HELLO
21 NF_LLTD_FUNCTION_EMIT
22 NF_LLTD_FUNCTION_TRAIN
23 NF_LLTD_FUNCTION_PROBE
24 NF_LLTD_FUNCTION_ACK
25 NF_LLTD_FUNCTION_QUERY
26 NF_LLTD_FUNCTION_QUERY_RESP
27 NF_LLTD_FUNCTION_RESET
28 NF_LLTD_FUNCTION_CHARGE
29 NF_LLTD_FUNCTION_FLAT
30 NF_LLTD_FUNCTION_QUERY_LARGE_TLV
31 NF_LLTD_FUNCTION_QUERY_LARGE_TLV_RESP
32 NF_LLTD_TLV_TYPE_EOP
33 NF_LLTD_TLV_TYPE_HOSTID
34 NF_LLTD_TLV_TYPE_CHARACTERISTICS
35 NF_LLTD_TLV_TYPE_PHYSICALMEDIUM
36 NF_LLTD_TLV_TYPE_WIRELESSMODE
37 NF_LLTD_TLV_TYPE_BSSID
38 NF_LLTD_TLV_TYPE_SSID
39 NF_LLTD_TLV_TYPE_IPv4ADDRESS
40 NF_LLTD_TLV_TYPE_IPv6ADDRESS
41 NF_LLTD_TLV_TYPE_MAXOPRATE
42 NF_LLTD_TLV_TYPE_PERFCOUNTER
43 NF_LLTD_TLV_TYPE_LINKSPEED
44 NF_LLTD_TLV_TYPE_RSSI
45 NF_LLTD_TLV_TYPE_ICONIMAGE
46 NF_LLTD_TLV_TYPE_MACHINENAME
47 NF_LLTD_TLV_TYPE_SUPPORTINFO
48 NF_LLTD_TLV_TYPE_FRIENDLYNAME
49 NF_LLTD_TLV_TYPE_UUID
50 NF_LLTD_TLV_TYPE_HARDWAREID
51 NF_LLTD_TLV_TYPE_QOSCHARACTERISTICS
52 NF_LLTD_TLV_TYPE_WIRELESSPHYSICALMEDIUM
53 NF_LLTD_TLV_TYPE_APTABLE
54 NF_LLTD_TLV_TYPE_DETAILEDICONIMAGE
55 NF_LLTD_TLV_TYPE_SEESLISTCOUNT
56 NF_LLTD_TLV_TYPE_COMPONENTTABLE
57 NF_LLTD_TLV_TYPE_REPEATERAP
58 NF_LLTD_TLV_TYPE_REPEATERAPTABLE
59 )],
60 );
61 our @EXPORT_OK = (
62 10 @{$EXPORT_TAGS{consts}},
63 );
64  
65 10 ▶use constant NF_LLTD_TOS_TOPOLOGY_DISCOVERY => 0x00;
Subroutine BEGIN: called CC=1 SCAR=0.0
66 10 ▶use constant NF_LLTD_TOS_QUICK_DISCOVERY => 0x01;
Subroutine BEGIN: called CC=1 SCAR=0.0
67 10 ▶use constant NF_LLTD_TOS_QOS_DIAGNOSTICS => 0x02;
Subroutine BEGIN: called CC=1 SCAR=0.0
68  
69 10 ▶use constant NF_LLTD_FUNCTION_DISCOVER => 0x00;
Subroutine BEGIN: called CC=1 SCAR=0.0
70 10 ▶use constant NF_LLTD_FUNCTION_HELLO => 0x01;
Subroutine BEGIN: called CC=1 SCAR=0.0
71 10 ▶use constant NF_LLTD_FUNCTION_EMIT => 0x02;
Subroutine BEGIN: called CC=1 SCAR=0.0
72 10 ▶use constant NF_LLTD_FUNCTION_TRAIN => 0x03; # No upper
Subroutine BEGIN: called CC=1 SCAR=0.0
73 10 ▶use constant NF_LLTD_FUNCTION_PROBE => 0x04; # No upper
Subroutine BEGIN: called CC=1 SCAR=0.0
74 10 ▶use constant NF_LLTD_FUNCTION_ACK => 0x05; # No upper
Subroutine BEGIN: called CC=1 SCAR=0.0
75 10 ▶use constant NF_LLTD_FUNCTION_QUERY => 0x06; # No upper
Subroutine BEGIN: called CC=1 SCAR=0.0
76 10 ▶use constant NF_LLTD_FUNCTION_QUERY_RESP => 0x07;
Subroutine BEGIN: called CC=1 SCAR=0.0
77 10 ▶use constant NF_LLTD_FUNCTION_RESET => 0x08; # No upper
Subroutine BEGIN: called CC=1 SCAR=0.0
78 10 ▶use constant NF_LLTD_FUNCTION_CHARGE => 0x09; # No upper
Subroutine BEGIN: called CC=1 SCAR=0.0
79 10 ▶use constant NF_LLTD_FUNCTION_FLAT => 0x0a; # XXX: TODO
Subroutine BEGIN: called CC=1 SCAR=0.0
80 10 ▶use constant NF_LLTD_FUNCTION_QUERY_LARGE_TLV => 0x0b; # XXX: TODO
Subroutine BEGIN: called CC=1 SCAR=0.0
81 10 ▶use constant NF_LLTD_FUNCTION_QUERY_LARGE_TLV_RESP => 0x0c; # XXX: TODO
Subroutine BEGIN: called CC=1 SCAR=0.0
82  
83 10 ▶use constant NF_LLTD_TLV_TYPE_EOP => 0x00;
Subroutine BEGIN: called CC=1 SCAR=0.0
84 10 ▶use constant NF_LLTD_TLV_TYPE_HOSTID => 0x01;
Subroutine BEGIN: called CC=1 SCAR=0.0
85 10 ▶use constant NF_LLTD_TLV_TYPE_CHARACTERISTICS => 0x02;
Subroutine BEGIN: called CC=1 SCAR=0.0
86 10 ▶use constant NF_LLTD_TLV_TYPE_PHYSICALMEDIUM => 0x03;
Subroutine BEGIN: called CC=1 SCAR=0.0
87 10 ▶use constant NF_LLTD_TLV_TYPE_WIRELESSMODE => 0x04;
Subroutine BEGIN: called CC=1 SCAR=0.0
88 10 ▶use constant NF_LLTD_TLV_TYPE_BSSID => 0x05;
Subroutine BEGIN: called CC=1 SCAR=0.0
89 10 ▶use constant NF_LLTD_TLV_TYPE_SSID => 0x06;
Subroutine BEGIN: called CC=1 SCAR=0.0
90 10 ▶use constant NF_LLTD_TLV_TYPE_IPv4ADDRESS => 0x07;
Subroutine BEGIN: called CC=1 SCAR=0.0
91 10 ▶use constant NF_LLTD_TLV_TYPE_IPv6ADDRESS => 0x08;
Subroutine BEGIN: called CC=1 SCAR=0.0
92 10 ▶use constant NF_LLTD_TLV_TYPE_MAXOPRATE => 0x09;
Subroutine BEGIN: called CC=1 SCAR=0.0
93 10 ▶use constant NF_LLTD_TLV_TYPE_PERFCOUNTER => 0x0a;
Subroutine BEGIN: called CC=1 SCAR=0.0
94 10 ▶use constant NF_LLTD_TLV_TYPE_LINKSPEED => 0x0c;
Subroutine BEGIN: called CC=1 SCAR=0.0
95 10 ▶use constant NF_LLTD_TLV_TYPE_RSSI => 0x0d;
Subroutine BEGIN: called CC=1 SCAR=0.0
96 10 ▶use constant NF_LLTD_TLV_TYPE_ICONIMAGE => 0x0e;
Subroutine BEGIN: called CC=1 SCAR=0.0
97 10 ▶use constant NF_LLTD_TLV_TYPE_MACHINENAME => 0x0f;
Subroutine BEGIN: called CC=1 SCAR=0.0
98 10 ▶use constant NF_LLTD_TLV_TYPE_SUPPORTINFO => 0x10;
Subroutine BEGIN: called CC=1 SCAR=0.0
99 10 ▶use constant NF_LLTD_TLV_TYPE_FRIENDLYNAME => 0x11;
Subroutine BEGIN: called CC=1 SCAR=0.0
100 10 ▶use constant NF_LLTD_TLV_TYPE_UUID => 0x12;
Subroutine BEGIN: called CC=1 SCAR=0.0
101 10 ▶use constant NF_LLTD_TLV_TYPE_HARDWAREID => 0x13;
Subroutine BEGIN: called CC=1 SCAR=0.0
102 10 ▶use constant NF_LLTD_TLV_TYPE_QOSCHARACTERISTICS => 0x14;
Subroutine BEGIN: called CC=1 SCAR=0.0
103 10 ▶use constant NF_LLTD_TLV_TYPE_WIRELESSPHYSICALMEDIUM => 0x15;
Subroutine BEGIN: called CC=1 SCAR=0.0
104 10 ▶use constant NF_LLTD_TLV_TYPE_APTABLE => 0x16;
Subroutine BEGIN: called CC=1 SCAR=0.0
105 10 ▶use constant NF_LLTD_TLV_TYPE_DETAILEDICONIMAGE => 0x18;
Subroutine BEGIN: called CC=1 SCAR=0.0
106 10 ▶use constant NF_LLTD_TLV_TYPE_SEESLISTCOUNT => 0x19;
Subroutine BEGIN: called CC=1 SCAR=0.0
107 10 ▶use constant NF_LLTD_TLV_TYPE_COMPONENTTABLE => 0x1a;
Subroutine BEGIN: called CC=1 SCAR=0.0
108 10 ▶use constant NF_LLTD_TLV_TYPE_REPEATERAP => 0x1b;
Subroutine BEGIN: called CC=1 SCAR=0.0
109 10 ▶use constant NF_LLTD_TLV_TYPE_REPEATERAPTABLE => 0x1c;
Subroutine BEGIN: called CC=1 SCAR=0.0
110  
111 #The following functions are valid for service type 0x02:
112 #0x00 = QosInitializeSink
113 #0x01 = QosReady
114 #0x02 = QosProbe
115 #0x03 = QosQuery
116 #0x04 = QosQueryResp
117 #0x05 = QosReset
118 #0x06 = QosError
119 #0x07 = QosAck
120 #0x08 = QosCounterSnapshot
121 #0x09 = QosCounterResult
122 #0x0A = QosCounterLease
123  
124 10 our @AS = qw(
125 version
126 tos
127 reserved
128 function
129 networkAddress1
130 networkAddress2
131 identifier
132 upperLayer
133 );
134 10 __PACKAGE__->cgBuildIndices;
135 10 __PACKAGE__->cgBuildAccessorsScalar(\@AS);
136  
137 10 ▶use Net::Frame::Layer::LLTD::Discover;
Subroutine BEGIN: called CC=1 SCAR=0.0
138 10 ▶use Net::Frame::Layer::LLTD::Hello;
Subroutine BEGIN: called CC=1 SCAR=0.0
139 10 ▶use Net::Frame::Layer::LLTD::Emit;
Subroutine BEGIN: called CC=1 SCAR=0.0
140 10 ▶use Net::Frame::Layer::LLTD::QueryResp;
Subroutine BEGIN: called CC=1 SCAR=0.0
141  
142 sub new {
143 shift->SUPER::new(
144 1 ▶ version => 1,
Subroutine new: called CC=1 SCAR=0.0
Pod documented
145 tos => NF_LLTD_TOS_TOPOLOGY_DISCOVERY,
146 reserved => 0,
147 function => NF_LLTD_FUNCTION_DISCOVER,
148 networkAddress1 => 'ff:ff:ff:ff:ff:ff',
149 networkAddress2 => 'ff:ff:ff:ff:ff:ff',
150 identifier => getRandom16bitsInt(),
151 @_,
152 );
153 }
154  
155 sub getLength {
156 0 ▶ my $self = shift;
Subroutine getLength: not called CC=2 SCAR=17.9
Pod documented
157 0 my $len = 18;
158 0 ▶ $len += $self->upperLayer->getLength if $self->upperLayer;
Branch: 1 branch
BranchTrueFalseTotal
if $self->upperLayer 0 0 0
159 0 $len;
160 }
161  
162 sub pack {
163 1 ▶ my $self = shift;
Subroutine pack: called CC=3 SCAR=11.2
Pod documented
164  
165 1 (my $dst = $self->networkAddress1) =~ s/://g;
166 1 (my $src = $self->networkAddress2) =~ s/://g;
167  
168 1 ▶ my $raw = $self->SUPER::pack('CCCCH12H12n',
Branch: 1 branch
BranchTrueFalseTotal
my $raw = $self->SUPER::pack("CCCCH12H12n", $self->version, $self->tos, $self->reserved, $self->function, $dst, $src, $self->identifier) or return undef 0 1 1
169 $self->version,
170 $self->tos,
171 $self->reserved,
172 $self->function,
173 $dst,
174 $src,
175 $self->identifier,
176 ) or return undef;
177  
178 1 ▶ $raw .= $self->upperLayer->pack if $self->upperLayer;
Branch: 1 branch
BranchTrueFalseTotal
if $self->upperLayer 0 1 1
179  
180 1 $self->raw($raw);
181 }
182  
183 sub unpack {
184 1 ▶ my $self = shift;
Subroutine unpack: called CC=9 SCAR=26.5
Pod documented
185  
186 1 ▶ my ($version, $tos, $reserved, $function, $dst, $src, $identifier,
Branch: 1 branch
BranchTrueFalseTotal
() = $self->SUPER::unpack("CCCCH12H12n a*", $self->raw) or return undef 0 1 1
187 $payload) = $self->SUPER::unpack('CCCCH12H12n a*', $self->raw)
188 or return undef;
189  
190 1 $self->version($version);
191 1 $self->tos($tos);
192 1 $self->reserved($reserved);
193 1 $self->function($function);
194 1 $self->networkAddress1(convertMac($dst));
195 1 $self->networkAddress2(convertMac($src));
196 1 $self->identifier($identifier);
197  
198 1 my $upperLayer;
199 1 ▶ if ($self->tos == NF_LLTD_TOS_QUICK_DISCOVERY
Branch: 1 branch
BranchTrueFalseTotal
if ($self->tos == 1 or $self->tos == 0) 1 0 1
Condition33%1/3
$self->tos == 1 or $self->tos == 0
l!l&&r!l&&!r
010
MC/DC0%0/2
$self->tos == 1 or $self->tos == 0
$self->tos == 1 $self->tos == 0
Truth table33%1/3
A or B
A= $self->tos == 1B= $self->tos == 0
ABresult
1X1
011
000
200 || $self->tos == NF_LLTD_TOS_TOPOLOGY_DISCOVERY) {
201 1 ▶ if ($self->function == NF_LLTD_FUNCTION_DISCOVER) {
Branch: 4 branches
BranchTrueFalseTotal
if ($self->function == 0) { } 1 0 1
elsif ($self->function == 1) { } 0 0 0
elsif ($self->function == 2) { } 0 0 0
elsif ($self->function == 7) { } 0 0 0
202 1 $upperLayer = Net::Frame::Layer::LLTD::Discover->new(raw => $payload);
203 }
204 elsif ($self->function == NF_LLTD_FUNCTION_HELLO) {
205 0 $upperLayer = Net::Frame::Layer::LLTD::Hello->new(raw => $payload);
206 }
207 elsif ($self->function == NF_LLTD_FUNCTION_EMIT) {
208 0 $upperLayer = Net::Frame::Layer::LLTD::Emit->new(raw => $payload);
209 }
210 elsif ($self->function == NF_LLTD_FUNCTION_QUERY_RESP) {
211 0 $upperLayer = Net::Frame::Layer::LLTD::QueryResp->new(raw => $payload);
212 }
213 }
214  
215 1 ▶ if ($upperLayer) {
Branch: 1 branch
BranchTrueFalseTotal
if ($upperLayer) { } 1 0 1
216 1 $upperLayer->unpack;
217 1 $self->upperLayer($upperLayer);
218 1 $self->payload($upperLayer->payload);
219 1 $upperLayer->payload(undef);
220 }
221 else {
222 0 $self->payload($payload);
223 }
224  
225 1 $self;
226 }
227  
228 0 ▶sub encapsulate { shift->nextLayer }
Subroutine encapsulate: not called CC=1 SCAR=6.9
Pod documented
229  
230 sub print {
231 0 ▶ my $self = shift;
Subroutine print: not called CC=2 SCAR=17.9
Pod documented
232  
233 0 my $l = $self->layer;
234 0 my $buf = sprintf
235 "$l: version:%d tos:0x%02x reserved:%d function:0x%02x\n".
236 "$l: networkAddress1: %s networkAddress2: %s\n".
237 "$l: identifier:%d",
238 $self->version,
239 $self->tos,
240 $self->reserved,
241 $self->function,
242 $self->networkAddress1,
243 $self->networkAddress2,
244 $self->identifier;
245  
246 0 ▶ $buf .= "\n".$self->upperLayer->print if $self->upperLayer;
Branch: 1 branch
BranchTrueFalseTotal
if $self->upperLayer 0 0 0
247  
248 0 $buf;
249 }
250  
251 10 1;
252  
253 __END__
« LLTD/Hello.pm ↑ Summary LLTD/Tlv.pm »