lib/SMB/v2/Command/Write.pm

filter: Statementstmt 32.5% 13 / 40 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 4 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 57.1% 4 / 7 Podpod 0.0% 0 / 3 totaltotal 28.3% 17 / 60 SCAR 26.9
CC
5
Cov
27%
pack
20.0
parse
6.0
init
2.0
CRAP 14.7
« lib/SMB/v2/Command/Read.pm ↑ Summary lib/SMB/v2/Command.pm »
1 # SMB Perl library, Copyright (C) 2014 Mikhael Goikhman, migo@cpan.org
2 #
3 # This program is free software: you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation, either version 3 of the License, or
6 # (at your option) any later version.
7 #
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
12 #
13 # You should have received a copy of the GNU General Public License
14 # along with this program. If not, see <http://www.gnu.org/licenses/>.
15  
16 package SMB::v2::Command::Write;
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 parent 'SMB::v2::Command';
Subroutine BEGIN: called CC=1 SCAR=0.0
22  
23 use constant {
24 1 FLAGS_WRITE_THROUGH => 1, # SMB 3.*
25 FLAGS_WRITE_UNBUFFERED => 2, # SMB 3.02
26  
27 CHANNEL_NONE => 0,
28 CHANNEL_RDMA_V1 => 1, # SMB 3.*
29 CHANNEL_RDMA_V1_INVALIDATE => 2, # SMB 3.02
30 1 ▶};
Subroutine BEGIN: called CC=1 SCAR=0.0
31  
32 sub init ($) {
33 0 ▶ $_[0]->set(
Subroutine init: not called CC=1 SCAR=6.9
Pod undocumented
34 flags => 0,
35 offset => 0,
36 length => 0,
37 channel => 0,
38 remaining_bytes => 0,
39 fid => 0,
40 openfile => undef,
41 buffer => undef,
42 )
43 }
44  
45 sub parse ($$) {
46 0 ▶ my $self = shift;
Subroutine parse: not called CC=2 SCAR=17.9
Pod undocumented
47 0 my $parser = shift;
48  
49 0 ▶ if ($self->is_response) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->is_response) { } 0 0 0
50 0 $parser->uint16; # reserved
51 0 $self->length($parser->uint32);
52 0 $self->remaining_bytes($parser->uint32);
53 0 $parser->uint16; # channel info offset
54 0 $parser->uint16; # channel info length
55 } else {
56 0 my $offset = $parser->uint16;
57 0 my $length = $parser->uint32;
58 0 $self->length($length);
59 0 $self->offset($parser->uint64);
60 0 $self->fid($parser->fid2);
61 0 $self->channel($parser->uint32);
62 0 $self->remaining_bytes($parser->uint32);
63 0 $parser->uint16; # channel info offset
64 0 $parser->uint16; # channel info length
65 0 $self->flags($parser->uint32);
66 0 $self->buffer($parser->bytes($length));
67 }
68  
69 0 return $self;
70 }
71  
72 sub pack ($$) {
73 0 ▶ my $self = shift;
Subroutine pack: not called CC=4 SCAR=30.0
Pod undocumented
74 0 my $packer = shift;
75  
76 0 ▶ if ($self->is_response) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->is_response) { } 0 0 0
77 0 $packer
78 ->uint16(0) # reserved
79 ->uint32($self->length)
80 ->uint32($self->remaining_bytes)
81 ->uint16(0) # channel info offset
82 ->uint16(0) # channel info length
83 ;
84 } else {
85 0 ▶ my $buffer = $self->buffer // die "No buffer";
Condition0%0/2
$self->buffer // die("No buffer")
l!l
00
MC/DC0%0/1
$self->buffer // die("No buffer")
$self->buffer
Truth table0%0/2
A
A= $self->buffer
Aresult
11
00
86  
87 0 ▶ $packer
Condition0%0/2
$self->fid || die('No fid set')
l!l
00
MC/DC0%0/1
$self->fid || die('No fid set')
$self->fid
Truth table0%0/2
A
A= $self->fid
Aresult
11
00
88 ->stub('data-offset', 'uint16')
89 ->uint32(length($buffer))
90 ->uint64($self->offset)
91 ->fid2($self->fid || die "No fid set")
92 ->uint32($self->channel)
93 ->uint32($self->remaining_bytes)
94 ->uint16(0) # channel info offset
95 ->uint16(0) # channel info length
96 ->uint32($self->flags)
97 ->fill('data-offset', $packer->diff('smb-header'))
98 ->bytes($self->buffer)
99 ;
100 }
101 }
102  
103 1 1;
« lib/SMB/v2/Command/Read.pm ↑ Summary lib/SMB/v2/Command.pm »