summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2013-08-13 18:20:08 +0200
committerStefan Metzmacher <metze@samba.org>2013-08-15 09:07:07 +0200
commita85d4511e6bc84938d60f090b44a5b1468ee4136 (patch)
tree322c0fd1db217c4994ab05277157793a8dcbbf21
parent6896bf0b28a07eb8ead5b3bd2bc50229aa59d439 (diff)
downloadsamba-a85d4511e6bc84938d60f090b44a5b1468ee4136.tar.gz
samba-a85d4511e6bc84938d60f090b44a5b1468ee4136.tar.bz2
samba-a85d4511e6bc84938d60f090b44a5b1468ee4136.zip
s3:libsmb: add SMB2 support to cli_pull*
Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
-rw-r--r--source3/libsmb/clireadwrite.c60
1 files changed, 46 insertions, 14 deletions
diff --git a/source3/libsmb/clireadwrite.c b/source3/libsmb/clireadwrite.c
index 821bcb18cf..d28c226037 100644
--- a/source3/libsmb/clireadwrite.c
+++ b/source3/libsmb/clireadwrite.c
@@ -360,7 +360,11 @@ struct tevent_req *cli_pull_send(TALLOC_CTX *mem_ctx,
return tevent_req_post(req, ev);
}
- state->chunk_size = cli_read_max_bufsize(cli);
+ if (smbXcli_conn_protocol(state->cli->conn) >= PROTOCOL_SMB2_02) {
+ state->chunk_size = smb2cli_conn_max_read_size(cli->conn);
+ } else {
+ state->chunk_size = cli_read_max_bufsize(cli);
+ }
if (state->chunk_size > page_size) {
state->chunk_size &= ~(page_size - 1);
}
@@ -519,19 +523,43 @@ static void cli_pull_chunk_ship(struct cli_pull_chunk *chunk)
ofs = chunk->ofs + chunk->tmp_size;
size = chunk->total_size - chunk->tmp_size;
- ok = smb1cli_conn_req_possible(state->cli->conn);
- if (!ok) {
- return;
- }
+ if (smbXcli_conn_protocol(state->cli->conn) >= PROTOCOL_SMB2_02) {
+ uint32_t max_size;
- chunk->subreq = cli_read_andx_send(chunk,
- state->ev,
- state->cli,
- state->fnum,
- ofs,
- size);
- if (tevent_req_nomem(chunk->subreq, req)) {
- return;
+ ok = smb2cli_conn_req_possible(state->cli->conn, &max_size);
+ if (!ok) {
+ return;
+ }
+
+ /*
+ * downgrade depending on the available credits
+ */
+ size = MIN(max_size, size);
+
+ chunk->subreq = cli_smb2_read_send(chunk,
+ state->ev,
+ state->cli,
+ state->fnum,
+ ofs,
+ size);
+ if (tevent_req_nomem(chunk->subreq, req)) {
+ return;
+ }
+ } else {
+ ok = smb1cli_conn_req_possible(state->cli->conn);
+ if (!ok) {
+ return;
+ }
+
+ chunk->subreq = cli_read_andx_send(chunk,
+ state->ev,
+ state->cli,
+ state->fnum,
+ ofs,
+ size);
+ if (tevent_req_nomem(chunk->subreq, req)) {
+ return;
+ }
}
tevent_req_set_callback(chunk->subreq,
cli_pull_chunk_done,
@@ -557,7 +585,11 @@ static void cli_pull_chunk_done(struct tevent_req *subreq)
chunk->subreq = NULL;
- status = cli_read_andx_recv(subreq, &received, &buf);
+ if (smbXcli_conn_protocol(state->cli->conn) >= PROTOCOL_SMB2_02) {
+ status = cli_smb2_read_recv(subreq, &received, &buf);
+ } else {
+ status = cli_read_andx_recv(subreq, &received, &buf);
+ }
if (NT_STATUS_EQUAL(status, NT_STATUS_END_OF_FILE)) {
received = 0;
status = NT_STATUS_OK;