r18469: Use new pidl-generated DFS client code.
[Samba/gebeck_regimport.git] / source / include / rpc_client.h
blob407d5d97a7d2c238df682a1c8263610055445e6c
1 /*
2 Unix SMB/CIFS implementation.
3 SMB parameters and setup
4 Copyright (C) Gerald (Jerry) Carter 2005.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 #ifndef _RPC_CLIENT_H
22 #define _RPC_CLIENT_H
24 /* autogenerated client stubs */
26 #include "librpc/gen_ndr/cli_unixinfo.h"
27 #include "librpc/gen_ndr/cli_dfs.h"
28 #include "librpc/gen_ndr/cli_lsa.h"
30 /* macro to expand cookie-cutter code in cli_xxx() using rpc_api_pipe_req() */
32 #define CLI_DO_RPC_INTERNAL( pcli, ctx, p_idx, opnum, q_in, r_out, \
33 q_ps, r_ps, q_io_fn, r_io_fn, default_error, copy_sess_key ) \
35 SMB_ASSERT(pcli->pipe_idx == p_idx); \
36 if (!prs_init( &q_ps, RPC_MAX_PDU_FRAG_LEN, ctx, MARSHALL )) { \
37 return NT_STATUS_NO_MEMORY;\
39 if (!prs_init( &r_ps, 0, ctx, UNMARSHALL )) {\
40 prs_mem_free( &q_ps );\
41 return NT_STATUS_NO_MEMORY;\
43 if ( copy_sess_key) prs_set_session_key(&q_ps, (const char *)pcli->dc->sess_key);\
44 if ( q_io_fn("", &q_in, &q_ps, 0) ) {\
45 NTSTATUS _smb_pipe_stat_ = rpc_api_pipe_req(pcli, opnum, &q_ps, &r_ps); \
46 if (!NT_STATUS_IS_OK(_smb_pipe_stat_)) {\
47 prs_mem_free( &q_ps );\
48 prs_mem_free( &r_ps );\
49 return _smb_pipe_stat_;\
51 if ( copy_sess_key ) prs_set_session_key(&r_ps, (const char *)pcli->dc->sess_key);\
52 if (!r_io_fn("", &r_out, &r_ps, 0)) {\
53 prs_mem_free( &q_ps );\
54 prs_mem_free( &r_ps );\
55 return default_error;\
57 } else {\
58 prs_mem_free( &q_ps );\
59 prs_mem_free( &r_ps );\
60 return default_error;\
62 prs_mem_free( &q_ps );\
63 prs_mem_free( &r_ps );\
66 #define CLI_DO_RPC_COPY_SESS_KEY( pcli, ctx, p_idx, opnum, q_in, r_out, \
67 q_ps, r_ps, q_io_fn, r_io_fn, default_error ) \
69 CLI_DO_RPC_INTERNAL( pcli, ctx, p_idx, opnum, q_in, r_out, \
70 q_ps, r_ps, q_io_fn, r_io_fn, default_error, True ); \
73 #define CLI_DO_RPC( pcli, ctx, p_idx, opnum, q_in, r_out, \
74 q_ps, r_ps, q_io_fn, r_io_fn, default_error ) \
76 CLI_DO_RPC_INTERNAL( pcli, ctx, p_idx, opnum, q_in, r_out, \
77 q_ps, r_ps, q_io_fn, r_io_fn, default_error, False ); \
81 /* Arrrgg. Same but with WERRORS. Needed for registry code. */
83 #define CLI_DO_RPC_WERR( pcli, ctx, p_idx, opnum, q_in, r_out, \
84 q_ps, r_ps, q_io_fn, r_io_fn, default_error ) \
86 SMB_ASSERT(pcli->pipe_idx == p_idx); \
87 if (!prs_init( &q_ps, RPC_MAX_PDU_FRAG_LEN, ctx, MARSHALL )) { \
88 return WERR_NOMEM;\
90 if (!prs_init( &r_ps, 0, ctx, UNMARSHALL )) {\
91 prs_mem_free( &q_ps );\
92 return WERR_NOMEM;\
94 if ( q_io_fn("", &q_in, &q_ps, 0) ) {\
95 NTSTATUS _smb_pipe_stat_ = rpc_api_pipe_req(pcli, opnum, &q_ps, &r_ps); \
96 if (!NT_STATUS_IS_OK(_smb_pipe_stat_)) {\
97 prs_mem_free( &q_ps );\
98 prs_mem_free( &r_ps );\
99 return ntstatus_to_werror(_smb_pipe_stat_);\
101 if (!r_io_fn("", &r_out, &r_ps, 0)) {\
102 prs_mem_free( &q_ps );\
103 prs_mem_free( &r_ps );\
104 return default_error;\
106 } else {\
107 prs_mem_free( &q_ps );\
108 prs_mem_free( &r_ps );\
109 return default_error;\
111 prs_mem_free( &q_ps );\
112 prs_mem_free( &r_ps );\
115 #endif /* _RPC_CLIENT_H */