summaryrefslogtreecommitdiff
path: root/libcli/smb
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2011-10-27 17:20:27 +0200
committerStefan Metzmacher <metze@samba.org>2011-11-24 19:02:31 +0100
commitbda3d491b416f780f63841e9f3a92b9a94c2aadc (patch)
tree8b774fbaac611108d4619dfa9f80c6a8d1fbe4c2 /libcli/smb
parent0995d68d59d5d2eeb5533b005b4651f416e64548 (diff)
downloadsamba-bda3d491b416f780f63841e9f3a92b9a94c2aadc.tar.gz
samba-bda3d491b416f780f63841e9f3a92b9a94c2aadc.tar.bz2
samba-bda3d491b416f780f63841e9f3a92b9a94c2aadc.zip
smbXcli: add smb2cli_req_set_notify_async()
That can be used if the caller wants to be notified if the async interim response arrives. metze
Diffstat (limited to 'libcli/smb')
-rw-r--r--libcli/smb/smbXcli_base.c23
-rw-r--r--libcli/smb/smbXcli_base.h1
2 files changed, 24 insertions, 0 deletions
diff --git a/libcli/smb/smbXcli_base.c b/libcli/smb/smbXcli_base.c
index 17256ea6fd..a2c94b3740 100644
--- a/libcli/smb/smbXcli_base.c
+++ b/libcli/smb/smbXcli_base.c
@@ -193,6 +193,8 @@ struct smbXcli_req_state {
uint16_t credit_charge;
bool signing_skipped;
+ bool notify_async;
+ bool got_async;
} smb2;
};
@@ -2235,6 +2237,15 @@ struct tevent_req *smb2cli_req_create(TALLOC_CTX *mem_ctx,
return req;
}
+void smb2cli_req_set_notify_async(struct tevent_req *req)
+{
+ struct smbXcli_req_state *state =
+ tevent_req_data(req,
+ struct smbXcli_req_state);
+
+ state->smb2.notify_async = true;
+}
+
static void smb2cli_writev_done(struct tevent_req *subreq);
static NTSTATUS smb2cli_conn_dispatch_incoming(struct smbXcli_conn *conn,
TALLOC_CTX *tmp_mem,
@@ -2634,6 +2645,8 @@ static NTSTATUS smb2cli_conn_dispatch_incoming(struct smbXcli_conn *conn,
}
state = tevent_req_data(req, struct smbXcli_req_state);
+ state->smb2.got_async = false;
+
req_opcode = SVAL(state->smb2.hdr, SMB2_HDR_OPCODE);
if (opcode != req_opcode) {
return NT_STATUS_INVALID_NETWORK_RESPONSE;
@@ -2657,6 +2670,12 @@ static NTSTATUS smb2cli_conn_dispatch_incoming(struct smbXcli_conn *conn,
req_flags |= SMB2_HDR_FLAG_ASYNC;
SBVAL(state->smb2.hdr, SMB2_HDR_FLAGS, req_flags);
SBVAL(state->smb2.hdr, SMB2_HDR_ASYNC_ID, async_id);
+
+ if (state->smb2.notify_async) {
+ state->smb2.got_async = true;
+ tevent_req_defer_callback(req, state->ev);
+ tevent_req_notify_callback(req);
+ }
continue;
}
@@ -2833,6 +2852,10 @@ NTSTATUS smb2cli_req_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
*piov = NULL;
}
+ if (state->smb2.got_async) {
+ return STATUS_PENDING;
+ }
+
if (tevent_req_is_nterror(req, &status)) {
for (i=0; i < num_expected; i++) {
if (NT_STATUS_EQUAL(status, expected[i].status)) {
diff --git a/libcli/smb/smbXcli_base.h b/libcli/smb/smbXcli_base.h
index ea03c4caf7..543621392b 100644
--- a/libcli/smb/smbXcli_base.h
+++ b/libcli/smb/smbXcli_base.h
@@ -154,6 +154,7 @@ struct tevent_req *smb2cli_req_create(TALLOC_CTX *mem_ctx,
uint16_t fixed_len,
const uint8_t *dyn,
uint32_t dyn_len);
+void smb2cli_req_set_notify_async(struct tevent_req *req);
NTSTATUS smb2cli_req_compound_submit(struct tevent_req **reqs,
int num_reqs);
void smb2cli_req_set_credit_charge(struct tevent_req *req, uint16_t charge);