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