2 Unix SMB/CIFS implementation.
6 Copyright (C) Jelmer Vernooij 2006
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
25 NTSTATUS cli_do_rpc_ndr(struct rpc_pipe_client *cli,
26 TALLOC_CTX *mem_ctx, int p_idx,
27 const struct ndr_interface_table *table,
28 uint32 opnum, void *r)
30 prs_struct q_ps, r_ps;
31 const struct ndr_interface_call *call;
32 struct ndr_pull *pull;
34 struct ndr_push *push;
37 SMB_ASSERT(cli->pipe_idx == p_idx);
38 SMB_ASSERT(table->num_calls > opnum);
40 call = &table->calls[opnum];
42 push = ndr_push_init_ctx(mem_ctx);
44 return NT_STATUS_NO_MEMORY;
47 status = call->ndr_push(push, NDR_IN, r);
48 if (!NT_STATUS_IS_OK(status)) {
52 blob = ndr_push_blob(push);
54 if (!prs_init_data_blob(&q_ps, &blob, mem_ctx)) {
55 return NT_STATUS_NO_MEMORY;
60 if (!prs_init( &r_ps, 0, mem_ctx, UNMARSHALL )) {
61 prs_mem_free( &q_ps );
62 return NT_STATUS_NO_MEMORY;
65 status = rpc_api_pipe_req(cli, opnum, &q_ps, &r_ps);
67 prs_mem_free( &q_ps );
69 if (!NT_STATUS_IS_OK(status)) {
70 prs_mem_free( &r_ps );
74 if (!prs_data_blob(&r_ps, &blob, mem_ctx)) {
75 prs_mem_free( &r_ps );
76 return NT_STATUS_NO_MEMORY;
79 prs_mem_free( &r_ps );
81 pull = ndr_pull_init_blob(&blob, mem_ctx);
83 return NT_STATUS_NO_MEMORY;
86 /* have the ndr parser alloc memory for us */
87 pull->flags |= LIBNDR_FLAG_REF_ALLOC;
88 status = call->ndr_pull(pull, NDR_OUT, r);
91 if (!NT_STATUS_IS_OK(status)) {