uint8_t *inbuf;
uint32_t seqnum;
int chain_num;
+ int chain_length;
struct tevent_req **chained_requests;
};
{
struct tevent_req *result;
struct cli_smb_state *state;
+ struct timeval endtime;
if (iov_count > MAX_SMB_IOV) {
/*
}
state->iov_count = iov_count + 3;
+ if (cli->timeout) {
+ endtime = timeval_current_ofs(0, cli->timeout * 1000);
+ if (!tevent_req_set_endtime(result, ev, endtime)) {
+ tevent_req_nomem(NULL, result);
+ }
+ }
return result;
}
if (state->mid != 0) {
SSVAL(iov[0].iov_base, smb_mid, state->mid);
} else {
- SSVAL(iov[0].iov_base, smb_mid, cli_alloc_mid(state->cli));
+ uint16_t mid = cli_alloc_mid(state->cli);
+ SSVAL(iov[0].iov_base, smb_mid, mid);
}
smb_setlen((char *)iov[0].iov_base, iov_len(iov, iov_count) - 4);
subreq, struct cli_state);
struct tevent_req *req;
struct cli_smb_state *state;
- struct tevent_context *ev;
NTSTATUS status;
uint8_t *inbuf;
ssize_t received;
req = cli->pending[i];
state = tevent_req_data(req, struct cli_smb_state);
- ev = state->ev;
if (!oplock_break /* oplock breaks are not signed */
&& !cli_check_sign_mac(cli, (char *)inbuf, state->seqnum+1)) {
state->inbuf = talloc_move(state, &inbuf);
talloc_set_destructor(req, NULL);
cli_smb_req_destructor(req);
+ state->chain_num = 0;
+ state->chain_length = 1;
tevent_req_done(req);
} else {
struct tevent_req **chain = talloc_move(
cli_smb_state);
state->inbuf = inbuf;
state->chain_num = i;
+ state->chain_length = num_chained;
tevent_req_done(chain[i]);
}
TALLOC_FREE(inbuf);
}
}
-NTSTATUS cli_smb_recv(struct tevent_req *req, uint8_t min_wct,
- uint8_t *pwct, uint16_t **pvwv,
+NTSTATUS cli_smb_recv(struct tevent_req *req,
+ TALLOC_CTX *mem_ctx, uint8_t **pinbuf,
+ uint8_t min_wct, uint8_t *pwct, uint16_t **pvwv,
uint32_t *pnum_bytes, uint8_t **pbytes)
{
struct cli_smb_state *state = tevent_req_data(
status = cli_pull_error((char *)state->inbuf);
- if (!have_andx_command((char *)state->inbuf, wct_ofs)
- && NT_STATUS_IS_ERR(status)) {
- /*
- * The last command takes the error code. All further commands
- * down the requested chain will get a
- * NT_STATUS_REQUEST_ABORTED.
- */
- return status;
+ if (!have_andx_command((char *)state->inbuf, wct_ofs)) {
+
+ if ((cmd == SMBsesssetupX)
+ && NT_STATUS_EQUAL(
+ status, NT_STATUS_MORE_PROCESSING_REQUIRED)) {
+ /*
+ * NT_STATUS_MORE_PROCESSING_REQUIRED is a
+ * valid return code for session setup
+ */
+ goto no_err;
+ }
+
+ if (NT_STATUS_IS_ERR(status)) {
+ /*
+ * The last command takes the error code. All
+ * further commands down the requested chain
+ * will get a NT_STATUS_REQUEST_ABORTED.
+ */
+ return status;
+ }
}
+no_err:
+
wct = CVAL(state->inbuf, wct_ofs);
bytes_offset = wct_ofs + 1 + wct * sizeof(uint16_t);
num_bytes = SVAL(state->inbuf, bytes_offset);
if (pbytes != NULL) {
*pbytes = (uint8_t *)state->inbuf + bytes_offset + 2;
}
+ if ((mem_ctx != NULL) && (pinbuf != NULL)) {
+ if (state->chain_num == state->chain_length-1) {
+ *pinbuf = talloc_move(mem_ctx, &state->inbuf);
+ } else {
+ *pinbuf = state->inbuf;
+ }
+ }
- return NT_STATUS_OK;
+ return status;
}
size_t cli_smb_wct_ofs(struct tevent_req **reqs, int num_reqs)
uint16_t *vwv;
uint32_t num_bytes;
uint8_t *bytes;
+ uint8_t *inbuf;
NTSTATUS status;
- status = cli_smb_recv(subreq, 8, &wct, &vwv, &num_bytes, &bytes);
+ status = cli_smb_recv(subreq, state, &inbuf, 8, &wct, &vwv,
+ &num_bytes, &bytes);
+ TALLOC_FREE(subreq);
if (!NT_STATUS_IS_OK(status)) {
- TALLOC_FREE(subreq);
tevent_req_nterror(req, status);
return;
}