struct tevent_req *cli_trans_send( TALLOC_CTX *mem_ctx, struct tevent_context *ev, struct cli_state *cli, uint8_t cmd, const char *pipe_name, uint16_t fid, uint16_t function, int flags, uint16_t *setup, uint8_t num_setup, uint8_t max_setup, uint8_t *param, uint32_t num_param, uint32_t max_param, uint8_t *data, uint32_t num_data, uint32_t max_data) { struct cli_trans_state *state; uint8_t additional_flags = 0; uint8_t clear_flags = 0; uint16_t additional_flags2 = 0; uint16_t clear_flags2 = 0; state = talloc_zero(mem_ctx, struct cli_trans_state); if (state == NULL) { return NULL; } state->cli = cli; state->ptr = talloc(state, struct cli_trans_state *); if (state->ptr == NULL) { talloc_free(state); return NULL; } *state->ptr = state; state->req = smb1cli_trans_send(state, ev, cli->conn, cmd, additional_flags, clear_flags, additional_flags2, clear_flags2, cli->timeout, cli->smb1.pid, cli->smb1.tcon, cli->smb1.session, pipe_name, fid, function, flags, setup, num_setup, max_setup, param, num_param, max_param, data, num_data, max_data); if (state->req == NULL) { talloc_free(state); return NULL; } talloc_reparent(state, state->req, state->ptr); talloc_set_destructor(state, cli_trans_state_destructor); talloc_set_destructor(state->ptr, cli_trans_state_ptr_destructor); return state->req; }
NTSTATUS smb1cli_trans(TALLOC_CTX *mem_ctx, struct smbXcli_conn *conn, uint8_t trans_cmd, uint8_t additional_flags, uint8_t clear_flags, uint16_t additional_flags2, uint16_t clear_flags2, uint32_t timeout_msec, uint32_t pid, uint16_t tid, uint16_t uid, const char *pipe_name, uint16_t fid, uint16_t function, int flags, uint16_t *setup, uint8_t num_setup, uint8_t max_setup, uint8_t *param, uint32_t num_param, uint32_t max_param, uint8_t *data, uint32_t num_data, uint32_t max_data, uint16_t *recv_flags2, uint16_t **rsetup, uint8_t min_rsetup, uint8_t *num_rsetup, uint8_t **rparam, uint32_t min_rparam, uint32_t *num_rparam, uint8_t **rdata, uint32_t min_rdata, uint32_t *num_rdata) { TALLOC_CTX *frame = talloc_stackframe(); struct tevent_context *ev; struct tevent_req *req; NTSTATUS status = NT_STATUS_OK; if (smbXcli_conn_has_async_calls(conn)) { /* * Can't use sync call while an async call is in flight */ status = NT_STATUS_INVALID_PARAMETER_MIX; goto fail; } ev = tevent_context_init(frame); if (ev == NULL) { status = NT_STATUS_NO_MEMORY; goto fail; } req = smb1cli_trans_send(frame, ev, conn, trans_cmd, additional_flags, clear_flags, additional_flags2, clear_flags2, timeout_msec, pid, tid, uid, pipe_name, fid, function, flags, setup, num_setup, max_setup, param, num_param, max_param, data, num_data, max_data); if (req == NULL) { status = NT_STATUS_NO_MEMORY; goto fail; } if (!tevent_req_poll(req, ev)) { status = map_nt_error_from_unix_common(errno); goto fail; } status = smb1cli_trans_recv(req, mem_ctx, recv_flags2, rsetup, min_rsetup, num_rsetup, rparam, min_rparam, num_rparam, rdata, min_rdata, num_rdata); fail: TALLOC_FREE(frame); return status; }