/*
Unix SMB/CIFS implementation.
test suite for SMB2 connection operations
Copyright (C) Andrew Tridgell 2005
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
*/
#include "includes.h"
#include "libcli/smb2/smb2.h"
#include "libcli/smb2/smb2_calls.h"
#include "torture/torture.h"
#include "torture/smb2/proto.h"
/*
send a close
*/
static NTSTATUS torture_smb2_close(struct torture_context *tctx,
struct smb2_tree *tree,
struct smb2_handle handle)
{
struct smb2_close io;
NTSTATUS status;
TALLOC_CTX *tmp_ctx = talloc_new(tree);
ZERO_STRUCT(io);
io.in.file.handle = handle;
io.in.flags = SMB2_CLOSE_FLAGS_FULL_INFORMATION;
status = smb2_close(tree, &io);
if (!NT_STATUS_IS_OK(status)) {
torture_comment(tctx, "close failed - %s\n", nt_errstr(status));
return status;
}
if (DEBUGLVL(1)) {
torture_comment(tctx, "Close gave:\n");
torture_comment(tctx, "create_time = %s\n", nt_time_string(tmp_ctx, io.out.create_time));
torture_comment(tctx, "access_time = %s\n", nt_time_string(tmp_ctx, io.out.access_time));
torture_comment(tctx, "write_time = %s\n", nt_time_string(tmp_ctx, io.out.write_time));
torture_comment(tctx, "change_time = %s\n", nt_time_string(tmp_ctx, io.out.change_time));
torture_comment(tctx, "alloc_size = %lld\n", (long long)io.out.alloc_size);
torture_comment(tctx, "size = %lld\n", (long long)io.out.size);
torture_comment(tctx, "file_attr = 0x%x\n", io.out.file_attr);
}
talloc_free(tmp_ctx);
return status;
}
/*
test writing
*/
static NTSTATUS torture_smb2_write(struct torture_context *tctx, struct smb2_tree *tree, struct smb2_handle handle)
{
struct smb2_write w;
struct smb2_read r;
struct smb2_flush f;
NTSTATUS status;
DATA_BLOB data;
int i;
uint32_t size = torture_setting_int(tctx, "smb2maxwrite", 64*1024);
data = data_blob_talloc(tree, NULL, size);
if (size != data.length) {
torture_comment(tctx, "data_blob_talloc(%u) failed\n", (unsigned int)size);
return NT_STATUS_NO_MEMORY;
}
for (i=0;isession);
torture_assert_ntstatus_ok(tctx, status, "logoff failed");
req = smb2_logoff_send(tree->session);
torture_assert_not_null(tctx, req, "smb2_logoff_send failed");
req->session = NULL;
status = smb2_logoff_recv(req);
torture_assert_ntstatus_equal(tctx, status, NT_STATUS_USER_SESSION_DELETED,
"logoff should have disabled session");
status = smb2_keepalive(tree->session->transport);
torture_assert_ntstatus_ok(tctx, status, "keepalive failed");
talloc_free(mem_ctx);
return true;
}