line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
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 . |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
package SMB::v2::Command::Write; |
17
|
|
|
|
|
|
|
|
18
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
27
|
|
19
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
22
|
|
20
|
|
|
|
|
|
|
|
21
|
1
|
|
|
1
|
|
4
|
use parent 'SMB::v2::Command'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
use constant { |
24
|
1
|
|
|
|
|
435
|
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
|
|
|
1
|
|
60
|
}; |
|
1
|
|
|
|
|
99
|
|
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub init ($) { |
33
|
0
|
|
|
0
|
0
|
|
$_[0]->set( |
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
|
|
|
0
|
0
|
|
my $self = shift; |
47
|
0
|
|
|
|
|
|
my $parser = shift; |
48
|
|
|
|
|
|
|
|
49
|
0
|
0
|
|
|
|
|
if ($self->is_response) { |
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
|
|
|
0
|
0
|
|
my $self = shift; |
74
|
0
|
|
|
|
|
|
my $packer = shift; |
75
|
|
|
|
|
|
|
|
76
|
0
|
0
|
|
|
|
|
if ($self->is_response) { |
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
|
|
0
|
|
|
|
my $buffer = $self->buffer // die "No buffer"; |
86
|
|
|
|
|
|
|
|
87
|
0
|
|
0
|
|
|
|
$packer |
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; |