s4-netlogon: implement dcesrv_netr_DsRAddressToSitenamesExW
[Samba/aatanasov.git] / source4 / libcli / smb2 / lease_break.c
blobc238f1d8abc8aaa0303cdb2b95acef896d90ba53
1 /*
2 Unix SMB/CIFS implementation.
4 SMB2 client oplock break handling
6 Copyright (C) Zachary Loafman 2009
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.
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.
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/>.
22 #include "includes.h"
23 #include "libcli/smb2/smb2.h"
24 #include "libcli/smb2/smb2_calls.h"
27 Send a Lease Break Acknowledgement
29 struct smb2_request *smb2_lease_break_ack_send(struct smb2_tree *tree,
30 struct smb2_lease_break_ack *io)
32 struct smb2_request *req;
34 req = smb2_request_init_tree(tree, SMB2_OP_BREAK, 0x24, false, 0);
35 if (req == NULL) return NULL;
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);
44 smb2_transport_send(req);
46 return req;
51 Receive a Lease Break Response
53 NTSTATUS smb2_lease_break_ack_recv(struct smb2_request *req,
54 struct smb2_lease_break_ack *io)
56 if (!smb2_request_receive(req) ||
57 !smb2_request_is_ok(req)) {
58 return smb2_request_destroy(req);
61 SMB2_CHECK_PACKET_RECV(req, 0x24, false);
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);
70 return smb2_request_destroy(req);
74 sync flush request
76 NTSTATUS smb2_lease_break_ack(struct smb2_tree *tree,
77 struct smb2_lease_break_ack *io)
79 struct smb2_request *req = smb2_lease_break_ack_send(tree, io);
80 return smb2_lease_break_ack_recv(req, io);