blib/lib/Net/OSCAR/XML/Template.pm

filter: Statementstmt 9.6% 26 / 269 Branchbran 0.0% 0 / 200 Conditioncond 0.0% 0 / 149 MC/DCmcdc 0.0% 0 / 82 Subroutinesub 47.3% 9 / 19 Podpod 0.0% 0 / 6 totaltotal 4.8% 35 / 725 CC 167 SCAR 88.3
CC
167
Cov
4%
unpack
10302.0
pack
3660.0
new
30.0
CRAP 6812.5
↑ Summary blib/lib/Net/OSCAR/Connection/Direct.pm »
1 # These objects, initialized with an "OSCAR protocol template" from Net::OSCAR::XML::protoparse,
2 # pack and unpack data according to the specification of that template.
3  
4 package Net::OSCAR::XML::Template;
5 5 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
6 5 $Net::OSCAR::XML::Template::VERSION = '1.928';
7 }
8  
9 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 5 ▶use Net::OSCAR::XML;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 5 ▶use Net::OSCAR::Common qw(:loglevels);
Subroutine BEGIN: called CC=1 SCAR=0.0
14 5 ▶use Net::OSCAR::Utility qw(hexdump);
Subroutine BEGIN: called CC=1 SCAR=0.0
15 5 ▶use Net::OSCAR::TLV;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 5 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 5 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 0 ▶sub new($@) {
Subroutine new: not called CC=5 SCAR=34.0
Pod undocumented
20 0 my $class = shift;
21 0 ▶ my $package = ref($class) || $class || "Net::OSCAR::XML::Template";
Condition0%0/5
ref $class || $class || 'Net::OSCAR::XML::Template'
l!l
00
ref $class or $class
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $class || $class || 'Net::OSCAR::XML::Template'
ref $class $class
Truth table0%0/3
A or B
A= ref $classB= $class
ABresult
1X1
011
000
22 0 my $self = {template => $_[0]};
23 0 ▶ $self->{oscar} = $class->{oscar} if ref($class) and $class->{oscar};
Branch: 1 branch
BranchTrueFalseTotal
if ref $class and $class->{"oscar"} 0 0 0
Condition0%0/3
ref $class and $class->{"oscar"}
!ll&&!rl&&r
000
MC/DC0%0/2
ref $class and $class->{"oscar"}
ref $class $class->{"oscar"}
Truth table0%0/3
A and B
A= ref $classB= $class->{"oscar"}
ABresult
0X0
100
111
24 0 bless $self, $package;
25 0 return $self;
26 }
27  
28 # Net::OSCAR::XML caches Template objects that don't have an associated OSCAR,
29 # so that the same Template can be reused with multiple OSCAR objects.
30 # Before returning a Template to the user, it calls set_oscar, so here we clone
31 # ourself with the new OSCAR.
32 #
33 0 ▶sub set_oscar($$) {
Subroutine set_oscar: not called CC=1 SCAR=6.9
Pod undocumented
34 0 my($self, $oscar) = @_;
35 0 my $clone = $self->new($self->{template});
36 0 $clone->{oscar} = $oscar;
37 0 return $clone;
38 }
39  
40  
41 # If given a scalar ref instead of a scalar as the second argument,
42 # we will modify the packet in-place.
43 0 ▶sub unpack($$) {
Subroutine unpack: not called CC=101 SCAR=92.4
Pod undocumented
44 0 my ($self, $x_packet) = @_;
45 0 my $oscar = $self->{oscar};
46 0 my $template = $self->{template};
47 0 ▶ my $packet = ref($x_packet) ? $$x_packet : $x_packet;
Branch: 1 branch
BranchTrueFalseTotal
ref $x_packet ? : 0 0 0
48  
49 0 my %data = ();
50  
51 0 ▶ $oscar->log_print_cond(OSCAR_DBG_XML, sub { "Decoding:\n", hexdump($packet), "\n according to: ", Data::Dumper::Dumper($template) });
Subroutine __ANON__: not called CC=1 SCAR=6.9
52  
53 0 assert(ref($template) eq "ARRAY");
54 0 foreach my $datum (@$template) {
55 # In TLV chains, count refers to number of TLVs, not number of repetitions of the datum, so it defaults to infinite.
56 0 ▶ my $count = $datum->{count} || ($datum->{type} eq "tlvchain" ? -1 : 1);
Branch: 1 branch
BranchTrueFalseTotal
$datum->{'type'} eq 'tlvchain' ? : 0 0 0
Condition0%0/3
$datum->{'count'} || ($datum->{'type'} eq 'tlvchain' ? -1 : 1)
l!l&&r!l&&!r
000
MC/DC0%0/2
$datum->{'count'} || ($datum->{'type'} eq 'tlvchain' ? -1 : 1)
$datum->{'count'} ($datum->{'type'} eq 'tlvchain' ? -1 : 1)
Truth table0%0/3
A || B
A= $datum->{'count'}B= ($datum->{'type'} eq 'tlvchain' ? -1 : 1)
ABresult
1X1
011
000
57 0 my @results;
58  
59  
60 ## Figure out how much input data this datum is dealing with
61  
62 0 ▶ if($datum->{prefix} and $datum->{prefix} eq "count") {
Branch: 1 branch
BranchTrueFalseTotal
if ($datum->{"prefix"} and $datum->{"prefix"} eq "count") 0 0 0
Condition0%0/3
$datum->{"prefix"} and $datum->{"prefix"} eq "count"
!ll&&!rl&&r
000
MC/DC0%0/2
$datum->{"prefix"} and $datum->{"prefix"} eq "count"
$datum->{"prefix"} $datum->{"prefix"} eq "count"
Truth table0%0/3
A and B
A= $datum->{"prefix"}B= $datum->{"prefix"} eq "count"
ABresult
0X0
100
111
63 0 ▶ ($count) = unpack($datum->{prefix_packlet}, substr($packet, 0, $datum->{prefix_len}, "")) || 0;
Condition0%0/2
CORE::unpack($datum->{'prefix_packlet'}, substr($packet, 0, $datum->{'prefix_len'}, '')) || 0
l!l
00
MC/DC0%0/1
CORE::unpack($datum->{'prefix_packlet'}, substr($packet, 0, $datum->{'prefix_len'}, '')) || 0
CORE::unpack($datum->{'prefix_packlet'}, substr($packet, 0, $datum->{'prefix_len'}, ''))
Truth table0%0/2
A
A= CORE::unpack($datum->{'prefix_packlet'}, substr($packet, 0, $datum->{'prefix_len'}, ''))
Aresult
11
00
64 }
65  
66 0 my $size = undef;
67 0 ▶ if($datum->{type} eq "num") {
Branch: 1 branch
BranchTrueFalseTotal
if ($datum->{'type'} eq 'num') { } 0 0 0
68 0 ▶ if($count != -1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($count != -1) { } 0 0 0
69 0 $size = $datum->{len} * $count;
70 } else {
71 0 $size = length($packet);
72 }
73 } else {
74 0 ▶ if($datum->{prefix} and $datum->{prefix} eq "length") {
Branch: 2 branches
BranchTrueFalseTotal
if ($datum->{'prefix'} and $datum->{'prefix'} eq 'length') { } 0 0 0
elsif (exists $datum->{'len'}) { } 0 0 0
Condition0%0/3
$datum->{"prefix"} and $datum->{"prefix"} eq "length"
!ll&&!rl&&r
000
MC/DC0%0/2
$datum->{"prefix"} and $datum->{"prefix"} eq "length"
$datum->{"prefix"} $datum->{"prefix"} eq "length"
Truth table0%0/3
A and B
A= $datum->{"prefix"}B= $datum->{"prefix"} eq "length"
ABresult
0X0
100
111
75 0 ($size) = unpack($datum->{prefix_packlet}, substr($packet, 0, $datum->{prefix_len}, ""));
76 } elsif(exists($datum->{len})) {
77 # In TLV chains, count is the number of TLVs, not a repeat
78 # count for the datum.
79 0 ▶ if($datum->{type} eq "tlvchain") {
Branch: 1 branch
BranchTrueFalseTotal
if ($datum->{'type'} eq 'tlvchain') { } 0 0 0
80 0 $size = $datum->{len};
81 } else {
82 0 ▶ if($count == -1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($count == -1) { } 0 0 0
83 0 $size = length($packet);
84 } else {
85 0 $size = $datum->{len} * $count;
86 }
87 }
88 }
89 }
90  
91 0 my $input;
92 0 ▶ if(defined($size)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $size) { } 0 0 0
93 0 $input = substr($packet, 0, $size, "");
94 } else {
95 0 $input = $packet;
96 }
97  
98  
99 ## Okay, we have our input data -- act on it
100  
101 0 ▶ if($datum->{type} eq "num") {
Branch: 3 branches
BranchTrueFalseTotal
if ($datum->{'type'} eq 'num') { } 0 0 0
elsif ($datum->{'type'} eq 'data' or $datum->{'type'} eq 'ref') { } 0 0 0
elsif ($datum->{'type'} eq 'tlvchain') { } 0 0 0
102 0 ▶ for(my $i = 0; ($input ne "") and ($count == -1 or $i < $count); $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($input ne "" and $count == -1 || $i < $count) 0 0 0
Condition0%0/6
$input ne "" and $count == -1 || $i < $count
!ll&&!rl&&r
000
$count == -1 or $i < $count
l!l&&r!l&&!r
000
MC/DC0%0/3
$input ne "" and $count == -1 || $i < $count
$input ne "" $count == -1 $i < $count
Truth table0%0/4
A and B or C
A= $input ne ""B= $count == -1C= $i < $count
ABCresult
0XX0
1000
11X1
1011
103 0 push @results, unpack($datum->{packlet}, substr($input, 0, $datum->{len}, ""));
104  
105 0 ▶ if(exists($datum->{enum_byval}) and exists($datum->{enum_byval}->{$results[-1]})) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $datum->{"enum_byval"} and exists $datum->{"enum_byval"}{$results[-1]}) 0 0 0
Condition0%0/3
exists $datum->{"enum_byval"} and exists $datum->{"enum_byval"}{$results[-1]}
!ll&&!rl&&r
000
MC/DC0%0/2
exists $datum->{"enum_byval"} and exists $datum->{"enum_byval"}{$results[-1]}
exists $datum->{"enum_byval"} exists $datum->{"enum_byval"}{$results[-1]}
Truth table0%0/3
A and B
A= exists $datum->{"enum_byval"}B= exists $datum->{"enum_byval"}{$results[-1]}
ABresult
0X0
100
111
106 0 $results[-1] = $datum->{enum_byval}->{$results[-1]};
107 }
108 }
109 ▶ } elsif($datum->{type} eq "data" or $datum->{type} eq "ref") {
Condition0%0/3
$datum->{"type"} eq "data" or $datum->{"type"} eq "ref"
l!l&&r!l&&!r
000
MC/DC0%0/2
$datum->{"type"} eq "data" or $datum->{"type"} eq "ref"
$datum->{"type"} eq "data" $datum->{"type"} eq "ref"
Truth table0%0/3
A or B
A= $datum->{"type"} eq "data"B= $datum->{"type"} eq "ref"
ABresult
1X1
011
000
110 # If we just have simple, no preset length, no subitems, raw data, it can't have a repeat count, since the first repetition will gobble up everything
111 0 ▶ assert($datum->{type} ne "data" or ($datum->{items} and @{$datum->{items}}) or defined($size) or $count == 1 or $datum->{null_terminated});
Condition0%0/15
$datum->{'type'} ne 'data' || $datum->{'items'} && @{$datum->{'items'};} || defined $size || $count == 1 || $datum->{'null_terminated'}
l!l&&r!l&&!r
000
$datum->{"type"} ne "data" or $datum->{"items"} and @{$datum->{"items"};} or defined $size or $count == 1
l!l&&r!l&&!r
000
$datum->{"type"} ne "data" or $datum->{"items"} and @{$datum->{"items"};} or defined $size
l!l&&r!l&&!r
000
$datum->{"type"} ne "data" or $datum->{"items"} and @{$datum->{"items"};}
l!l&&r!l&&!r
000
$datum->{"items"} and @{$datum->{"items"};}
!ll&&!rl&&r
000
MC/DC0%0/6
$datum->{'type'} ne 'data' || $datum->{'items'} && @{$datum->{'items'};} || defined $size || $count == 1 || $datum->{'null_terminated'}
$datum->{"type"} ne "data" $datum->{"items"} @{$datum->{"items"};} defined $size $count == 1 $datum->{'null_terminated'}
Truth table0%0/10
A or B and C or D or E || F
A= $datum->{"type"} ne "data"B= $datum->{"items"}C= @{$datum->{"items"};}D= defined $sizeE= $count == 1F= $datum->{'null_terminated'}
ABCDEFresult
1XXXXX1
011XXX1
00X1XX1
0101XX1
00X01X1
01001X1
00X0011
0100011
00X0000
0100000
112  
113 # We want:
114 # <data length_prefix="num" />
115 # to be empty string, not undefined, when length==0.
116 0 ▶ if(!$input and $count == 1 and defined($size)) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $input and $count == 1 and defined $size) 0 0 0
Condition0%0/6
not $input and $count == 1 and defined $size
!ll&&!rl&&r
000
not $input and $count == 1
!ll&&!rl&&r
000
MC/DC0%0/3
not $input and $count == 1 and defined $size
not $input $count == 1 defined $size
Truth table0%0/4
not(A) and B and C
A= not $inputB= $count == 1C= defined $size
ABCresult
0XX0
10X0
1100
1111
117 0 push @results, "";
118 }
119  
120 0 ▶ for(my $i = 0; $input and ($count == -1 or $i < $count); $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($input and $count == -1 || $i < $count) 0 0 0
Condition0%0/6
$input and $count == -1 || $i < $count
!ll&&!rl&&r
000
$count == -1 or $i < $count
l!l&&r!l&&!r
000
MC/DC0%0/3
$input and $count == -1 || $i < $count
$input $count == -1 $i < $count
Truth table0%0/4
A and B or C
A= $inputB= $count == -1C= $i < $count
ABCresult
0XX0
1000
11X1
1011
121 # So, consider the structure:
122 # <data name="foo">
123 # <word />
124 # <word />
125 # </data>
126 # We don't know the size of 'foo' in advance.
127 # Thus, we pass a reference to the actual packet into protopack.
128 # subpacket will be modified to be the packet minus the bits that the contents of the data consumed.
129  
130 0 my %tmp;
131 0 ▶ if($datum->{type} eq "data") {
Branch: 2 branches
BranchTrueFalseTotal
if ($datum->{'type'} eq 'data') { } 0 0 0
elsif ($datum->{'type'} eq 'ref') { } 0 0 0
132 0 my $subinput;
133 0 ▶ if($datum->{len}) {
Branch: 2 branches
BranchTrueFalseTotal
if ($datum->{'len'}) { } 0 0 0
elsif ($datum->{'null_terminated'}) { } 0 0 0
134 0 $subinput = substr($input, 0, $datum->{len}, "");
135 } elsif($datum->{null_terminated}) {
136 0 $input =~ s/^(.*?)\0//;
137 0 $subinput = $1;
138 } else {
139 0 $subinput = $input;
140 0 $input = "";
141 }
142  
143 0 ▶ if(exists($datum->{pad})) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $datum->{"pad"}) 0 0 0
144 0 my $pad = chr($datum->{pad});
145 0 $subinput =~ s/$pad*$//;
146 }
147  
148 0 ▶ if($datum->{items} and @{$datum->{items}}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($datum->{'items'} and @{$datum->{'items'};}) { } 0 0 0
Condition0%0/3
$datum->{"items"} and @{$datum->{"items"};}
!ll&&!rl&&r
000
MC/DC0%0/2
$datum->{"items"} and @{$datum->{"items"};}
$datum->{"items"} @{$datum->{"items"};}
Truth table0%0/3
A and B
A= $datum->{"items"}B= @{$datum->{"items"};}
ABresult
0X0
100
111
149 0 assert(!$datum->{null_terminated});
150 0 (%tmp) = $self->new($datum->{items})->unpack(\$subinput);
151 0 ▶ $input = $subinput unless $datum->{len};
Branch: 1 branch
BranchTrueFalseTotal
unless $datum->{"len"} 0 0 0
152 } else {
153 0 ▶ $subinput =~ s/\0$// if $datum->{null_terminated};
Branch: 1 branch
BranchTrueFalseTotal
if $datum->{"null_terminated"} 0 0 0
154  
155 # The simple case -- raw <data />
156 0 ▶ push @results, $subinput if $datum->{name};
Branch: 1 branch
BranchTrueFalseTotal
if $datum->{"name"} 0 0 0
157 }
158 } elsif($datum->{type} eq "ref") {
159 0 (%tmp) = protoparse($oscar, $datum->{name})->unpack(\$input);
160 }
161  
162 0 ▶ push @results, \%tmp if %tmp;
Branch: 1 branch
BranchTrueFalseTotal
if %tmp 0 0 0
163 }
164 } elsif($datum->{type} eq "tlvchain") {
165 0 my @unknown;
166  
167 ## First set up a hash to store the data for each TLV, grouped by (sub)type
168 ##
169 0 my $tlvmap = tlv();
170 0 ▶ if($datum->{subtyped}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($datum->{'subtyped'}) { } 0 0 0
171 0 foreach (@{$datum->{items}}) {
172 0 ▶ $tlvmap->{$_->{num}} ||= tlv();
Condition0%0/3
$$tlvmap{$_->{"num"}} ||= &tlv()
l!l&&r!l&&!r
000
MC/DC0%0/2
$$tlvmap{$_->{"num"}} ||= &tlv()
$$tlvmap{$_->{"num"}} &tlv()
Truth table0%0/3
A ||= B
A= $$tlvmap{$_->{"num"}}B= &tlv()
ABresult
1X1
011
000
173 0 ▶ $tlvmap->{$_->{num}}->{$_->{subtype} || -1} = {%$_};
Condition0%0/2
$_->{'subtype'} || -1
l!l
00
MC/DC0%0/1
$_->{'subtype'} || -1
$_->{'subtype'}
Truth table0%0/2
A
A= $_->{'subtype'}
Aresult
11
00
174 }
175 } else {
176 0 $tlvmap->{$_->{num}} = {%$_} foreach (@{$datum->{items}});
177 }
178  
179 ## Now, go through the chain and split the data into TLVs.
180 ##
181 0 ▶ for(my $i = 0; $input and ($count == -1 or $i < $count); $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($input and $count == -1 || $i < $count) 0 0 0
Condition0%0/6
$input and $count == -1 || $i < $count
!ll&&!rl&&r
000
$count == -1 or $i < $count
l!l&&r!l&&!r
000
MC/DC0%0/3
$input and $count == -1 || $i < $count
$input $count == -1 $i < $count
Truth table0%0/4
A and B or C
A= $inputB= $count == -1C= $i < $count
ABCresult
0XX0
1000
11X1
1011
182 0 my %tlv;
183 0 ▶ if($datum->{subtyped}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($datum->{'subtyped'}) { } 0 0 0
184 0 (%tlv) = protoparse($oscar, "subtyped_TLV")->unpack(\$input);
185 } else {
186 0 (%tlv) = protoparse($oscar, "TLV")->unpack(\$input);
187 }
188  
189 0 my $unknown = 0;
190 0 ▶ if(!exists($tlvmap->{$tlv{type}})) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $$tlvmap{$tlv{"type"}}) 0 0 0
191 0 ▶ $tlvmap->{$tlv{type}} = $datum->{subtyped} ? tlv() : {};
Branch: 1 branch
BranchTrueFalseTotal
$datum->{'subtyped'} ? : 0 0 0
192 0 $unknown = 1;
193 }
194  
195 0 ▶ assert(!exists($tlv{name})) if exists($tlv{count});
Branch: 1 branch
BranchTrueFalseTotal
if exists $tlv{"count"} 0 0 0
196 0 ▶ if($datum->{subtyped}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($datum->{'subtyped'}) { } 0 0 0
197 0 assert(exists($tlv{subtype}));
198  
199 0 ▶ if(!exists($tlvmap->{$tlv{type}}->{$tlv{subtype}})) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $$tlvmap{$tlv{"type"}}{$tlv{"subtype"}}) 0 0 0
200 0 ▶ if(exists($tlvmap->{$tlv{type}}->{-1})) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $$tlvmap{$tlv{'type'}}{'-1'}) { } 0 0 0
201 0 $tlv{subtype} = -1;
202 } else {
203 0 $tlvmap->{$tlv{type}}->{$tlv{subtype}} = {};
204 0 $unknown = 1;
205 }
206 }
207  
208 0 ▶ if(!$unknown) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $unknown) { } 0 0 0
209 0 my $type = $tlv{type};
210 0 my $subtype = $tlv{subtype};
211 0 ▶ $tlvmap->{$type}->{$subtype}->{data} ||= [];
Condition0%0/2
$tlvmap->{$type}{$subtype}{"data"} ||= []
l!l
00
MC/DC0%0/1
$tlvmap->{$type}{$subtype}{"data"} ||= []
$tlvmap->{$type}{$subtype}{"data"}
Truth table0%0/2
A
A= $tlvmap->{$type}{$subtype}{"data"}
Aresult
11
00
212 0 ▶ $tlvmap->{$type}->{$subtype}->{outdata} ||= [];
Condition0%0/2
$tlvmap->{$type}{$subtype}{"outdata"} ||= []
l!l
00
MC/DC0%0/1
$tlvmap->{$type}{$subtype}{"outdata"} ||= []
$tlvmap->{$type}{$subtype}{"outdata"}
Truth table0%0/2
A
A= $tlvmap->{$type}{$subtype}{"outdata"}
Aresult
11
00
213  
214 0 ▶ $tlv{data} = "" if !defined($tlv{data});
Branch: 1 branch
BranchTrueFalseTotal
unless defined $tlv{"data"} 0 0 0
215 0 push @{$tlvmap->{$type}->{$subtype}->{data}}, $tlv{data};
216 } else {
217 push @unknown, {
218 type => $tlv{type},
219 subtype => $tlv{subtype},
220 data => $tlv{data}
221 0 };
222 }
223 } else {
224 0 ▶ if(!$unknown) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $unknown) { } 0 0 0
225 0 my $type = $tlv{type};
226 0 ▶ $tlvmap->{$type}->{data} ||= [];
Condition0%0/2
$tlvmap->{$type}{"data"} ||= []
l!l
00
MC/DC0%0/1
$tlvmap->{$type}{"data"} ||= []
$tlvmap->{$type}{"data"}
Truth table0%0/2
A
A= $tlvmap->{$type}{"data"}
Aresult
11
00
227 0 ▶ $tlvmap->{$type}->{outdata} ||= [];
Condition0%0/2
$tlvmap->{$type}{"outdata"} ||= []
l!l
00
MC/DC0%0/1
$tlvmap->{$type}{"outdata"} ||= []
$tlvmap->{$type}{"outdata"}
Truth table0%0/2
A
A= $tlvmap->{$type}{"outdata"}
Aresult
11
00
228  
229 0 ▶ $tlv{data} = "" if !defined($tlv{data});
Branch: 1 branch
BranchTrueFalseTotal
unless defined $tlv{"data"} 0 0 0
230 0 push @{$tlvmap->{$tlv{type}}->{data}}, $tlv{data};
231 } else {
232 push @unknown, {
233 type => $tlv{type},
234 data => $tlv{data}
235 0 };
236 }
237 }
238 }
239  
240 ## Almost done! Go back through the hash we made earlier, which now has the
241 ## data in it, and figure out which TLVs we want to emit.
242 ##
243 0 my @outvals;
244 0 ▶ while(my($num, $val) = each %$tlvmap) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %$tlvmap) 0 0 0
245 0 ▶ if($datum->{subtyped}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($datum->{'subtyped'}) { } 0 0 0
246 0 ▶ while(my($subtype, $subval) = each %$val) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %$val) 0 0 0
247 0 ▶ push @outvals, $subval if exists($subval->{data});
Branch: 1 branch
BranchTrueFalseTotal
if exists $subval->{"data"} 0 0 0
248 }
249 } else {
250 0 ▶ push @outvals, $val if exists($val->{data});
Branch: 1 branch
BranchTrueFalseTotal
if exists $val->{"data"} 0 0 0
251 }
252 }
253  
254  
255 ## Okay, now take the TLVs to emit, and structure the output correctly
256 ## for each thing-to-emit. We'll need to do one last phase of postprocessing
257 ## so that we can group counted TLVs correctly.
258 ##
259 0 foreach my $val (@outvals) {
260 0 foreach (@{$val->{data}}) {
261 0 ▶ next unless exists($val->{items});
Branch: 1 branch
BranchTrueFalseTotal
unless exists $val->{"items"} 0 0 0
262 0 my(%tmp) = $self->new($val->{items})->unpack($_);
263 # We want:
264 # <tlv type="1"><data name="x" /></tlv>
265 # to give x => "" when TLV 1 is present but empty,
266 # not x => undef.
267 0 ▶ if(@{$val->{items}} == 1 and $val->{items}->[0]->{name}) {
Branch: 1 branch
BranchTrueFalseTotal
if (@{$val->{"items"};} == 1 and $val->{"items"}[0]{"name"}) 0 0 0
Condition0%0/3
@{$val->{"items"};} == 1 and $val->{"items"}[0]{"name"}
!ll&&!rl&&r
000
MC/DC0%0/2
@{$val->{"items"};} == 1 and $val->{"items"}[0]{"name"}
@{$val->{"items"};} == 1 $val->{"items"}[0]{"name"}
Truth table0%0/3
A and B
A= @{$val->{"items"};} == 1B= $val->{"items"}[0]{"name"}
ABresult
0X0
100
111
268 0 my $name = $val->{items}->[0]->{name};
269 0 ▶ $tmp{$name} = "" if !defined($tmp{$name});
Branch: 1 branch
BranchTrueFalseTotal
unless defined $tmp{$name} 0 0 0
270 }
271  
272 0 ▶ if(@{$val->{items}}) {
Branch: 1 branch
BranchTrueFalseTotal
if (@{$val->{'items'};}) { } 0 0 0
273 0 push @{$val->{outdata}}, \%tmp;
274 } else {
275 0 push @{$val->{outdata}}, "";
276 }
277 }
278 }
279  
280  
281 ## Okay, we've stashed the output (formatted data structures) for each TLV.
282 ## Now we need to merge these into results.
283 ## This is normally just pushing everything out to results, as a hashref
284 ## under the TLVs name for named TLVs, but counted TLVs also need to
285 ## be layered into an array.
286 ##
287 0 foreach my $val (@outvals) {
288 0 ▶ if(exists($val->{count})) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $val->{'count'}) { } 0 0 0
289 0 ▶ if(exists($val->{name})) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $val->{'name'}) { } 0 0 0
290 push @results, {
291 $val->{name} => $val->{outdata}
292 0 };
293 } else {
294 0 push @results, $val->{outdata}->[0];
295 }
296 } else {
297 0 ▶ if(exists($val->{name})) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $val->{'name'}) { } 0 0 0
298 push @results, {
299 0 $val->{name} => $val->{outdata}->[0]
300 };
301 } else {
302 0 push @results, $val->{outdata}->[0];
303 }
304 }
305 }
306  
307 0 ▶ push @results, {__UNKNOWN => [@unknown]} if @unknown;
Branch: 1 branch
BranchTrueFalseTotal
if @unknown 0 0 0
308 }
309  
310  
311 # If we didn't know the length of the datum in advance,
312 # we've been modifying the entire packet in-place.
313 0 ▶ $packet = $input if !defined($size);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $size 0 0 0
314  
315  
316 ## Okay, we have the results from this datum, store them away.
317  
318 0 ▶ if($datum->{name}) {
Branch: 2 branches
BranchTrueFalseTotal
if ($datum->{'name'}) { } 0 0 0
elsif (@results) { } 0 0 0
319 0 ▶ if($datum->{count} or ($datum->{prefix} and $datum->{prefix} eq "count")) {
Branch: 2 branches
BranchTrueFalseTotal
if ($datum->{'count'} or $datum->{'prefix'} and $datum->{'prefix'} eq 'count') { } 0 0 0
elsif ($datum->{'type'} eq 'ref' or ref $datum->{'items'} and @{$datum->{'items'};}) { } 0 0 0
Condition0%0/6
$datum->{"count"} or $datum->{"prefix"} and $datum->{"prefix"} eq "count"
l!l&&r!l&&!r
000
$datum->{"prefix"} and $datum->{"prefix"} eq "count"
!ll&&!rl&&r
000
MC/DC0%0/3
$datum->{"count"} or $datum->{"prefix"} and $datum->{"prefix"} eq "count"
$datum->{"count"} $datum->{"prefix"} $datum->{"prefix"} eq "count"
Truth table0%0/4
A or B and C
A= $datum->{"count"}B= $datum->{"prefix"}C= $datum->{"prefix"} eq "count"
ABCresult
1XX1
0111
00X0
0100
320 0 $data{$datum->{name}} = \@results;
321 ▶ } elsif(
Condition0%0/6
$datum->{"type"} eq "ref" or ref $datum->{"items"} and @{$datum->{"items"};}
l!l&&r!l&&!r
000
ref $datum->{"items"} and @{$datum->{"items"};}
!ll&&!rl&&r
000
MC/DC0%0/3
$datum->{"type"} eq "ref" or ref $datum->{"items"} and @{$datum->{"items"};}
$datum->{"type"} eq "ref" ref $datum->{"items"} @{$datum->{"items"};}
Truth table0%0/4
A or B and C
A= $datum->{"type"} eq "ref"B= ref $datum->{"items"}C= @{$datum->{"items"};}
ABCresult
1XX1
0111
00X0
0100
322 $datum->{type} eq "ref" or
323 0 (ref($datum->{items}) and @{$datum->{items}})
324 ) {
325 0 $data{$_} = $results[0]->{$_} foreach keys %{$results[0]};
326 } else {
327 0 $data{$datum->{name}} = $results[0];
328 }
329 } elsif(@results) {
330 0 foreach my $result(@results) {
331 0 ▶ next unless ref($result);
Branch: 1 branch
BranchTrueFalseTotal
unless ref $result 0 0 0
332 0 $data{$_} = $result->{$_} foreach keys %$result;
333 }
334 }
335 }
336  
337 0 ▶ $oscar->log_print_cond(OSCAR_DBG_XML, sub { "Decoded:\n", join("\n", map { "\t$_ => ".(defined($data{$_}) ? hexdump($data{$_}) : 'undef') } keys %data) });
Subroutine __ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
BranchTrueFalseTotal
defined $data{$_} ? : 0 0 0
338  
339 # Remember, passing in a ref to packet in place of actual packet data == in-place editing...
340 0 ▶ $$x_packet = $packet if ref($x_packet);
Branch: 1 branch
BranchTrueFalseTotal
if ref $x_packet 0 0 0
341  
342 0 return %data;
343 }
344  
345  
346 0 ▶sub pack($%) {
Subroutine pack: not called CC=60 SCAR=82.1
Pod undocumented
347 0 my($self, %data) = @_;
348 0 my $packet = "";
349 0 my $oscar = $self->{oscar};
350 0 my $template = $self->{template};
351  
352 0 ▶ $oscar->log_print_cond(OSCAR_DBG_XML, sub { "Encoding:\n", join("\n", map { "\t$_ => ".(defined($data{$_}) ? hexdump($data{$_}) : 'undef') } keys %data), "\n according to: ", Data::Dumper::Dumper($template) });
Subroutine __ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
BranchTrueFalseTotal
defined $data{$_} ? : 0 0 0
353  
354 0 assert(ref($template) eq "ARRAY");
355 0 foreach my $datum (@$template) {
356 0 my $output = undef;
357  
358 ## Figure out what we're packing
359 0 my $value = undef;
360 0 ▶ $value = $data{$datum->{name}} if $datum->{name};
Branch: 1 branch
BranchTrueFalseTotal
if $datum->{"name"} 0 0 0
361 0 ▶ $value = $datum->{value} if !defined($value);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value 0 0 0
362 0 ▶ my @valarray = ref($value) eq "ARRAY" ? @$value : ($value); # Don't modify $value in-place!
Branch: 1 branch
BranchTrueFalseTotal
ref $value eq 'ARRAY' ? : 0 0 0
363  
364 0 ▶ $datum->{count} = @valarray if $datum->{prefix} and $datum->{prefix} eq "count";
Branch: 1 branch
BranchTrueFalseTotal
if $datum->{"prefix"} and $datum->{"prefix"} eq "count" 0 0 0
Condition0%0/3
$datum->{"prefix"} and $datum->{"prefix"} eq "count"
!ll&&!rl&&r
000
MC/DC0%0/2
$datum->{"prefix"} and $datum->{"prefix"} eq "count"
$datum->{"prefix"} $datum->{"prefix"} eq "count"
Truth table0%0/3
A and B
A= $datum->{"prefix"}B= $datum->{"prefix"} eq "count"
ABresult
0X0
100
111
365 0 ▶ my $max_count = exists($datum->{count}) ? $datum->{count} : 1;
Branch: 1 branch
BranchTrueFalseTotal
exists $datum->{'count'} ? : 0 0 0
366 0 my $count = 0;
367  
368 0 ▶ assert($max_count == -1 or @valarray <= $max_count);
Condition0%0/3
$max_count == -1 || @valarray <= $max_count
l!l&&r!l&&!r
000
MC/DC0%0/2
$max_count == -1 || @valarray <= $max_count
$max_count == -1 @valarray <= $max_count
Truth table0%0/3
A || B
A= $max_count == -1B= @valarray <= $max_count
ABresult
1X1
011
000
369  
370  
371 ## Pack it
372 0 ▶ if($datum->{type} eq "num") {
Branch: 3 branches
BranchTrueFalseTotal
if ($datum->{'type'} eq 'num') { } 0 0 0
elsif ($datum->{'type'} eq 'data' or $datum->{'type'} eq 'ref') { } 0 0 0
elsif ($datum->{'type'} eq 'tlvchain') { } 0 0 0
373 0 ▶ next unless defined($value);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value 0 0 0
374  
375 0 ▶ for($count = 0; ($max_count == -1 or $count < $max_count) and @valarray; $count++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($max_count == -1 || $count < $max_count and @valarray) 0 0 0
Condition0%0/6
$max_count == -1 || $count < $max_count and @valarray
!ll&&!rl&&r
000
$max_count == -1 or $count < $max_count
l!l&&r!l&&!r
000
MC/DC0%0/3
$max_count == -1 || $count < $max_count and @valarray
$max_count == -1 $count < $max_count @valarray
Truth table0%0/5
A or B and C
A= $max_count == -1B= $count < $max_countC= @valarray
ABCresult
00X0
1X00
0100
1X11
0111
376 0 my $val = shift @valarray;
377 0 ▶ if(exists($datum->{enum_byname}) and exists($datum->{enum_byname}->{$val})) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $datum->{"enum_byname"} and exists $datum->{"enum_byname"}{$val}) 0 0 0
Condition0%0/3
exists $datum->{"enum_byname"} and exists $datum->{"enum_byname"}{$val}
!ll&&!rl&&r
000
MC/DC0%0/2
exists $datum->{"enum_byname"} and exists $datum->{"enum_byname"}{$val}
exists $datum->{"enum_byname"} exists $datum->{"enum_byname"}{$val}
Truth table0%0/3
A and B
A= exists $datum->{"enum_byname"}B= exists $datum->{"enum_byname"}{$val}
ABresult
0X0
100
111
378 0 $val = $datum->{enum_byname}->{$val};
379 }
380  
381 0 $output .= pack($datum->{packlet}, $val);
382 }
383 ▶ } elsif($datum->{type} eq "data" or $datum->{type} eq "ref") {
Condition0%0/3
$datum->{"type"} eq "data" or $datum->{"type"} eq "ref"
l!l&&r!l&&!r
000
MC/DC0%0/2
$datum->{"type"} eq "data" or $datum->{"type"} eq "ref"
$datum->{"type"} eq "data" $datum->{"type"} eq "ref"
Truth table0%0/3
A or B
A= $datum->{"type"} eq "data"B= $datum->{"type"} eq "ref"
ABresult
1X1
011
000
384 0 ▶ for($count = 0; ($max_count == -1 or $count < $max_count) and @valarray; $count++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($max_count == -1 || $count < $max_count and @valarray) 0 0 0
Condition0%0/6
$max_count == -1 || $count < $max_count and @valarray
!ll&&!rl&&r
000
$max_count == -1 or $count < $max_count
l!l&&r!l&&!r
000
MC/DC0%0/3
$max_count == -1 || $count < $max_count and @valarray
$max_count == -1 $count < $max_count @valarray
Truth table0%0/5
A or B and C
A= $max_count == -1B= $count < $max_countC= @valarray
ABCresult
00X0
1X00
0100
1X11
0111
385 0 my $val = shift @valarray;
386  
387 0 ▶ if($datum->{items} and @{$datum->{items}}) {
Branch: 2 branches
BranchTrueFalseTotal
if ($datum->{'items'} and @{$datum->{'items'};}) { } 0 0 0
elsif ($datum->{'type'} eq 'ref') { } 0 0 0
Condition0%0/3
$datum->{"items"} and @{$datum->{"items"};}
!ll&&!rl&&r
000
MC/DC0%0/2
$datum->{"items"} and @{$datum->{"items"};}
$datum->{"items"} @{$datum->{"items"};}
Truth table0%0/3
A and B
A= $datum->{"items"}B= @{$datum->{"items"};}
ABresult
0X0
100
111
388 0 ▶ $output .= $self->new($datum->{items})->pack(ref($val) ? %$val : %data);
Branch: 1 branch
BranchTrueFalseTotal
ref $val ? : 0 0 0
389 } elsif($datum->{type} eq "ref") {
390 0 ▶ assert($max_count == 1 or (ref($val) and ref($val) eq "HASH"));
Condition0%0/6
$max_count == 1 || ref $val && ref $val eq 'HASH'
l!l&&r!l&&!r
000
ref $val and ref $val eq "HASH"
!ll&&!rl&&r
000
MC/DC0%0/3
$max_count == 1 || ref $val && ref $val eq 'HASH'
$max_count == 1 ref $val ref $val eq "HASH"
Truth table0%0/4
A || B and C
A= $max_count == 1B= ref $valC= ref $val eq "HASH"
ABCresult
1XX1
0111
00X0
0100
391 0 ▶ $output .= protoparse($oscar, $datum->{name})->pack(ref($val) ? %$val : %data);
Branch: 1 branch
BranchTrueFalseTotal
ref $val ? : 0 0 0
392 } else {
393 0 ▶ $output .= $val if defined($val);
Branch: 1 branch
BranchTrueFalseTotal
if defined $val 0 0 0
394 }
395  
396 0 ▶ $output .= chr(0) if $datum->{null_terminated};
Branch: 1 branch
BranchTrueFalseTotal
if $datum->{"null_terminated"} 0 0 0
397 0 ▶ if(exists($datum->{pad})) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $datum->{"pad"}) 0 0 0
398 0 ▶ assert(exists($datum->{len}) and exists($datum->{pad}));
Condition0%0/3
exists $datum->{'len'} && exists $datum->{'pad'}
!ll&&!rl&&r
000
MC/DC0%0/2
exists $datum->{'len'} && exists $datum->{'pad'}
exists $datum->{'len'} exists $datum->{'pad'}
Truth table0%0/3
A && B
A= exists $datum->{'len'}B= exists $datum->{'pad'}
ABresult
0X0
100
111
399  
400 0 ▶ my $outlen = defined($output) ? length($output) : 0;
Branch: 1 branch
BranchTrueFalseTotal
defined $output ? : 0 0 0
401 0 my $pad_needed = $datum->{len} - $outlen;
402 0 ▶ $output .= chr($datum->{pad}) x $pad_needed if $pad_needed;
Branch: 1 branch
BranchTrueFalseTotal
if $pad_needed 0 0 0
403 }
404 }
405 } elsif($datum->{type} eq "tlvchain") {
406 0 foreach my $tlv (@{$datum->{items}}) {
407 0 my $tlvdata = undef;
408  
409 0 ▶ if(exists($tlv->{name})) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $tlv->{'name'}) { } 0 0 0
410 0 ▶ if(exists($data{$tlv->{name}})) {
Branch: 2 branches
BranchTrueFalseTotal
if (exists $data{$tlv->{'name'}}) { } 0 0 0
elsif (exists $tlv->{'value'} and not @{$tlv->{'items'};}) { } 0 0 0
411 0 ▶ if(@{$tlv->{items}}) {
Branch: 1 branch
BranchTrueFalseTotal
if (@{$tlv->{'items'};}) { } 0 0 0
412 0 ▶ assert(ref($data{$tlv->{name}}) eq "HASH" or ref($data{$tlv->{name}}) eq "ARRAY");
Condition0%0/3
ref $data{$tlv->{'name'}} eq 'HASH' || ref $data{$tlv->{'name'}} eq 'ARRAY'
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $data{$tlv->{'name'}} eq 'HASH' || ref $data{$tlv->{'name'}} eq 'ARRAY'
ref $data{$tlv->{'name'}} eq 'HASH' ref $data{$tlv->{'name'}} eq 'ARRAY'
Truth table0%0/3
A || B
A= ref $data{$tlv->{'name'}} eq 'HASH'B= ref $data{$tlv->{'name'}} eq 'ARRAY'
ABresult
1X1
011
000
413 0 ▶ if(ref($data{$tlv->{name}}) eq "ARRAY") {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $data{$tlv->{'name'}} eq 'ARRAY') { } 0 0 0
414 0 $tlvdata = [];
415 0 push @$tlvdata, $self->new($tlv->{items})->pack(%$_) foreach @{$data{$tlv->{name}}};
416 } else {
417 0 $tlvdata = [$self->new($tlv->{items})->pack(%{$data{$tlv->{name}}})];
418 }
419 } else {
420 0 ▶ $tlvdata = [""] if defined($data{$tlv->{name}});
Branch: 1 branch
BranchTrueFalseTotal
if defined $data{$tlv->{"name"}} 0 0 0
421 }
422 0 ▶ } elsif(exists($tlv->{value}) and !@{$tlv->{items}}) {
Condition0%0/3
exists $tlv->{"value"} and not @{$tlv->{"items"};}
!ll&&!rl&&r
000
MC/DC0%0/2
exists $tlv->{"value"} and not @{$tlv->{"items"};}
exists $tlv->{"value"} not @{$tlv->{"items"};}
Truth table0%0/3
A and not(B)
A= exists $tlv->{"value"}B= not @{$tlv->{"items"};}
ABresult
0X0
100
111
423 0 $tlvdata = [$tlv->{value}];
424 }
425 } else {
426 0 my $tmp = $self->new($tlv->{items})->pack(%data);
427  
428 # If TLV has no name and only one element, do special handling for "present but empty" value.
429 0 ▶ if($tmp ne "") {
Branch: 3 branches
BranchTrueFalseTotal
if ($tmp ne '') { } 0 0 0
elsif (@{$tlv->{'items'};} == 1 and $tlv->{'items'}[0]{'name'} and exists $data{$tlv->{'items'}[0]{'name'}}) { } 0 0 0
elsif (not @{$tlv->{'items'};} and exists $tlv->{'value'}) { } 0 0 0
430 0 $tlvdata = [$tmp];
431 0 ▶ } elsif(@{$tlv->{items}} == 1 and $tlv->{items}->[0]->{name} and exists($data{$tlv->{items}->[0]->{name}})) {
Condition0%0/6
@{$tlv->{"items"};} == 1 and $tlv->{"items"}[0]{"name"} and exists $data{$tlv->{"items"}[0]{"name"}}
!ll&&!rl&&r
000
@{$tlv->{"items"};} == 1 and $tlv->{"items"}[0]{"name"}
!ll&&!rl&&r
000
MC/DC0%0/3
@{$tlv->{"items"};} == 1 and $tlv->{"items"}[0]{"name"} and exists $data{$tlv->{"items"}[0]{"name"}}
@{$tlv->{"items"};} == 1 $tlv->{"items"}[0]{"name"} exists $data{$tlv->{"items"}[0]{"name"}}
Truth table0%0/4
A and B and C
A= @{$tlv->{"items"};} == 1B= $tlv->{"items"}[0]{"name"}C= exists $data{$tlv->{"items"}[0]{"name"}}
ABCresult
0XX0
10X0
1100
1111
432 0 $tlvdata = [""];
433 0 ▶ } elsif(!@{$tlv->{items}} and exists($tlv->{value})) {
Condition0%0/3
not @{$tlv->{"items"};} and exists $tlv->{"value"}
!ll&&!rl&&r
000
MC/DC0%0/2
not @{$tlv->{"items"};} and exists $tlv->{"value"}
not @{$tlv->{"items"};} exists $tlv->{"value"}
Truth table0%0/3
not(A) and B
A= not @{$tlv->{"items"};}B= exists $tlv->{"value"}
ABresult
0X0
100
111
434 0 $tlvdata = [$tlv->{value}];
435 }
436 }
437
438 0 assert($tlv->{num});
439 0 ▶ next unless defined($tlvdata);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $tlvdata 0 0 0
440  
441 0 $count++;
442 0 ▶ if($datum->{subtyped}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($datum->{'subtyped'}) { } 0 0 0
443 0 my $subtype = 0;
444 0 assert(exists($tlv->{subtype}));
445 0 ▶ $subtype = $tlv->{subtype} if $tlv->{subtype} != -1;
Branch: 1 branch
BranchTrueFalseTotal
if $tlv->{"subtype"} != -1 0 0 0
446  
447 $output .= protoparse($oscar, "subtyped_TLV")->pack(
448 type => $tlv->{num},
449 subtype => $subtype,
450 data => $_
451 0 ) foreach @$tlvdata;
452 } else {
453 $output .= protoparse($oscar, "TLV")->pack(
454 type => $tlv->{num},
455 data => $_
456 0 ) foreach @$tlvdata;
457 }
458 }
459 }
460  
461  
462 ## Handle any prefixes
463 0 ▶ if($datum->{prefix} and defined($output)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($datum->{"prefix"} and defined $output) 0 0 0
Condition0%0/3
$datum->{"prefix"} and defined $output
!ll&&!rl&&r
000
MC/DC0%0/2
$datum->{"prefix"} and defined $output
$datum->{"prefix"} defined $output
Truth table0%0/3
A and B
A= $datum->{"prefix"}B= defined $output
ABresult
0X0
100
111
464 0 ▶ if($datum->{prefix} eq "count") {
Branch: 1 branch
BranchTrueFalseTotal
if ($datum->{'prefix'} eq 'count') { } 0 0 0
465 0 $packet .= pack($datum->{prefix_packlet}, $count);
466 } else {
467 0 $packet .= pack($datum->{prefix_packlet}, length($output));
468 }
469 }
470  
471 0 ▶ $packet .= $output if defined($output);
Branch: 1 branch
BranchTrueFalseTotal
if defined $output 0 0 0
472 }
473  
474 0 ▶ $oscar->log_print_cond(OSCAR_DBG_XML, sub { "Encoded:\n", hexdump($packet) });
Subroutine __ANON__: not called CC=1 SCAR=6.9
475 0 return $packet;
476 }
477  
478  
479 0 ▶sub assert($) {
Subroutine assert: not called CC=2 SCAR=17.9
Pod undocumented
480 0 my $test = shift;
481 0 ▶ return if $test;
Branch: 1 branch
BranchTrueFalseTotal
if $test 0 0 0
482 0 confess("Net::OSCAR internal error");
483 }
484  
485 # Why isn't this imported properly??
486 0 ▶sub protoparse { Net::OSCAR::XML::protoparse(@_); }
Subroutine protoparse: not called CC=1 SCAR=6.9
Pod undocumented
487  
488 5 1;
↑ Summary blib/lib/Net/OSCAR/Connection/Direct.pm »