summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuk Claes <luk@debian.org>2012-05-10 18:40:56 +0200
committerStefan Metzmacher <metze@samba.org>2012-05-12 01:01:31 +0200
commitc7a129262857ede4d4985a1c368b7066811ed2c3 (patch)
tree833088031d9a2f5c9a1bd184a8b90112f040cdaf
parent50d88c96bc03206b59a882669ab13f763945d41f (diff)
downloadsamba-c7a129262857ede4d4985a1c368b7066811ed2c3.tar.gz
samba-c7a129262857ede4d4985a1c368b7066811ed2c3.tar.bz2
samba-c7a129262857ede4d4985a1c368b7066811ed2c3.zip
s3/libsmb: Generalise cli_state in smb2 write calls
Signed-off-by: Luk Claes <luk@debian.org> Signed-off-by: Stefan Metzmacher <metze@samba.org>
-rw-r--r--source3/libsmb/cli_np_tstream.c20
-rw-r--r--source3/libsmb/smb2cli.h10
-rw-r--r--source3/libsmb/smb2cli_write.c25
-rw-r--r--source3/torture/test_smb2.c21
4 files changed, 50 insertions, 26 deletions
diff --git a/source3/libsmb/cli_np_tstream.c b/source3/libsmb/cli_np_tstream.c
index 9bf5611d96..53e0c41d8c 100644
--- a/source3/libsmb/cli_np_tstream.c
+++ b/source3/libsmb/cli_np_tstream.c
@@ -473,14 +473,18 @@ static void tstream_cli_np_writev_write_next(struct tevent_req *req)
0, /* offset */
cli_nps->write.ofs); /* size */
} else {
- subreq = smb2cli_write_send(state, state->ev, cli_nps->cli,
- cli_nps->write.ofs, /* length */
- 0, /* offset */
- cli_nps->fid_persistent,
- cli_nps->fid_volatile,
- 0, /* remaining_bytes */
- 0, /* flags */
- cli_nps->write.buf);
+ subreq = smb2cli_write_send(state, state->ev,
+ cli_nps->cli->conn,
+ cli_nps->cli->timeout,
+ cli_nps->cli->smb2.session,
+ cli_nps->cli->smb2.tid,
+ cli_nps->write.ofs, /* length */
+ 0, /* offset */
+ cli_nps->fid_persistent,
+ cli_nps->fid_volatile,
+ 0, /* remaining_bytes */
+ 0, /* flags */
+ cli_nps->write.buf);
}
if (tevent_req_nomem(subreq, req)) {
return;
diff --git a/source3/libsmb/smb2cli.h b/source3/libsmb/smb2cli.h
index e562945358..6fa77f4ff3 100644
--- a/source3/libsmb/smb2cli.h
+++ b/source3/libsmb/smb2cli.h
@@ -142,7 +142,10 @@ NTSTATUS smb2cli_read(struct smbXcli_conn *conn,
struct tevent_req *smb2cli_write_send(TALLOC_CTX *mem_ctx,
struct tevent_context *ev,
- struct cli_state *cli,
+ struct smbXcli_conn *conn,
+ uint32_t timeout_msec,
+ struct smbXcli_session *session,
+ uint32_t tcon_id,
uint32_t length,
uint64_t offset,
uint64_t fid_persistent,
@@ -151,7 +154,10 @@ struct tevent_req *smb2cli_write_send(TALLOC_CTX *mem_ctx,
uint32_t flags,
const uint8_t *data);
NTSTATUS smb2cli_write_recv(struct tevent_req *req);
-NTSTATUS smb2cli_write(struct cli_state *cli,
+NTSTATUS smb2cli_write(struct smbXcli_conn *conn,
+ uint32_t timeout_msec,
+ struct smbXcli_session *session,
+ uint32_t tcon_id,
uint32_t length,
uint64_t offset,
uint64_t fid_persistent,
diff --git a/source3/libsmb/smb2cli_write.c b/source3/libsmb/smb2cli_write.c
index 3d7b667a50..e257b588be 100644
--- a/source3/libsmb/smb2cli_write.c
+++ b/source3/libsmb/smb2cli_write.c
@@ -34,7 +34,10 @@ static void smb2cli_write_done(struct tevent_req *subreq);
struct tevent_req *smb2cli_write_send(TALLOC_CTX *mem_ctx,
struct tevent_context *ev,
- struct cli_state *cli,
+ struct smbXcli_conn *conn,
+ uint32_t timeout_msec,
+ struct smbXcli_session *session,
+ uint32_t tcon_id,
uint32_t length,
uint64_t offset,
uint64_t fid_persistent,
@@ -74,12 +77,12 @@ struct tevent_req *smb2cli_write_send(TALLOC_CTX *mem_ctx,
dyn_len = sizeof(state->dyn_pad);
}
- subreq = smb2cli_req_send(state, ev, cli->conn, SMB2_OP_WRITE,
+ subreq = smb2cli_req_send(state, ev, conn, SMB2_OP_WRITE,
0, 0, /* flags */
- cli->timeout,
- cli->smb2.pid,
- cli->smb2.tid,
- cli->smb2.session,
+ timeout_msec,
+ 0xFEFF, /* pid */
+ tcon_id,
+ session,
state->fixed, sizeof(state->fixed),
dyn, dyn_len);
if (tevent_req_nomem(subreq, req)) {
@@ -115,7 +118,10 @@ NTSTATUS smb2cli_write_recv(struct tevent_req *req)
return tevent_req_simple_recv_ntstatus(req);
}
-NTSTATUS smb2cli_write(struct cli_state *cli,
+NTSTATUS smb2cli_write(struct smbXcli_conn *conn,
+ uint32_t timeout_msec,
+ struct smbXcli_session *session,
+ uint32_t tcon_id,
uint32_t length,
uint64_t offset,
uint64_t fid_persistent,
@@ -129,7 +135,7 @@ NTSTATUS smb2cli_write(struct cli_state *cli,
struct tevent_req *req;
NTSTATUS status = NT_STATUS_NO_MEMORY;
- if (cli_has_async_calls(cli)) {
+ if (smbXcli_conn_has_async_calls(conn)) {
/*
* Can't use sync call while an async call is in flight
*/
@@ -140,7 +146,8 @@ NTSTATUS smb2cli_write(struct cli_state *cli,
if (ev == NULL) {
goto fail;
}
- req = smb2cli_write_send(frame, ev, cli, length, offset,
+ req = smb2cli_write_send(frame, ev, conn, timeout_msec, session,
+ tcon_id, length, offset,
fid_persistent, fid_volatile,
remaining_bytes, flags, data);
if (req == NULL) {
diff --git a/source3/torture/test_smb2.c b/source3/torture/test_smb2.c
index 8ce0ad84e7..12f32aa07f 100644
--- a/source3/torture/test_smb2.c
+++ b/source3/torture/test_smb2.c
@@ -89,7 +89,8 @@ bool run_smb2_basic(int dummy)
return false;
}
- status = smb2cli_write(cli, strlen(hello), 0, fid_persistent,
+ status = smb2cli_write(cli->conn, cli->timeout, cli->smb2.session,
+ cli->smb2.tid, strlen(hello), 0, fid_persistent,
fid_volatile, 0, 0, (const uint8_t *)hello);
if (!NT_STATUS_IS_OK(status)) {
printf("smb2cli_write returned %s\n", nt_errstr(status));
@@ -338,7 +339,8 @@ bool run_smb2_session_reconnect(int dummy)
return false;
}
- status = smb2cli_write(cli1, strlen(hello), 0, fid_persistent,
+ status = smb2cli_write(cli1->conn, cli1->timeout, cli1->smb2.session,
+ cli1->smb2.tid, strlen(hello), 0, fid_persistent,
fid_volatile, 0, 0, (const uint8_t *)hello);
if (!NT_STATUS_IS_OK(status)) {
printf("smb2cli_write returned %s\n", nt_errstr(status));
@@ -532,7 +534,8 @@ bool run_smb2_session_reconnect(int dummy)
return false;
}
- status = smb2cli_write(cli2, strlen(hello), 0, fid_persistent,
+ status = smb2cli_write(cli2->conn, cli2->timeout, cli2->smb2.session,
+ cli2->smb2.tid, strlen(hello), 0, fid_persistent,
fid_volatile, 0, 0, (const uint8_t *)hello);
if (!NT_STATUS_EQUAL(status, NT_STATUS_FILE_CLOSED)) {
printf("smb2cli_write returned %s\n", nt_errstr(status));
@@ -587,7 +590,8 @@ bool run_smb2_session_reconnect(int dummy)
return false;
}
- status = smb2cli_write(cli2, strlen(hello), 0, fid_persistent,
+ status = smb2cli_write(cli2->conn, cli2->timeout, cli2->smb2.session,
+ cli2->smb2.tid, strlen(hello), 0, fid_persistent,
fid_volatile, 0, 0, (const uint8_t *)hello);
if (!NT_STATUS_EQUAL(status, NT_STATUS_FILE_CLOSED)) {
printf("smb2cli_write returned %s\n", nt_errstr(status));
@@ -645,7 +649,8 @@ bool run_smb2_session_reconnect(int dummy)
return false;
}
- status = smb2cli_write(cli2, strlen(hello), 0, fid_persistent,
+ status = smb2cli_write(cli2->conn, cli2->timeout, cli2->smb2.session,
+ cli2->smb2.tid, strlen(hello), 0, fid_persistent,
fid_volatile, 0, 0, (const uint8_t *)hello);
if (!NT_STATUS_IS_OK(status)) {
printf("smb2cli_write returned %s\n", nt_errstr(status));
@@ -738,7 +743,8 @@ bool run_smb2_tcon_dependence(int dummy)
return false;
}
- status = smb2cli_write(cli, strlen(hello), 0, fid_persistent,
+ status = smb2cli_write(cli->conn, cli->timeout, cli->smb2.session,
+ cli->smb2.tid, strlen(hello), 0, fid_persistent,
fid_volatile, 0, 0, (const uint8_t *)hello);
if (!NT_STATUS_IS_OK(status)) {
printf("smb2cli_write returned %s\n", nt_errstr(status));
@@ -1142,7 +1148,8 @@ bool run_smb2_multi_channel(int dummy)
return false;
}
- status = smb2cli_write(cli1, strlen(hello), 0, fid_persistent,
+ status = smb2cli_write(cli1->conn, cli1->timeout, cli1->smb2.session,
+ cli1->smb2.tid, strlen(hello), 0, fid_persistent,
fid_volatile, 0, 0, (const uint8_t *)hello);
if (!NT_STATUS_IS_OK(status)) {
printf("smb2cli_write returned %s\n", nt_errstr(status));