struct smb2_handle handle;
uint8_t level;
struct smb2_break br;
+ struct smb2_close cl;
int count;
int failures;
NTSTATUS failure_status;
return;
}
+static void torture_oplock_close_callback(struct smb2_request *req)
+{
+ NTSTATUS status;
+
+ status = smb2_close_recv(req, &break_info.cl);
+ if (!NT_STATUS_IS_OK(status)) {
+ break_info.failures++;
+ break_info.failure_status = status;
+ }
+
+ return;
+}
+
+/* A general oplock break notification handler. This should be used when a
+ * test expects to break from batch or exclusive to a lower level. */
+static bool torture_oplock_close_handler(struct smb2_transport *transport,
+ const struct smb2_handle *handle,
+ uint8_t level,
+ void *private_data)
+{
+ struct smb2_tree *tree = private_data;
+ const char *name;
+ struct smb2_request *req;
+ ZERO_STRUCT(break_info.br);
+
+ break_info.handle = *handle;
+ break_info.level = level;
+ break_info.count++;
+
+ switch (level) {
+ case SMB2_OPLOCK_LEVEL_II:
+ name = "level II";
+ break;
+ case SMB2_OPLOCK_LEVEL_NONE:
+ name = "none";
+ break;
+ default:
+ name = "unknown";
+ break_info.failures++;
+ }
+ printf("Got break to %s [0x%02X] => closing in oplock handler\n", name, level);
+
+ ZERO_STRUCT(break_info.cl);
+ break_info.cl.in.file.handle = *handle;
+
+ req = smb2_close_send(tree, &break_info.cl);
+ req->async.fn = torture_oplock_close_callback;
+ req->async.private_data = NULL;
+ return true;
+}
+
/**
* Test what happens when SMB2_FLAGS_REPLAY_OPERATION is enabled for various
* commands. We want to verify if the server returns an error code or not.