rpc_client/ndr.c

説明を見る。
00001 /* 
00002    Unix SMB/CIFS implementation.
00003 
00004    libndr interface
00005 
00006    Copyright (C) Jelmer Vernooij 2006
00007    
00008    This program is free software; you can redistribute it and/or modify
00009    it under the terms of the GNU General Public License as published by
00010    the Free Software Foundation; either version 2 of the License, or
00011    (at your option) any later version.
00012    
00013    This program is distributed in the hope that it will be useful,
00014    but WITHOUT ANY WARRANTY; without even the implied warranty of
00015    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016    GNU General Public License for more details.
00017    
00018    You should have received a copy of the GNU General Public License
00019    along with this program; if not, write to the Free Software
00020    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
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         /* have the ndr parser alloc memory for us */
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 }

Sambaに対してSat Aug 29 21:23:04 2009に生成されました。  doxygen 1.4.7