1/* 2 Unix SMB/CIFS implementation. 3 4 SMB2 client oplock break handling 5 6 Copyright (C) Zachary Loafman 2009 7 8 This program is free software; you can redistribute it and/or modify 9 it under the terms of the GNU General Public License as published by 10 the Free Software Foundation; either version 3 of the License, or 11 (at your option) any later version. 12 13 This program is distributed in the hope that it will be useful, 14 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 GNU General Public License for more details. 17 18 You should have received a copy of the GNU General Public License 19 along with this program. If not, see <http://www.gnu.org/licenses/>. 20*/ 21 22#include "includes.h" 23#include "libcli/smb2/smb2.h" 24#include "libcli/smb2/smb2_calls.h" 25 26/* 27 Send a Lease Break Acknowledgement 28*/ 29struct smb2_request *smb2_lease_break_ack_send(struct smb2_tree *tree, 30 struct smb2_lease_break_ack *io) 31{ 32 struct smb2_request *req; 33 34 req = smb2_request_init_tree(tree, SMB2_OP_BREAK, 0x24, false, 0); 35 if (req == NULL) return NULL; 36 37 SIVAL(req->out.body, 0x02, io->in.reserved); 38 SIVAL(req->out.body, 0x04, io->in.lease.lease_flags); 39 memcpy(req->out.body+0x8, &io->in.lease.lease_key, 40 sizeof(struct smb2_lease_key)); 41 SIVAL(req->out.body, 0x18, io->in.lease.lease_state); 42 SBVAL(req->out.body, 0x1C, io->in.lease.lease_duration); 43 44 smb2_transport_send(req); 45 46 return req; 47} 48 49 50/* 51 Receive a Lease Break Response 52*/ 53NTSTATUS smb2_lease_break_ack_recv(struct smb2_request *req, 54 struct smb2_lease_break_ack *io) 55{ 56 if (!smb2_request_receive(req) || 57 !smb2_request_is_ok(req)) { 58 return smb2_request_destroy(req); 59 } 60 61 SMB2_CHECK_PACKET_RECV(req, 0x24, false); 62 63 io->out.reserved = IVAL(req->in.body, 0x02); 64 io->out.lease.lease_flags = IVAL(req->in.body, 0x04); 65 memcpy(&io->out.lease.lease_key, req->in.body+0x8, 66 sizeof(struct smb2_lease_key)); 67 io->out.lease.lease_state = IVAL(req->in.body, 0x18); 68 io->out.lease.lease_duration = IVAL(req->in.body, 0x1C); 69 70 return smb2_request_destroy(req); 71} 72 73/* 74 sync flush request 75*/ 76NTSTATUS smb2_lease_break_ack(struct smb2_tree *tree, 77 struct smb2_lease_break_ack *io) 78{ 79 struct smb2_request *req = smb2_lease_break_ack_send(tree, io); 80 return smb2_lease_break_ack_recv(req, io); 81} 82