00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include "includes.h"
00024
00025
00026 NTSTATUS cli_do_rpc_ndr(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
00027 int p_idx, int opnum, void *data,
00028 ndr_pull_flags_fn_t pull_fn, ndr_push_flags_fn_t push_fn)
00029 {
00030 prs_struct q_ps, r_ps;
00031 struct ndr_pull *pull;
00032 DATA_BLOB blob;
00033 struct ndr_push *push;
00034 NTSTATUS status;
00035
00036 SMB_ASSERT(cli->pipe_idx == p_idx);
00037
00038 push = ndr_push_init_ctx(mem_ctx);
00039 if (!push) {
00040 return NT_STATUS_NO_MEMORY;
00041 }
00042
00043 status = push_fn(push, NDR_IN, data);
00044 if (!NT_STATUS_IS_OK(status)) {
00045 return status;
00046 }
00047
00048 blob = ndr_push_blob(push);
00049
00050 if (!prs_init_data_blob(&q_ps, &blob, mem_ctx)) {
00051 return NT_STATUS_NO_MEMORY;
00052 }
00053
00054 talloc_free(push);
00055
00056 if (!prs_init( &r_ps, 0, mem_ctx, UNMARSHALL )) {
00057 prs_mem_free( &q_ps );
00058 return NT_STATUS_NO_MEMORY;
00059 }
00060
00061 status = rpc_api_pipe_req(cli, opnum, &q_ps, &r_ps);
00062
00063 prs_mem_free( &q_ps );
00064
00065 if (!NT_STATUS_IS_OK(status)) {
00066 prs_mem_free( &r_ps );
00067 return status;
00068 }
00069
00070 if (!prs_data_blob(&r_ps, &blob, mem_ctx)) {
00071 prs_mem_free( &r_ps );
00072 return NT_STATUS_NO_MEMORY;
00073 }
00074
00075 prs_mem_free( &r_ps );
00076
00077 pull = ndr_pull_init_blob(&blob, mem_ctx);
00078 if (pull == NULL) {
00079 return NT_STATUS_NO_MEMORY;
00080 }
00081
00082
00083 pull->flags |= LIBNDR_FLAG_REF_ALLOC;
00084 status = pull_fn(pull, NDR_OUT, data);
00085 talloc_free(pull);
00086
00087 if (!NT_STATUS_IS_OK(status)) {
00088 return status;
00089 }
00090
00091 return NT_STATUS_OK;
00092 }