00001 /* 00002 Unix SMB/CIFS implementation. 00003 SMB client oplock functions 00004 Copyright (C) Andrew Tridgell 2001 00005 00006 This program is free software; you can redistribute it and/or modify 00007 it under the terms of the GNU General Public License as published by 00008 the Free Software Foundation; either version 2 of the License, or 00009 (at your option) any later version. 00010 00011 This program is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 GNU General Public License for more details. 00015 00016 You should have received a copy of the GNU General Public License 00017 along with this program; if not, write to the Free Software 00018 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00019 */ 00020 00021 #include "includes.h" 00022 00023 /**************************************************************************** 00024 send an ack for an oplock break request 00025 ****************************************************************************/ 00026 BOOL cli_oplock_ack(struct cli_state *cli, int fnum, unsigned char level) 00027 { 00028 char *oldbuf = cli->outbuf; 00029 pstring buf; 00030 BOOL ret; 00031 00032 cli->outbuf = buf; 00033 00034 memset(buf,'\0',smb_size); 00035 set_message(buf,8,0,True); 00036 00037 SCVAL(buf,smb_com,SMBlockingX); 00038 SSVAL(buf,smb_tid, cli->cnum); 00039 cli_setup_packet(cli); 00040 SSVAL(buf,smb_vwv0,0xFF); 00041 SSVAL(buf,smb_vwv1,0); 00042 SSVAL(buf,smb_vwv2,fnum); 00043 if (level == 1) 00044 SSVAL(buf,smb_vwv3,0x102); /* levelII oplock break ack */ 00045 else 00046 SSVAL(buf,smb_vwv3,2); /* exclusive oplock break ack */ 00047 SIVAL(buf,smb_vwv4,0); /* timoeut */ 00048 SSVAL(buf,smb_vwv6,0); /* unlockcount */ 00049 SSVAL(buf,smb_vwv7,0); /* lockcount */ 00050 00051 ret = cli_send_smb(cli); 00052 00053 cli->outbuf = oldbuf; 00054 00055 return ret; 00056 } 00057 00058 00059 /**************************************************************************** 00060 set the oplock handler for a connection 00061 ****************************************************************************/ 00062 void cli_oplock_handler(struct cli_state *cli, 00063 BOOL (*handler)(struct cli_state *, int, unsigned char)) 00064 { 00065 cli->oplock_handler = handler; 00066 }