idl: rebuild drsuapi.idl
[Samba/aatanasov.git] / source4 / smb_server / smb2 / fileio.c
blob12bfd5175685548111da457abc3794d0cde79ca3
1 /*
2 Unix SMB2 implementation.
4 Copyright (C) Stefan Metzmacher 2005
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
20 #include "includes.h"
21 #include "libcli/smb2/smb2.h"
22 #include "libcli/smb2/smb2_calls.h"
23 #include "smb_server/smb_server.h"
24 #include "smb_server/service_smb_proto.h"
25 #include "smb_server/smb2/smb2_server.h"
26 #include "ntvfs/ntvfs.h"
27 #include "libcli/raw/libcliraw.h"
28 #include "libcli/raw/raw_proto.h"
29 #include "librpc/gen_ndr/ndr_security.h"
31 static void smb2srv_create_send(struct ntvfs_request *ntvfs)
33 struct smb2srv_request *req;
34 union smb_open *io;
35 DATA_BLOB blob;
37 SMB2SRV_CHECK_ASYNC_STATUS(io, union smb_open);
39 /* setup the blobs we should give in the reply */
40 if (io->smb2.out.maximal_access != 0) {
41 uint32_t data[2];
42 SIVAL(data, 0, 0);
43 SIVAL(data, 4, io->smb2.out.maximal_access);
44 SMB2SRV_CHECK(smb2_create_blob_add(req, &io->smb2.out.blobs,
45 SMB2_CREATE_TAG_MXAC,
46 data_blob_const(data, 8)));
50 SMB2SRV_CHECK(smb2_create_blob_push(req, &blob, io->smb2.out.blobs));
51 SMB2SRV_CHECK(smb2srv_setup_reply(req, 0x58, true, blob.length));
53 SCVAL(req->out.body, 0x02, io->smb2.out.oplock_level);
54 SCVAL(req->out.body, 0x03, io->smb2.out.reserved);
55 SIVAL(req->out.body, 0x04, io->smb2.out.create_action);
56 SBVAL(req->out.body, 0x08, io->smb2.out.create_time);
57 SBVAL(req->out.body, 0x10, io->smb2.out.access_time);
58 SBVAL(req->out.body, 0x18, io->smb2.out.write_time);
59 SBVAL(req->out.body, 0x20, io->smb2.out.change_time);
60 SBVAL(req->out.body, 0x28, io->smb2.out.alloc_size);
61 SBVAL(req->out.body, 0x30, io->smb2.out.size);
62 SIVAL(req->out.body, 0x38, io->smb2.out.file_attr);
63 SIVAL(req->out.body, 0x3C, io->smb2.out.reserved2);
64 smb2srv_push_handle(req->out.body, 0x40, io->smb2.out.file.ntvfs);
65 SMB2SRV_CHECK(smb2_push_o32s32_blob(&req->out, 0x50, blob));
67 /* also setup the chained file handle */
68 req->chained_file_handle = req->_chained_file_handle;
69 smb2srv_push_handle(req->chained_file_handle, 0, io->smb2.out.file.ntvfs);
71 smb2srv_send_reply(req);
74 void smb2srv_create_recv(struct smb2srv_request *req)
76 union smb_open *io;
77 DATA_BLOB blob;
78 int i;
80 SMB2SRV_CHECK_BODY_SIZE(req, 0x38, true);
81 SMB2SRV_TALLOC_IO_PTR(io, union smb_open);
82 SMB2SRV_SETUP_NTVFS_REQUEST(smb2srv_create_send, NTVFS_ASYNC_STATE_MAY_ASYNC);
84 ZERO_STRUCT(io->smb2.in);
85 io->smb2.level = RAW_OPEN_SMB2;
86 io->smb2.in.security_flags = CVAL(req->in.body, 0x02);
87 io->smb2.in.oplock_level = CVAL(req->in.body, 0x03);
88 io->smb2.in.impersonation_level = IVAL(req->in.body, 0x04);
89 io->smb2.in.create_flags = BVAL(req->in.body, 0x08);
90 io->smb2.in.reserved = BVAL(req->in.body, 0x10);
91 io->smb2.in.desired_access = IVAL(req->in.body, 0x18);
92 io->smb2.in.file_attributes = IVAL(req->in.body, 0x1C);
93 io->smb2.in.share_access = IVAL(req->in.body, 0x20);
94 io->smb2.in.create_disposition = IVAL(req->in.body, 0x24);
95 io->smb2.in.create_options = IVAL(req->in.body, 0x28);
96 SMB2SRV_CHECK(smb2_pull_o16s16_string(&req->in, io, req->in.body+0x2C, &io->smb2.in.fname));
97 SMB2SRV_CHECK(smb2_pull_o32s32_blob(&req->in, io, req->in.body+0x30, &blob));
98 SMB2SRV_CHECK(smb2_create_blob_parse(io, blob, &io->smb2.in.blobs));
100 /* interpret the parsed tags that a server needs to respond to */
101 for (i=0;i<io->smb2.in.blobs.num_blobs;i++) {
102 if (strcmp(io->smb2.in.blobs.blobs[i].tag, SMB2_CREATE_TAG_EXTA) == 0) {
103 SMB2SRV_CHECK(ea_pull_list_chained(&io->smb2.in.blobs.blobs[i].data, io,
104 &io->smb2.in.eas.num_eas,
105 &io->smb2.in.eas.eas));
107 if (strcmp(io->smb2.in.blobs.blobs[i].tag, SMB2_CREATE_TAG_SECD) == 0) {
108 enum ndr_err_code ndr_err;
109 io->smb2.in.sec_desc = talloc(io, struct security_descriptor);
110 if (io->smb2.in.sec_desc == NULL) {
111 smb2srv_send_error(req, NT_STATUS_NO_MEMORY);
112 return;
114 ndr_err = ndr_pull_struct_blob(&io->smb2.in.blobs.blobs[i].data, io, NULL,
115 io->smb2.in.sec_desc,
116 (ndr_pull_flags_fn_t)ndr_pull_security_descriptor);
117 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
118 smb2srv_send_error(req, ndr_map_error2ntstatus(ndr_err));
119 return;
122 if (strcmp(io->smb2.in.blobs.blobs[i].tag, SMB2_CREATE_TAG_DHNQ) == 0) {
123 io->smb2.in.durable_open = true;
125 if (strcmp(io->smb2.in.blobs.blobs[i].tag, SMB2_CREATE_TAG_DHNC) == 0) {
126 if (io->smb2.in.blobs.blobs[i].data.length != 16) {
127 smb2srv_send_error(req, NT_STATUS_INVALID_PARAMETER);
128 return;
130 io->smb2.in.durable_handle = talloc(io, struct smb2_handle);
131 if (io->smb2.in.durable_handle == NULL) {
132 smb2srv_send_error(req, NT_STATUS_NO_MEMORY);
133 return;
135 smb2_pull_handle(io->smb2.in.blobs.blobs[i].data.data, io->smb2.in.durable_handle);
137 if (strcmp(io->smb2.in.blobs.blobs[i].tag, SMB2_CREATE_TAG_ALSI) == 0) {
138 if (io->smb2.in.blobs.blobs[i].data.length != 8) {
139 smb2srv_send_error(req, NT_STATUS_INVALID_PARAMETER);
140 return;
142 io->smb2.in.alloc_size = BVAL(io->smb2.in.blobs.blobs[i].data.data, 0);
144 if (strcmp(io->smb2.in.blobs.blobs[i].tag, SMB2_CREATE_TAG_MXAC) == 0) {
145 io->smb2.in.query_maximal_access = true;
147 if (strcmp(io->smb2.in.blobs.blobs[i].tag, SMB2_CREATE_TAG_TWRP) == 0) {
148 if (io->smb2.in.blobs.blobs[i].data.length != 8) {
149 smb2srv_send_error(req, NT_STATUS_INVALID_PARAMETER);
150 return;
152 io->smb2.in.timewarp = BVAL(io->smb2.in.blobs.blobs[i].data.data, 0);
154 if (strcmp(io->smb2.in.blobs.blobs[i].tag, SMB2_CREATE_TAG_QFID) == 0) {
155 io->smb2.in.query_on_disk_id = true;
159 /* the VFS backend does not yet handle NULL filenames */
160 if (io->smb2.in.fname == NULL) {
161 io->smb2.in.fname = "";
164 SMB2SRV_CALL_NTVFS_BACKEND(ntvfs_open(req->ntvfs, io));
167 static void smb2srv_close_send(struct ntvfs_request *ntvfs)
169 struct smb2srv_request *req;
170 union smb_close *io;
172 SMB2SRV_CHECK_ASYNC_STATUS(io, union smb_close);
173 SMB2SRV_CHECK(smb2srv_setup_reply(req, 0x3C, false, 0));
175 SSVAL(req->out.body, 0x02, io->smb2.out.flags);
176 SIVAL(req->out.body, 0x04, io->smb2.out._pad);
177 SBVAL(req->out.body, 0x08, io->smb2.out.create_time);
178 SBVAL(req->out.body, 0x10, io->smb2.out.access_time);
179 SBVAL(req->out.body, 0x18, io->smb2.out.write_time);
180 SBVAL(req->out.body, 0x20, io->smb2.out.change_time);
181 SBVAL(req->out.body, 0x28, io->smb2.out.alloc_size);
182 SBVAL(req->out.body, 0x30, io->smb2.out.size);
183 SIVAL(req->out.body, 0x38, io->smb2.out.file_attr);
185 /* also destroy the chained file handle */
186 req->chained_file_handle = NULL;
187 memset(req->_chained_file_handle, 0, sizeof(req->_chained_file_handle));
189 smb2srv_send_reply(req);
192 void smb2srv_close_recv(struct smb2srv_request *req)
194 union smb_close *io;
196 SMB2SRV_CHECK_BODY_SIZE(req, 0x18, false);
197 SMB2SRV_TALLOC_IO_PTR(io, union smb_close);
198 SMB2SRV_SETUP_NTVFS_REQUEST(smb2srv_close_send, NTVFS_ASYNC_STATE_MAY_ASYNC);
200 io->smb2.level = RAW_CLOSE_SMB2;
201 io->smb2.in.flags = SVAL(req->in.body, 0x02);
202 io->smb2.in._pad = IVAL(req->in.body, 0x04);
203 io->smb2.in.file.ntvfs = smb2srv_pull_handle(req, req->in.body, 0x08);
205 SMB2SRV_CHECK_FILE_HANDLE(io->smb2.in.file.ntvfs);
206 SMB2SRV_CALL_NTVFS_BACKEND(ntvfs_close(req->ntvfs, io));
209 static void smb2srv_flush_send(struct ntvfs_request *ntvfs)
211 struct smb2srv_request *req;
212 union smb_flush *io;
214 SMB2SRV_CHECK_ASYNC_STATUS(io, union smb_flush);
215 SMB2SRV_CHECK(smb2srv_setup_reply(req, 0x04, false, 0));
217 SSVAL(req->out.body, 0x02, io->smb2.out.reserved);
219 smb2srv_send_reply(req);
222 void smb2srv_flush_recv(struct smb2srv_request *req)
224 union smb_flush *io;
226 SMB2SRV_CHECK_BODY_SIZE(req, 0x18, false);
227 SMB2SRV_TALLOC_IO_PTR(io, union smb_flush);
228 SMB2SRV_SETUP_NTVFS_REQUEST(smb2srv_flush_send, NTVFS_ASYNC_STATE_MAY_ASYNC);
230 io->smb2.level = RAW_FLUSH_SMB2;
231 io->smb2.in.reserved1 = SVAL(req->in.body, 0x02);
232 io->smb2.in.reserved2 = IVAL(req->in.body, 0x04);
233 io->smb2.in.file.ntvfs = smb2srv_pull_handle(req, req->in.body, 0x08);
235 SMB2SRV_CHECK_FILE_HANDLE(io->smb2.in.file.ntvfs);
236 SMB2SRV_CALL_NTVFS_BACKEND(ntvfs_flush(req->ntvfs, io));
239 static void smb2srv_read_send(struct ntvfs_request *ntvfs)
241 struct smb2srv_request *req;
242 union smb_read *io;
244 SMB2SRV_CHECK_ASYNC_STATUS(io, union smb_read);
245 SMB2SRV_CHECK(smb2srv_setup_reply(req, 0x10, true, io->smb2.out.data.length));
247 /* TODO: avoid the memcpy */
248 SMB2SRV_CHECK(smb2_push_o16s32_blob(&req->out, 0x02, io->smb2.out.data));
249 SIVAL(req->out.body, 0x08, io->smb2.out.remaining);
250 SIVAL(req->out.body, 0x0C, io->smb2.out.reserved);
252 smb2srv_send_reply(req);
255 void smb2srv_read_recv(struct smb2srv_request *req)
257 union smb_read *io;
259 SMB2SRV_CHECK_BODY_SIZE(req, 0x30, true);
261 /* MS-SMB2 2.2.19 read must have a single byte of zero */
262 if (req->in.body_size - req->in.body_fixed < 1) {
263 smb2srv_send_error(req, NT_STATUS_INVALID_PARAMETER);
264 return;
266 SMB2SRV_TALLOC_IO_PTR(io, union smb_read);
267 SMB2SRV_SETUP_NTVFS_REQUEST(smb2srv_read_send, NTVFS_ASYNC_STATE_MAY_ASYNC);
269 io->smb2.level = RAW_READ_SMB2;
270 io->smb2.in._pad = SVAL(req->in.body, 0x02);
271 io->smb2.in.length = IVAL(req->in.body, 0x04);
272 io->smb2.in.offset = BVAL(req->in.body, 0x08);
273 io->smb2.in.file.ntvfs = smb2srv_pull_handle(req, req->in.body, 0x10);
274 io->smb2.in.min_count = IVAL(req->in.body, 0x20);
275 io->smb2.in.channel = IVAL(req->in.body, 0x24);
276 io->smb2.in.remaining = IVAL(req->in.body, 0x28);
277 io->smb2.in.channel_offset = SVAL(req->in.body, 0x2C);
278 io->smb2.in.channel_length = SVAL(req->in.body, 0x2E);
280 SMB2SRV_CHECK_FILE_HANDLE(io->smb2.in.file.ntvfs);
282 /* preallocate the buffer for the backends */
283 io->smb2.out.data = data_blob_talloc(io, NULL, io->smb2.in.length);
284 if (io->smb2.out.data.length != io->smb2.in.length) {
285 SMB2SRV_CHECK(NT_STATUS_NO_MEMORY);
288 SMB2SRV_CALL_NTVFS_BACKEND(ntvfs_read(req->ntvfs, io));
291 static void smb2srv_write_send(struct ntvfs_request *ntvfs)
293 struct smb2srv_request *req;
294 union smb_write *io;
296 SMB2SRV_CHECK_ASYNC_STATUS(io, union smb_write);
297 SMB2SRV_CHECK(smb2srv_setup_reply(req, 0x10, true, 0));
299 SSVAL(req->out.body, 0x02, io->smb2.out._pad);
300 SIVAL(req->out.body, 0x04, io->smb2.out.nwritten);
301 SBVAL(req->out.body, 0x08, io->smb2.out.unknown1);
303 smb2srv_send_reply(req);
306 void smb2srv_write_recv(struct smb2srv_request *req)
308 union smb_write *io;
310 SMB2SRV_CHECK_BODY_SIZE(req, 0x30, true);
311 SMB2SRV_TALLOC_IO_PTR(io, union smb_write);
312 SMB2SRV_SETUP_NTVFS_REQUEST(smb2srv_write_send, NTVFS_ASYNC_STATE_MAY_ASYNC);
314 /* TODO: avoid the memcpy */
315 io->smb2.level = RAW_WRITE_SMB2;
316 SMB2SRV_CHECK(smb2_pull_o16s32_blob(&req->in, io, req->in.body+0x02, &io->smb2.in.data));
317 io->smb2.in.offset = BVAL(req->in.body, 0x08);
318 io->smb2.in.file.ntvfs = smb2srv_pull_handle(req, req->in.body, 0x10);
319 io->smb2.in.unknown1 = BVAL(req->in.body, 0x20);
320 io->smb2.in.unknown2 = BVAL(req->in.body, 0x28);
322 SMB2SRV_CHECK_FILE_HANDLE(io->smb2.in.file.ntvfs);
323 SMB2SRV_CALL_NTVFS_BACKEND(ntvfs_write(req->ntvfs, io));
326 static void smb2srv_lock_send(struct ntvfs_request *ntvfs)
328 struct smb2srv_request *req;
329 union smb_lock *io;
331 SMB2SRV_CHECK_ASYNC_STATUS_ERR(io, union smb_lock);
332 SMB2SRV_CHECK(smb2srv_setup_reply(req, 0x04, false, 0));
334 SSVAL(req->out.body, 0x02, io->smb2.out.reserved);
336 smb2srv_send_reply(req);
339 void smb2srv_lock_recv(struct smb2srv_request *req)
341 union smb_lock *io;
342 int i;
344 SMB2SRV_CHECK_BODY_SIZE(req, 0x30, false);
345 SMB2SRV_TALLOC_IO_PTR(io, union smb_lock);
346 SMB2SRV_SETUP_NTVFS_REQUEST(smb2srv_lock_send, NTVFS_ASYNC_STATE_MAY_ASYNC);
348 io->smb2.level = RAW_LOCK_SMB2;
349 io->smb2.in.lock_count = SVAL(req->in.body, 0x02);
350 io->smb2.in.reserved = IVAL(req->in.body, 0x04);
351 io->smb2.in.file.ntvfs = smb2srv_pull_handle(req, req->in.body, 0x08);
352 if (req->in.body_size < 24 + 24*(uint64_t)io->smb2.in.lock_count) {
353 DEBUG(0,("%s: lock buffer too small\n", __location__));
354 smb2srv_send_error(req, NT_STATUS_FOOBAR);
355 return;
357 io->smb2.in.locks = talloc_array(io, struct smb2_lock_element,
358 io->smb2.in.lock_count);
359 if (io->smb2.in.locks == NULL) {
360 smb2srv_send_error(req, NT_STATUS_NO_MEMORY);
361 return;
364 for (i=0;i<io->smb2.in.lock_count;i++) {
365 io->smb2.in.locks[i].offset = BVAL(req->in.body, 24 + i*24);
366 io->smb2.in.locks[i].length = BVAL(req->in.body, 32 + i*24);
367 io->smb2.in.locks[i].flags = IVAL(req->in.body, 40 + i*24);
368 io->smb2.in.locks[i].reserved = IVAL(req->in.body, 44 + i*24);
371 SMB2SRV_CHECK_FILE_HANDLE(io->smb2.in.file.ntvfs);
372 SMB2SRV_CALL_NTVFS_BACKEND(ntvfs_lock(req->ntvfs, io));
375 static void smb2srv_ioctl_send(struct ntvfs_request *ntvfs)
377 struct smb2srv_request *req;
378 union smb_ioctl *io;
380 SMB2SRV_CHECK_ASYNC_STATUS_ERR(io, union smb_ioctl);
381 SMB2SRV_CHECK(smb2srv_setup_reply(req, 0x30, true, 0));
383 SSVAL(req->out.body, 0x02, io->smb2.out._pad);
384 SIVAL(req->out.body, 0x04, io->smb2.out.function);
385 if (io->smb2.level == RAW_IOCTL_SMB2_NO_HANDLE) {
386 struct smb2_handle h;
387 h.data[0] = UINT64_MAX;
388 h.data[1] = UINT64_MAX;
389 smb2_push_handle(req->out.body + 0x08, &h);
390 } else {
391 smb2srv_push_handle(req->out.body, 0x08,io->smb2.in.file.ntvfs);
393 SMB2SRV_CHECK(smb2_push_o32s32_blob(&req->out, 0x18, io->smb2.out.in));
394 SMB2SRV_CHECK(smb2_push_o32s32_blob(&req->out, 0x20, io->smb2.out.out));
395 SIVAL(req->out.body, 0x28, io->smb2.out.unknown2);
396 SIVAL(req->out.body, 0x2C, io->smb2.out.unknown3);
398 smb2srv_send_reply(req);
401 void smb2srv_ioctl_recv(struct smb2srv_request *req)
403 union smb_ioctl *io;
404 struct smb2_handle h;
406 SMB2SRV_CHECK_BODY_SIZE(req, 0x38, true);
407 SMB2SRV_TALLOC_IO_PTR(io, union smb_ioctl);
408 SMB2SRV_SETUP_NTVFS_REQUEST(smb2srv_ioctl_send, NTVFS_ASYNC_STATE_MAY_ASYNC);
410 /* TODO: avoid the memcpy */
411 io->smb2.in._pad = SVAL(req->in.body, 0x02);
412 io->smb2.in.function = IVAL(req->in.body, 0x04);
413 /* file handle ... */
414 SMB2SRV_CHECK(smb2_pull_o32s32_blob(&req->in, io, req->in.body+0x18, &io->smb2.in.out));
415 io->smb2.in.unknown2 = IVAL(req->in.body, 0x20);
416 SMB2SRV_CHECK(smb2_pull_o32s32_blob(&req->in, io, req->in.body+0x24, &io->smb2.in.in));
417 io->smb2.in.max_response_size = IVAL(req->in.body, 0x2C);
418 io->smb2.in.flags = BVAL(req->in.body, 0x30);
420 smb2_pull_handle(req->in.body + 0x08, &h);
421 if (h.data[0] == UINT64_MAX && h.data[1] == UINT64_MAX) {
422 io->smb2.level = RAW_IOCTL_SMB2_NO_HANDLE;
423 } else {
424 io->smb2.level = RAW_IOCTL_SMB2;
425 io->smb2.in.file.ntvfs = smb2srv_pull_handle(req, req->in.body, 0x08);
426 SMB2SRV_CHECK_FILE_HANDLE(io->smb2.in.file.ntvfs);
429 SMB2SRV_CALL_NTVFS_BACKEND(ntvfs_ioctl(req->ntvfs, io));
432 static void smb2srv_notify_send(struct ntvfs_request *ntvfs)
434 struct smb2srv_request *req;
435 union smb_notify *io;
436 size_t size = 0;
437 int i;
438 uint8_t *p;
439 DATA_BLOB blob = data_blob(NULL, 0);
441 SMB2SRV_CHECK_ASYNC_STATUS(io, union smb_notify);
442 SMB2SRV_CHECK(smb2srv_setup_reply(req, 0x08, true, 0));
444 #define MAX_BYTES_PER_CHAR 3
446 /* work out how big the reply buffer could be */
447 for (i=0;i<io->smb2.out.num_changes;i++) {
448 size += 12 + 3 + (1+strlen(io->smb2.out.changes[i].name.s)) * MAX_BYTES_PER_CHAR;
451 blob = data_blob_talloc(req, NULL, size);
452 if (size > 0 && !blob.data) {
453 SMB2SRV_CHECK(NT_STATUS_NO_MEMORY);
456 p = blob.data;
458 /* construct the changes buffer */
459 for (i=0;i<io->smb2.out.num_changes;i++) {
460 uint32_t ofs;
461 ssize_t len;
463 SIVAL(p, 4, io->smb2.out.changes[i].action);
464 len = push_string(p + 12, io->smb2.out.changes[i].name.s,
465 blob.length - (p+12 - blob.data), STR_UNICODE);
466 SIVAL(p, 8, len);
468 ofs = len + 12;
470 if (ofs & 3) {
471 int pad = 4 - (ofs & 3);
472 memset(p+ofs, 0, pad);
473 ofs += pad;
476 if (i == io->smb2.out.num_changes-1) {
477 SIVAL(p, 0, 0);
478 } else {
479 SIVAL(p, 0, ofs);
482 p += ofs;
485 blob.length = p - blob.data;
487 SMB2SRV_CHECK(smb2_push_o16s32_blob(&req->out, 0x02, blob));
489 smb2srv_send_reply(req);
492 void smb2srv_notify_recv(struct smb2srv_request *req)
494 union smb_notify *io;
496 SMB2SRV_CHECK_BODY_SIZE(req, 0x20, false);
497 SMB2SRV_TALLOC_IO_PTR(io, union smb_notify);
498 SMB2SRV_SETUP_NTVFS_REQUEST(smb2srv_notify_send, NTVFS_ASYNC_STATE_MAY_ASYNC);
500 io->smb2.level = RAW_NOTIFY_SMB2;
501 io->smb2.in.recursive = SVAL(req->in.body, 0x02);
502 io->smb2.in.buffer_size = IVAL(req->in.body, 0x04);
503 io->smb2.in.file.ntvfs = smb2srv_pull_handle(req, req->in.body, 0x08);
504 io->smb2.in.completion_filter = IVAL(req->in.body, 0x18);
505 io->smb2.in.unknown = BVAL(req->in.body, 0x1C);
507 SMB2SRV_CHECK_FILE_HANDLE(io->smb2.in.file.ntvfs);
508 SMB2SRV_CALL_NTVFS_BACKEND(ntvfs_notify(req->ntvfs, io));
511 static void smb2srv_break_send(struct ntvfs_request *ntvfs)
513 struct smb2srv_request *req;
514 union smb_lock *io;
516 SMB2SRV_CHECK_ASYNC_STATUS_ERR(io, union smb_lock);
517 SMB2SRV_CHECK(smb2srv_setup_reply(req, 0x18, false, 0));
519 SCVAL(req->out.body, 0x02, io->smb2_break.out.oplock_level);
520 SCVAL(req->out.body, 0x03, io->smb2_break.out.reserved);
521 SIVAL(req->out.body, 0x04, io->smb2_break.out.reserved2);
522 smb2srv_push_handle(req->out.body, 0x08,io->smb2_break.out.file.ntvfs);
524 smb2srv_send_reply(req);
527 void smb2srv_break_recv(struct smb2srv_request *req)
529 union smb_lock *io;
531 SMB2SRV_CHECK_BODY_SIZE(req, 0x18, false);
532 SMB2SRV_TALLOC_IO_PTR(io, union smb_lock);
533 SMB2SRV_SETUP_NTVFS_REQUEST(smb2srv_break_send, NTVFS_ASYNC_STATE_MAY_ASYNC);
535 io->smb2_break.level = RAW_LOCK_SMB2_BREAK;
536 io->smb2_break.in.oplock_level = CVAL(req->in.body, 0x02);
537 io->smb2_break.in.reserved = CVAL(req->in.body, 0x03);
538 io->smb2_break.in.reserved2 = IVAL(req->in.body, 0x04);
539 io->smb2_break.in.file.ntvfs = smb2srv_pull_handle(req, req->in.body, 0x08);
541 SMB2SRV_CHECK_FILE_HANDLE(io->smb2_break.in.file.ntvfs);
542 SMB2SRV_CALL_NTVFS_BACKEND(ntvfs_lock(req->ntvfs, io));