s4-libcli: Check return value of smbcli_request_setup().
[Samba/bjacke.git] / source4 / libcli / raw / clioplock.c
blob6c04843f3f7e3c1fe1f5e569880bbdeb91e10438
1 /*
2 Unix SMB/CIFS implementation.
3 SMB client oplock functions
4 Copyright (C) Andrew Tridgell 2001
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/raw/libcliraw.h"
22 #include "libcli/raw/raw_proto.h"
24 /****************************************************************************
25 send an ack for an oplock break request
26 ****************************************************************************/
27 _PUBLIC_ bool smbcli_oplock_ack(struct smbcli_tree *tree, uint16_t fnum, uint16_t ack_level)
29 bool ret;
30 struct smbcli_request *req;
32 req = smbcli_request_setup(tree, SMBlockingX, 8, 0);
33 if (req == NULL) {
34 return false;
37 SSVAL(req->out.vwv,VWV(0),0xFF);
38 SSVAL(req->out.vwv,VWV(1),0);
39 SSVAL(req->out.vwv,VWV(2),fnum);
40 SCVAL(req->out.vwv,VWV(3),LOCKING_ANDX_OPLOCK_RELEASE);
41 SCVAL(req->out.vwv,VWV(3)+1,ack_level);
42 SIVAL(req->out.vwv,VWV(4),0);
43 SSVAL(req->out.vwv,VWV(6),0);
44 SSVAL(req->out.vwv,VWV(7),0);
47 * The low level code knows it is a
48 * one way request by looking at SMBlockingX,
49 * wct == 8 and LOCKING_ANDX_OPLOCK_RELEASE
51 ret = smbcli_request_send(req);
53 return ret;
57 /****************************************************************************
58 set the oplock handler for a connection
59 ****************************************************************************/
60 _PUBLIC_ void smbcli_oplock_handler(struct smbcli_transport *transport,
61 bool (*handler)(struct smbcli_transport *, uint16_t, uint16_t, uint8_t, void *),
62 void *private_data)
64 transport->oplock.handler = handler;
65 transport->oplock.private_data = private_data;