blib/lib/Net/Flow/Ie.pm

filter: Statementstmt 23.5% 16 / 68 Branchbran 0.0% 0 / 34 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 57.1% 4 / 7 Podpod 33.3% 1 / 3 totaltotal 17.2% 21 / 122 CC 23 SCAR 46.5
CC
23
Cov
15%
eachdecode
182.0
iedecode
72.0
addie
20.0
CRAP 104.3
↑ Summary
1 #!/usr/bin/perl
2 #
3 #
4 # Atsushi Kobayashi
5 #
6 # Ie.pm - 2008/04/07
7 #
8 # Copyright (c) 2007-2008 NTT Information Sharing Platform Laboratories
9 #
10 # This package is free software and is provided "as is" without express
11 # or implied warranty. It may be used, redistributed and/or modified
12 # under the terms of the Perl Artistic License (see
13 # http://www.perl.com/perl/misc/Artistic.html)
14 #
15  
16 package Net::Flow::Ie;
17  
18 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 1 ▶use Exporter;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 1 ▶use Math::BigInt;
Subroutine BEGIN: called CC=1 SCAR=0.0
23  
24  
25 1 our $VERSION = '0.01';
26 1 our @EXPORT_OK = qw(iedecode addie);
27  
28 1 my $ieRef = {
29 # NetFlowV9
30
31 0=>{ # dummy
32 'Name'=>'dummy',
33 'Type'=>'octetArray' },
34 1=>{ # RFC5102
35 'Name'=>'octetDeltaCount',
36 'Type'=>'unsigned64' },
37 2=>{ # RFC5102
38 'Name'=>'packetDeltaCount',
39 'Type'=>'unsigned64' },
40 4=>{ # RFC5102
41 'Name'=>'protocolIdentifier',
42 'Type'=>'unsigned8' },
43 5=>{ # RFC5102
44 'Name'=>'ipClassOfService',
45 'Type'=>'unsigned8' },
46 6=>{ # RFC5102
47 'Name'=>'tcpControlBits',
48 'Type'=>'unsigned8' },
49 7=>{ # RFC5102
50 'Name'=>'sourceTransportPort',
51 'Type'=>'unsigned16' },
52 8=>{ # RFC5102
53 'Name'=>'sourceIPv4Address',
54 'Type'=>'ipv4Address' },
55 9=>{ # RFC5102
56 'Name'=>'sourceIPv4PrefixLength',
57 'Type'=>'unsigned8' },
58 10=>{ # RFC5102
59 'Name'=>'ingressInterface',
60 'Type'=>'unsigned32' },
61 11=>{ # RFC5102
62 'Name'=>'destinationTransportPort',
63 'Type'=>'unsigned16' },
64 12=>{ # RFC5102
65 'Name'=>'destinationIPv4Address',
66 'Type'=>'ipv4Address' },
67 13=>{ # RFC5102
68 'Name'=>'destinationIPv4PrefixLength',
69 'Type'=>'unsigned8' },
70 14=>{ # RFC5102
71 'Name'=>'egressInterface',
72 'Type'=>'unsigned32' },
73 15=>{ # RFC5102
74 'Name'=>'ipNextHopIPv4Address',
75 'Type'=>'ipv4Address' },
76 16=>{ # RFC5102
77 'Name'=>'bgpSourceAsNumber',
78 'Type'=>'unsigned32' },
79 17=>{ # RFC5102
80 'Name'=>'bgpDestinationAsNumber',
81 'Type'=>'unsigned32' },
82 18=>{ # RFC5102
83 'Name'=>'bgpNextHopIPv4Address',
84 'Type'=>'ipv4Address' },
85 19=>{ # RFC5102
86 'Name'=>'postMCastPacketDeltaCount',
87 'Type'=>'unsigned64' },
88 20=>{ # RFC5102
89 'Name'=>'postMCastOctetDeltaCount',
90 'Type'=>'unsigned64' },
91 21=>{ # RFC5102
92 'Name'=>'flowEndSysUpTime',
93 'Type'=>'unsigned32' },
94 22=>{ # RFC5102
95 'Name'=>'flowStartSysUpTime',
96 'Type'=>'unsigned32' },
97 23=>{ # RFC5102
98 'Name'=>'postOctetDeltaCount',
99 'Type'=>'unsigned64' },
100 24=>{ # RFC5102
101 'Name'=>'postPacketDeltaCount',
102 'Type'=>'unsigned64' },
103 25=>{ # RFC5102
104 'Name'=>'minimumIpTotalLength',
105 'Type'=>'unsigned64' },
106 26=>{ # RFC5102
107 'Name'=>'maximumIpTotalLength',
108 'Type'=>'unsigned64' },
109 27=>{ # RFC5102
110 'Name'=>'sourceIPv6Address',
111 'Type'=>'ipv6Address' },
112 28=>{ # RFC5102
113 'Name'=>'destinationIPv6Address',
114 'Type'=>'ipv6Address' },
115 29=>{ # RFC5102
116 'Name'=>'sourceIPv6PrefixLength',
117 'Type'=>'unsigned8' },
118 30=>{ # RFC5102
119 'Name'=>'destinationIPv6PrefixLength',
120 'Type'=>'unsigned8' },
121 31=>{ # RFC5102
122 'Name'=>'flowLabelIPv6',
123 'Type'=>'unsigned32' },
124 32=>{ # RFC5102
125 'Name'=>'icmpTypeCodeIPv4',
126 'Type'=>'unsigned16' },
127 33=>{ # RFC5102
128 'Name'=>'igmpType',
129 'Type'=>'unsigned8' },
130 36=>{ # RFC5102
131 'Name'=>'flowActiveTimeout',
132 'Type'=>'unsigned16' },
133 37=>{ # RFC5102
134 'Name'=>'flowIdleTimeout',
135 'Type'=>'unsigned16' },
136
137 38=>{ # NetFlowV9
138 'Name'=>'ENGINE_TYPE',
139 'Type'=>'unsigned8' },
140 39=>{ # NetFlowV9
141 'Name'=>'ENGINE_ID',
142 'Type'=>'unsigned8' },
143
144
145 40=>{ # RFC5102
146 'Name'=>'exportedOctetTotalCount',
147 'Type'=>'unsigned64' },
148 41=>{ # RFC5102
149 'Name'=>'exportedMessageTotalCount',
150 'Type'=>'unsigned64' },
151 42=>{ # RFC5102
152 'Name'=>'exportedFlowRecordTotalCount',
153 'Type'=>'unsigned64' },
154 44=>{ # RFC5102
155 'Name'=>'sourceIPv4Prefix',
156 'Type'=>'ipv4Address' },
157 45=>{ # RFC5102
158 'Name'=>'destinationIPv4Prefix',
159 'Type'=>'ipv4Address' },
160 46=>{ # RFC5102
161 'Name'=>'mplsTopLabelType',
162 'Type'=>'unsigned8' },
163 47=>{ # RFC5102
164 'Name'=>'mplsTopLabelIPv4Address',
165 'Type'=>'ipv4Address' },
166
167 48=>{ # NetFlowV9
168 'Name'=>'FLOW_SAMPLER_ID',
169 'Type'=>'unsigned8' },
170 49=>{ # NetFlowV9
171 'Name'=>'FLOW_SAMPLER_MODE',
172 'Type'=>'unsigned8' },
173 50=>{ # NetFlowV9
174 'Name'=>'FLOW_SAMPLER_RAMDOM_INTERVAL',
175 'Type'=>'unsigned32' },
176
177 52=>{ # RFC5102
178 'Name'=>'minimumTTL',
179 'Type'=>'unsigned8' },
180 53=>{ # RFC5102
181 'Name'=>'maximumTTL',
182 'Type'=>'unsigned8' },
183 54=>{ # RFC5102
184 'Name'=>'fragmentIdentification',
185 'Type'=>'unsigned32' },
186 55=>{ # RFC5102
187 'Name'=>'postIpClassOfService',
188 'Type'=>'unsigned8' },
189 56=>{ # RFC5102
190 'Name'=>'sourceMacAddress',
191 'Type'=>'macAddress' },
192 57=>{ # RFC5102
193 'Name'=>'postDestinationMacAddress',
194 'Type'=>'macAddress' },
195 58=>{ # RFC5102
196 'Name'=>'vlanId',
197 'Type'=>'unsigned16' },
198 59=>{ # RFC5102
199 'Name'=>'postVlanId',
200 'Type'=>'unsigned16' },
201 60=>{ # RFC5102
202 'Name'=>'ipVersion',
203 'Type'=>'unsigned8' },
204 61=>{ # RFC5102
205 'Name'=>'flowDirection',
206 'Type'=>'unsigned8' },
207 62=>{ # RFC5102
208 'Name'=>'ipNextHopIPv6Address',
209 'Type'=>'ipv6Address' },
210 63=>{ # RFC5102
211 'Name'=>'bgpNextHopIPv6Address',
212 'Type'=>'ipv6Address' },
213 64=>{ # RFC5102
214 'Name'=>'ipv6ExtensionHeaders',
215 'Type'=>'unsigned32' },
216 70=>{ # RFC5102
217 'Name'=>'mplsTopLabelStackSection',
218 'Type'=>'octetArray' },
219 71=>{ # RFC5102
220 'Name'=>'mplsLabelStackSection2',
221 'Type'=>'octetArray' },
222 72=>{ # RFC5102
223 'Name'=>'mplsLabelStackSection3',
224 'Type'=>'octetArray' },
225 73=>{ # RFC5102
226 'Name'=>'mplsLabelStackSection4',
227 'Type'=>'octetArray' },
228 74=>{ # RFC5102
229 'Name'=>'mplsLabelStackSection5',
230 'Type'=>'octetArray' },
231 75=>{ # RFC5102
232 'Name'=>'mplsLabelStackSection6',
233 'Type'=>'octetArray' },
234 76=>{ # RFC5102
235 'Name'=>'mplsLabelStackSection7',
236 'Type'=>'octetArray' },
237 77=>{ # RFC5102
238 'Name'=>'mplsLabelStackSection8',
239 'Type'=>'octetArray' },
240 78=>{ # RFC5102
241 'Name'=>'mplsLabelStackSection9',
242 'Type'=>'octetArray' },
243 79=>{ # RFC5102
244 'Name'=>'mplsLabelStackSection10',
245 'Type'=>'octetArray' },
246 80=>{ # RFC5102
247 'Name'=>'destinationMacAddress',
248 'Type'=>'macAddress' },
249 81=>{ # RFC5102
250 'Name'=>'postSourceMacAddress',
251 'Type'=>'macAddress' },
252
253 82=>{ # NetFlowV9
254 'Name'=>'INTERFACE_NAME',
255 'Type'=>'string' },
256 83=>{ # NetFlowV9
257 'Name'=>'INTERFACE_DESCRIPTION',
258 'Type'=>'string' },
259 84=>{ # NetFlowV9
260 'Name'=>'FLOW_SAMPLER_NAME',
261 'Type'=>'string' },
262
263 85=>{ # RFC5102
264 'Name'=>'octetTotalCount',
265 'Type'=>'unsigned64' },
266 86=>{ # RFC5102
267 'Name'=>'packetTotalCount',
268 'Type'=>'unsigned64' },
269 88=>{ # RFC5102
270 'Name'=>'fragmentOffset',
271 'Type'=>'unsigned16' },
272 90=>{ # RFC5102
273 'Name'=>'mplsVpnRouteDistinguisher',
274 'Type'=>'octetArray' },
275
276 # RFC5102
277
278 128=>{ # RFC5102
279 'Name'=>'bgpNextAdjacentAsNumber',
280 'Type'=>'unsigned32' },
281 129=>{ # RFC5102
282 'Name'=>'bgpPrevAdjacentAsNumber',
283 'Type'=>'unsigned32' },
284 130=>{ # RFC5102
285 'Name'=>'exporterIPv4Address',
286 'Type'=>'ipv4Address' },
287 131=>{ # RFC5102
288 'Name'=>'exporterIPv6Address',
289 'Type'=>'ipv6Address' },
290 132=>{ # RFC5102
291 'Name'=>'droppedOctetDeltaCount',
292 'Type'=>'unsigned64' },
293 133=>{ # RFC5102
294 'Name'=>'droppedPacketDeltaCount',
295 'Type'=>'unsigned64' },
296 134=>{ # RFC5102
297 'Name'=>'droppedOctetTotalCount',
298 'Type'=>'unsigned64' },
299 135=>{ # RFC5102
300 'Name'=>'droppedPacketTotalCount',
301 'Type'=>'unsigned64' },
302 136=>{ # RFC5102
303 'Name'=>'flowEndReason',
304 'Type'=>'unsigned8' },
305 137=>{ # RFC5102
306 'Name'=>'commonPropertiesId',
307 'Type'=>'unsigned64' },
308 138=>{ # RFC5102
309 'Name'=>'observationPointId',
310 'Type'=>'unsigned32' },
311 139=>{ # RFC5102
312 'Name'=>'icmpTypeCodeIPv6',
313 'Type'=>'unsigned16' },
314 140=>{ # RFC5102
315 'Name'=>'mplsTopLabelIPv6Address',
316 'Type'=>'ipv6Address' },
317 141=>{ # RFC5102
318 'Name'=>'lineCardId',
319 'Type'=>'unsigned32' },
320 142=>{ # RFC5102
321 'Name'=>'portId',
322 'Type'=>'unsigned32' },
323 143=>{ # RFC5102
324 'Name'=>'meteringProcessId',
325 'Type'=>'unsigned32' },
326 144=>{ # RFC5102
327 'Name'=>'exportingProcessId',
328 'Type'=>'unsigned32' },
329 145=>{ # RFC5102
330 'Name'=>'templateId',
331 'Type'=>'unsigned16' },
332 146=>{ # RFC5102
333 'Name'=>'wlanChannelId',
334 'Type'=>'unsigned8' },
335 147=>{ # RFC5102
336 'Name'=>'wlanSSID',
337 'Type'=>'string' },
338 148=>{ # RFC5102
339 'Name'=>'flowId',
340 'Type'=>'unsigned64' },
341 149=>{ # RFC5102
342 'Name'=>'observationDomainId',
343 'Type'=>'unsigned32' },
344 150=>{ # RFC5102
345 'Name'=>'flowStartSeconds',
346 'Type'=>'dateTimeSeconds' },
347 151=>{ # RFC5102
348 'Name'=>'flowEndSeconds',
349 'Type'=>'dateTimeSeconds' },
350 152=>{ # RFC5102
351 'Name'=>'flowStartMilliseconds',
352 'Type'=>'dateTimeMilliseconds' },
353 153=>{ # RFC5102
354 'Name'=>'flowEndMilliseconds',
355 'Type'=>'dateTimeMilliseconds' },
356 154=>{ # RFC5102
357 'Name'=>'flowStartMicroseconds',
358 'Type'=>'dateTimeMicroseconds' },
359 155=>{ # RFC5102
360 'Name'=>'flowEndMicroseconds',
361 'Type'=>'dateTimeMicroseconds' },
362 156=>{ # RFC5102
363 'Name'=>'flowStartNanoseconds',
364 'Type'=>'dateTimeNanoseconds' },
365 157=>{ # RFC5102
366 'Name'=>'flowEndNanoseconds',
367 'Type'=>'dateTimeNanoseconds' },
368 158=>{ # RFC5102
369 'Name'=>'flowStartDeltaMicroseconds',
370 'Type'=>'unsigned32' },
371 159=>{ # RFC5102
372 'Name'=>'flowEndDeltaMicroseconds',
373 'Type'=>'unsigned32' },
374 160=>{ # RFC5102
375 'Name'=>'systemInitTimeMilliseconds',
376 'Type'=>'unsigned32' },
377 161=>{ # RFC5102
378 'Name'=>'flowDurationMilliseconds',
379 'Type'=>'unsigned32' },
380 162=>{ # RFC5102
381 'Name'=>'flowDurationMicroseconds',
382 'Type'=>'unsigned32' },
383 163=>{ # RFC5102
384 'Name'=>'observedFlowTotalCount',
385 'Type'=>'unsigned64' },
386 164=>{ # RFC5102
387 'Name'=>'ignoredPacketTotalCount',
388 'Type'=>'unsigned64' },
389 165=>{ # RFC5102
390 'Name'=>'ignoredOctetTotalCount',
391 'Type'=>'unsigned64' },
392 166=>{ # RFC5102
393 'Name'=>'notSentFlowTotalCount',
394 'Type'=>'unsigned64' },
395 167=>{ # RFC5102
396 'Name'=>'notSentPacketTotalCount',
397 'Type'=>'unsigned64' },
398 168=>{ # RFC5102
399 'Name'=>'notSentOctetTotalCount',
400 'Type'=>'unsigned64' },
401 169=>{ # RFC5102
402 'Name'=>'destinationIPv6Prefix',
403 'Type'=>'ipv6Address' },
404 170=>{ # RFC5102
405 'Name'=>'sourceIPv6Prefix',
406 'Type'=>'ipv6Address' },
407 171=>{ # RFC5102
408 'Name'=>'postOctetTotalCount',
409 'Type'=>'unsigned64' },
410 172=>{ # RFC5102
411 'Name'=>'postPacketTotalCount',
412 'Type'=>'unsigned64' },
413 173=>{ # RFC5102
414 'Name'=>'flowKeyIndicator',
415 'Type'=>'unsigned64' },
416 174=>{ # RFC5102
417 'Name'=>'postMCastPacketTotalCount',
418 'Type'=>'unsigned64' },
419 175=>{ # RFC5102
420 'Name'=>'postMCastOctetTotalCount',
421 'Type'=>'unsigned64' },
422 176=>{ # RFC5102
423 'Name'=>'icmpTypeIPv4',
424 'Type'=>'unsigned8' },
425 177=>{ # RFC5102
426 'Name'=>'icmpCodeIPv4',
427 'Type'=>'unsigned8' },
428 178=>{ # RFC5102
429 'Name'=>'icmpTypeIPv6',
430 'Type'=>'unsigned8' },
431 179=>{ # RFC5102
432 'Name'=>'icmpCodeIPv6',
433 'Type'=>'unsigned8' },
434 180=>{ # RFC5102
435 'Name'=>'udpSourcePort',
436 'Type'=>'unsigned16' },
437 181=>{ # RFC5102
438 'Name'=>'udpDestinationPort',
439 'Type'=>'unsigned16' },
440 182=>{ # RFC5102
441 'Name'=>'tcpSourcePort',
442 'Type'=>'unsigned16' },
443 183=>{ # RFC5102
444 'Name'=>'tcpDestinationPort',
445 'Type'=>'unsigned16' },
446 184=>{ # RFC5102
447 'Name'=>'tcpSequenceNumber',
448 'Type'=>'unsigned32' },
449 185=>{ # RFC5102
450 'Name'=>'tcpAcknowledgementNumber',
451 'Type'=>'unsigned32' },
452 186=>{ # RFC5102
453 'Name'=>'tcpWindowSize',
454 'Type'=>'unsigned16' },
455 187=>{ # RFC5102
456 'Name'=>'tcpUrgentPointer',
457 'Type'=>'unsigned16' },
458 188=>{ # RFC5102
459 'Name'=>'tcpHeaderLength',
460 'Type'=>'unsigned8' },
461 189=>{ # RFC5102
462 'Name'=>'ipHeaderLength',
463 'Type'=>'unsigned8' },
464 190=>{ # RFC5102
465 'Name'=>'totalLengthIPv4',
466 'Type'=>'unsigned16' },
467 191=>{ # RFC5102
468 'Name'=>'payloadLengthIPv6',
469 'Type'=>'unsigned16' },
470 192=>{ # RFC5102
471 'Name'=>'ipTTL',
472 'Type'=>'unsigned8' },
473 193=>{ # RFC5102
474 'Name'=>'nextHeaderIPv6',
475 'Type'=>'unsigned8' },
476 194=>{ # RFC5102
477 'Name'=>'mplsPayloadLength',
478 'Type'=>'unsigned32' },
479 195=>{ # RFC5102
480 'Name'=>'ipDiffServCodePoint',
481 'Type'=>'unsigned8' },
482 196=>{ # RFC5102
483 'Name'=>'ipPrecedence',
484 'Type'=>'unsigned8' },
485 197=>{ # RFC5102
486 'Name'=>'fragmentFlags',
487 'Type'=>'unsigned8' },
488 198=>{ # RFC5102
489 'Name'=>'octetDeltaSumOfSquares',
490 'Type'=>'unsigned64' },
491 199=>{ # RFC5102
492 'Name'=>'octetTotalSumOfSquares',
493 'Type'=>'unsigned64' },
494 200=>{ # RFC5102
495 'Name'=>'mplsTopLabelTTL',
496 'Type'=>'unsigned8' },
497 201=>{ # RFC5102
498 'Name'=>'mplsLabelStackLength',
499 'Type'=>'unsigned32' },
500 202=>{ # RFC5102
501 'Name'=>'mplsLabelStackDepth',
502 'Type'=>'unsigned32' },
503 203=>{ # RFC5102
504 'Name'=>'mplsTopLabelExp',
505 'Type'=>'unsigned8' },
506 204=>{ # RFC5102
507 'Name'=>'ipPayloadLength',
508 'Type'=>'unsigned32' },
509 205=>{ # RFC5102
510 'Name'=>'udpMessageLength',
511 'Type'=>'unsigned16' },
512 206=>{ # RFC5102
513 'Name'=>'isMulticast',
514 'Type'=>'unsigned8' },
515 207=>{ # RFC5102
516 'Name'=>'ipv4IHL',
517 'Type'=>'unsigned8' },
518 208=>{ # RFC5102
519 'Name'=>'ipv4Options',
520 'Type'=>'unsigned32' },
521 209=>{ # RFC5102
522 'Name'=>'tcpOptions',
523 'Type'=>'unsigned64' },
524 210=>{ # RFC5102
525 'Name'=>'paddingOctets',
526 'Type'=>'octetArray' },
527 211=>{ # RFC5102
528 'Name'=>'collectorIPv4Address',
529 'Type'=>'ipv4Address' },
530 212=>{ # RFC5102
531 'Name'=>'collectorIPv6Address',
532 'Type'=>'ipv6Address' },
533 213=>{ # RFC5102
534 'Name'=>'exportInterface',
535 'Type'=>'unsigned32' },
536 214=>{ # RFC5102
537 'Name'=>'exportProtocolVersion',
538 'Type'=>'unsigned8' },
539 215=>{ # RFC5102
540 'Name'=>'exportTransportProtocol',
541 'Type'=>'unsigned8' },
542 216=>{ # RFC5102
543 'Name'=>'collectorTransportPort',
544 'Type'=>'unsigned16' },
545 217=>{ # RFC5102
546 'Name'=>'exporterTransportPort',
547 'Type'=>'unsigned16' },
548 218=>{ # RFC5102
549 'Name'=>'tcpSynTotalCount',
550 'Type'=>'unsigned64' },
551 219=>{ # RFC5102
552 'Name'=>'tcpFinTotalCount',
553 'Type'=>'unsigned64' },
554 220=>{ # RFC5102
555 'Name'=>'tcpRstTotalCount',
556 'Type'=>'unsigned64' },
557 221=>{ # RFC5102
558 'Name'=>'tcpPshTotalCount',
559 'Type'=>'unsigned64' },
560 222=>{ # RFC5102
561 'Name'=>'tcpAckTotalCount',
562 'Type'=>'unsigned64' },
563 223=>{ # RFC5102
564 'Name'=>'tcpUrgTotalCount',
565 'Type'=>'unsigned64' },
566 224=>{ # RFC5102
567 'Name'=>'ipTotalLength',
568 'Type'=>'unsigned64' },
569 237=>{ # RFC5102
570 'Name'=>'postMplsTopLabelExp',
571 'Type'=>'unsigned8' },
572 238=>{ # RFC5102
573 'Name'=>'tcpWindowScale',
574 'Type'=>'unsigned16' },
575 };
576  
577 0 ▶sub addie {
Subroutine addie: not called CC=4 SCAR=30.0
Pod documented
578 0 my( $Ref) = @_ ;
579  
580 0 ▶ return $ieRef if !(defined $Ref && ref $Ref) ;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $Ref and ref $Ref 0 0 0
Condition0%0/3
defined $Ref and ref $Ref
!ll&&!rl&&r
000
MC/DC0%0/2
defined $Ref and ref $Ref
defined $Ref ref $Ref
Truth table0%0/3
A and B
A= defined $RefB= ref $Ref
ABresult
0X0
100
111
581
582 0 foreach my $id (keys %{$Ref} ){
583 0 $$ieRef{$id}->{Name} = $$Ref{$id}->{Name} ;
584 0 $$ieRef{$id}->{Type} = $$Ref{$id}->{Type} ;
585 }
586
587 0 return $ieRef ;
588
589 }
590  
591 0 ▶sub iedecode {
Subroutine iedecode: not called CC=8 SCAR=42.8
Pod undocumented
592 0 my( $id,$bvalue,$Ref) = @_ ;
593 0 my $value = undef ;
594
595 0 ▶ if( !(defined $Ref && ref $Ref) ){
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $Ref and ref $Ref) 0 0 0
Condition0%0/3
defined $Ref and ref $Ref
!ll&&!rl&&r
000
MC/DC0%0/2
defined $Ref and ref $Ref
defined $Ref ref $Ref
Truth table0%0/3
A and B
A= defined $RefB= ref $Ref
ABresult
0X0
100
111
596 0 $Ref = $ieRef ;
597 }
598
599 0 ▶ $Ref->{$id}->{Name} = "unknown".$id if !defined $Ref->{$id}->{Name} ;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $Ref->{$id}{"Name"} 0 0 0
600 0 ▶ $Ref->{$id}->{Type} = "octetArray" if !defined $Ref->{$id}->{Type} ;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $Ref->{$id}{"Type"} 0 0 0
601
602 0 ▶ if( defined $bvalue ){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $bvalue) 0 0 0
603
604 0 ▶ if( ref $bvalue ){
Branch: 1 branch
BranchTrueFalseTotal
if (ref $bvalue) { } 0 0 0
605
606 0 foreach my $eachvalue ( @{$bvalue} ){
607
608 0 $value .= &eachdecode($id,$eachvalue,$Ref) . "," ;
609
610 }
611  
612 0 chop($value) ;
613
614 }else{
615
616 0 $value = &eachdecode($id,$bvalue,$Ref) ;
617
618 }
619
620 }
621  
622 return(
623 $Ref->{$id}->{Name},
624 0 $value
625 ) ;
626
627 }
628  
629 0 ▶sub eachdecode {
Subroutine eachdecode: not called CC=13 SCAR=52.0
Pod undocumented
630
631 0 my( $id,$bvalue,$Ref) = @_ ;
632 0 my $value = undef ;
633
634 0 ▶ if( $Ref->{$id}->{Type} =~ /^unsigned/ ){
Branch: 6 branches
BranchTrueFalseTotal
if ($Ref->{$id}{'Type'} =~ /^unsigned/) { } 0 0 0
elsif ($Ref->{$id}{'Type'} eq 'ipv4Address') { } 0 0 0
elsif ($Ref->{$id}{'Type'} eq 'ipv6Address') { } 0 0 0
elsif ($Ref->{$id}{'Type'} eq 'macAddress') { } 0 0 0
elsif ($Ref->{$id}{'Type'} eq 'octetArray') { } 0 0 0
elsif ($Ref->{$id}{'Type'} eq 'string') { } 0 0 0
635  
636 0 my $length = length($bvalue) ;
637  
638 0 ▶ if( $length == 1 ){
Branch: 4 branches
BranchTrueFalseTotal
if ($length == 1) { } 0 0 0
elsif ($length == 2) { } 0 0 0
elsif ($length == 4) { } 0 0 0
elsif ($length == 8) { } 0 0 0
639  
640 0 $value = unpack("C",$bvalue) ;
641  
642 }elsif( $length == 2 ){
643  
644 0 $value = unpack("n",$bvalue) ;
645
646 }elsif( $length == 4 ){
647  
648 0 $value = unpack("N",$bvalue) ;
649  
650 }elsif( $length == 8 ){
651  
652 0 my $bigvalue = Math::BigInt->new();
653 0 my ($value1,$value2) = unpack("NN",$bvalue) ;
654 0 $bigvalue += $value1<<32 ;
655 0 $bigvalue += $value2 ;
656 0 $value = $bigvalue->bstr() ;
657  
658 }else{
659
660 0 $value = unpack("H*",$bvalue) ;
661
662 }
663  
664 }elsif( $Ref->{$id}->{Type} eq "ipv4Address" ){
665
666 0 my @ipv4 = unpack("C4",$bvalue) ;
667 0 $value = $ipv4[0] .".". $ipv4[1] .".". $ipv4[2].".". $ipv4[3] ;
668
669 }elsif( $Ref->{$id}->{Type} eq "ipv6Address" ){
670
671 0 my @ipv6 = unpack("H4"x8,$bvalue) ;
672
673 0 foreach my $field (@ipv6){
674  
675 0 $field =~ s/^0+// ;
676 0 $value .= $field . ":" ;
677
678 }
679
680 0 chop($value) ;
681 0 $value =~ s/\:\:+/\:\:/ ;
682
683 }elsif( $Ref->{$id}->{Type} eq "macAddress" ){
684
685 0 $value = unpack("H*",$bvalue) ;
686 0 $value =~ s/([0-9a-f]{2})/$1\:/g ;
687
688 }elsif( $Ref->{$id}->{Type} eq "octetArray" ){
689
690 0 $value = unpack("H*",$bvalue) ;
691
692 }elsif( $Ref->{$id}->{Type} eq "string" ){
693
694 0 my $num = index($bvalue,pack("H*",0x00)) ;
695  
696 0 ▶ if( $num == 1 ){
Branch: 1 branch
BranchTrueFalseTotal
if ($num == 1) { } 0 0 0
697 0 $value = pack("a*",$bvalue) ;
698 }else{
699 0 $value = pack("a$num",$bvalue) ;
700 }
701
702 }else{
703
704 0 $value = unpack("H*",$bvalue) ;
705
706 }
707  
708 0 return( $value );
709
710 }
711  
712 1 1;
713  
714 __END__
↑ Summary