2 * Unix SMB/CIFS implementation.
4 * test suite for SMB2 replay
6 * Copyright (C) Anubhav Rakshit 2014
7 * Copyright (C) Stefan Metzmacher 2014
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 3 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <http://www.gnu.org/licenses/>.
24 #include "libcli/smb2/smb2.h"
25 #include "libcli/smb2/smb2_calls.h"
26 #include "torture/torture.h"
27 #include "torture/smb2/proto.h"
28 #include "../libcli/smb/smbXcli_base.h"
29 #include "oplock_break_handler.h"
31 struct break_info break_info;
33 static void torture_oplock_ack_callback(struct smb2_request *req)
37 status = smb2_break_recv(req, &break_info.br);
38 if (!NT_STATUS_IS_OK(status)) {
39 break_info.failures++;
40 break_info.failure_status = status;
45 * A general oplock break notification handler. This should be used when a
46 * test expects to break from batch or exclusive to a lower level.
49 bool torture_oplock_ack_handler(struct smb2_transport *transport,
50 const struct smb2_handle *handle,
54 struct smb2_tree *tree = private_data;
56 struct smb2_request *req;
58 ZERO_STRUCT(break_info.br);
60 break_info.handle = *handle;
61 break_info.level = level;
65 case SMB2_OPLOCK_LEVEL_II:
68 case SMB2_OPLOCK_LEVEL_NONE:
73 break_info.failures++;
75 torture_comment(break_info.tctx,
76 "transport[%p] Acking to %s [0x%02X] in oplock handler\n",
77 transport, name, level);
79 break_info.br.in.file.handle = *handle;
80 break_info.br.in.oplock_level = level;
81 break_info.br.in.reserved = 0;
82 break_info.br.in.reserved2 = 0;
83 break_info.received_transport = tree->session->transport;
84 SMB_ASSERT(tree->session->transport == transport);
86 req = smb2_break_send(tree, &break_info.br);
87 req->async.fn = torture_oplock_ack_callback;
88 req->async.private_data = NULL;