From bda3d491b416f780f63841e9f3a92b9a94c2aadc Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 27 Oct 2011 17:20:27 +0200 Subject: 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 --- libcli/smb/smbXcli_base.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'libcli/smb/smbXcli_base.c') 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)) { -- cgit