summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2012-07-23 22:32:49 +0200
committerStefan Metzmacher <metze@samba.org>2012-07-24 22:20:06 +0200
commit697b82a61979b48de86d74d2bf5c498032ff49b1 (patch)
tree15b979f43065e3ce53f82c3ea57fa080a0a3fb19
parent74f9b52e659265c7a6283550d226f0cec5e8fb18 (diff)
downloadsamba-697b82a61979b48de86d74d2bf5c498032ff49b1.tar.gz
samba-697b82a61979b48de86d74d2bf5c498032ff49b1.tar.bz2
samba-697b82a61979b48de86d74d2bf5c498032ff49b1.zip
libcli/smb: pass smbXcli_tcon to smb2cli_read*()
metze
-rw-r--r--libcli/smb/smb2cli_read.c11
-rw-r--r--libcli/smb/smbXcli_base.h4
-rw-r--r--source3/libsmb/cli_np_tstream.c2
-rw-r--r--source3/torture/test_smb2.c30
4 files changed, 31 insertions, 16 deletions
diff --git a/libcli/smb/smb2cli_read.c b/libcli/smb/smb2cli_read.c
index 29b9f378e6..5ff4b6443d 100644
--- a/libcli/smb/smb2cli_read.c
+++ b/libcli/smb/smb2cli_read.c
@@ -38,7 +38,7 @@ struct tevent_req *smb2cli_read_send(TALLOC_CTX *mem_ctx,
struct smbXcli_conn *conn,
uint32_t timeout_msec,
struct smbXcli_session *session,
- uint32_t tcon_id,
+ struct smbXcli_tcon *tcon,
uint32_t length,
uint64_t offset,
uint64_t fid_persistent,
@@ -49,6 +49,7 @@ struct tevent_req *smb2cli_read_send(TALLOC_CTX *mem_ctx,
struct tevent_req *req, *subreq;
struct smb2cli_read_state *state;
uint8_t *fixed;
+ uint32_t tcon_id = 0;
req = tevent_req_create(mem_ctx, &state,
struct smb2cli_read_state);
@@ -66,6 +67,10 @@ struct tevent_req *smb2cli_read_send(TALLOC_CTX *mem_ctx,
SBVAL(fixed, 32, minimum_count);
SBVAL(fixed, 40, remaining_bytes);
+ if (tcon) {
+ tcon_id = smb2cli_tcon_current_id(tcon);
+ }
+
subreq = smb2cli_req_send(state, ev, conn, SMB2_OP_READ,
0, 0, /* flags */
timeout_msec,
@@ -142,7 +147,7 @@ NTSTATUS smb2cli_read_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
NTSTATUS smb2cli_read(struct smbXcli_conn *conn,
uint32_t timeout_msec,
struct smbXcli_session *session,
- uint32_t tcon_id,
+ struct smbXcli_tcon *tcon,
uint32_t length,
uint64_t offset,
uint64_t fid_persistent,
@@ -170,7 +175,7 @@ NTSTATUS smb2cli_read(struct smbXcli_conn *conn,
goto fail;
}
req = smb2cli_read_send(frame, ev,
- conn, timeout_msec, session, tcon_id,
+ conn, timeout_msec, session, tcon,
length, offset,
fid_persistent, fid_volatile,
minimum_count, remaining_bytes);
diff --git a/libcli/smb/smbXcli_base.h b/libcli/smb/smbXcli_base.h
index b433c4e769..7aefffc85d 100644
--- a/libcli/smb/smbXcli_base.h
+++ b/libcli/smb/smbXcli_base.h
@@ -374,7 +374,7 @@ struct tevent_req *smb2cli_read_send(TALLOC_CTX *mem_ctx,
struct smbXcli_conn *conn,
uint32_t timeout_msec,
struct smbXcli_session *session,
- uint32_t tcon_id,
+ struct smbXcli_tcon *tcon,
uint32_t length,
uint64_t offset,
uint64_t fid_persistent,
@@ -386,7 +386,7 @@ NTSTATUS smb2cli_read_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
NTSTATUS smb2cli_read(struct smbXcli_conn *conn,
uint32_t timeout_msec,
struct smbXcli_session *session,
- uint32_t tcon_id,
+ struct smbXcli_tcon *tcon,
uint32_t length,
uint64_t offset,
uint64_t fid_persistent,
diff --git a/source3/libsmb/cli_np_tstream.c b/source3/libsmb/cli_np_tstream.c
index 47333868dc..2ec33d5ac4 100644
--- a/source3/libsmb/cli_np_tstream.c
+++ b/source3/libsmb/cli_np_tstream.c
@@ -773,7 +773,7 @@ static void tstream_cli_np_readv_read_next(struct tevent_req *req)
cli_nps->cli->conn,
cli_nps->cli->timeout,
cli_nps->cli->smb2.session,
- cli_nps->cli->smb2.tid,
+ cli_nps->cli->smb2.tcon,
TSTREAM_CLI_NP_MAX_BUF_SIZE, /* length */
0, /* offset */
cli_nps->fid_persistent,
diff --git a/source3/torture/test_smb2.c b/source3/torture/test_smb2.c
index a4655dc05d..ba5cb8ffba 100644
--- a/source3/torture/test_smb2.c
+++ b/source3/torture/test_smb2.c
@@ -105,7 +105,7 @@ bool run_smb2_basic(int dummy)
}
status = smb2cli_read(cli->conn, cli->timeout, cli->smb2.session,
- cli->smb2.tid, 0x10000, 0, fid_persistent,
+ cli->smb2.tcon, 0x10000, 0, fid_persistent,
fid_volatile, 2, 0,
talloc_tos(), &result, &nread);
if (!NT_STATUS_IS_OK(status)) {
@@ -355,7 +355,7 @@ bool run_smb2_session_reconnect(int dummy)
}
status = smb2cli_read(cli1->conn, cli1->timeout, cli1->smb2.session,
- cli1->smb2.tid, 0x10000, 0, fid_persistent,
+ cli1->smb2.tcon, 0x10000, 0, fid_persistent,
fid_volatile, 2, 0,
talloc_tos(), &result, &nread);
if (!NT_STATUS_IS_OK(status)) {
@@ -547,7 +547,7 @@ bool run_smb2_session_reconnect(int dummy)
}
status = smb2cli_read(cli2->conn, cli2->timeout, cli2->smb2.session,
- cli2->smb2.tid, 0x10000, 0, fid_persistent,
+ cli2->smb2.tcon, 0x10000, 0, fid_persistent,
fid_volatile, 2, 0,
talloc_tos(), &result, &nread);
if (!NT_STATUS_EQUAL(status, NT_STATUS_FILE_CLOSED) &&
@@ -609,7 +609,7 @@ bool run_smb2_session_reconnect(int dummy)
}
status = smb2cli_read(cli2->conn, cli2->timeout, cli2->smb2.session,
- cli2->smb2.tid, 0x10000, 0, fid_persistent,
+ cli2->smb2.tcon, 0x10000, 0, fid_persistent,
fid_volatile, 2, 0,
talloc_tos(), &result, &nread);
if (!NT_STATUS_EQUAL(status, NT_STATUS_FILE_CLOSED) &&
@@ -679,7 +679,7 @@ bool run_smb2_session_reconnect(int dummy)
}
status = smb2cli_read(cli2->conn, cli2->timeout, cli2->smb2.session,
- cli2->smb2.tid, 0x10000, 0, fid_persistent,
+ cli2->smb2.tcon, 0x10000, 0, fid_persistent,
fid_volatile, 2, 0,
talloc_tos(), &result, &nread);
if (!NT_STATUS_IS_OK(status)) {
@@ -710,6 +710,8 @@ bool run_smb2_tcon_dependence(int dummy)
const char *hello = "Hello, world\n";
uint8_t *result;
uint32_t nread;
+ struct smbXcli_tcon *tcon2;
+ uint32_t tcon2_id;
printf("Starting SMB2-TCON-DEPENDENCE\n");
@@ -773,7 +775,7 @@ bool run_smb2_tcon_dependence(int dummy)
}
status = smb2cli_read(cli->conn, cli->timeout, cli->smb2.session,
- cli->smb2.tid, 0x10000, 0, fid_persistent,
+ cli->smb2.tcon, 0x10000, 0, fid_persistent,
fid_volatile, 2, 0,
talloc_tos(), &result, &nread);
if (!NT_STATUS_IS_OK(status)) {
@@ -795,10 +797,18 @@ bool run_smb2_tcon_dependence(int dummy)
/* check behaviour with wrong tid... */
- cli->smb2.tid++;
+ tcon2 = smbXcli_tcon_create(cli);
+ tcon2_id = smb2cli_tcon_current_id(cli->smb2.tcon);
+ tcon2_id++;
+ smb2cli_tcon_set_values(tcon2,
+ tcon2_id,
+ 0, /* type */
+ 0, /* flags */
+ 0, /* capabilities */
+ 0 /* maximal_access */);
status = smb2cli_read(cli->conn, cli->timeout, cli->smb2.session,
- cli->smb2.tid, 0x10000, 0, fid_persistent,
+ tcon2, 0x10000, 0, fid_persistent,
fid_volatile, 2, 0,
talloc_tos(), &result, &nread);
if (!NT_STATUS_EQUAL(status, NT_STATUS_NETWORK_NAME_DELETED)) {
@@ -806,7 +816,7 @@ bool run_smb2_tcon_dependence(int dummy)
return false;
}
- cli->smb2.tid--;
+ talloc_free(tcon2);
return true;
}
@@ -1192,7 +1202,7 @@ bool run_smb2_multi_channel(int dummy)
}
status = smb2cli_read(cli2->conn, cli2->timeout, cli2->smb2.session,
- cli2->smb2.tid, 0x10000, 0, fid_persistent,
+ cli2->smb2.tcon, 0x10000, 0, fid_persistent,
fid_volatile, 2, 0,
talloc_tos(), &result, &nread);
if (!NT_STATUS_IS_OK(status)) {