2 Unix SMB/CIFS implementation.
4 DCERPC client side interface structures
6 Copyright (C) Tim Potter 2003
7 Copyright (C) Andrew Tridgell 2003-2005
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 3 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program. If not, see <http://www.gnu.org/licenses/>.
23 /* This is a public header file that is installed as part of Samba.
24 * If you remove any functions or change their signature, update
25 * the so version number. */
27 #ifndef __S4_DCERPC_H__
28 #define __S4_DCERPC_H__
30 #include "../lib/util/data_blob.h"
31 #include "librpc/gen_ndr/dcerpc.h"
32 #include "../librpc/ndr/libndr.h"
33 #include "../librpc/rpc/rpc_common.h"
35 #ifdef SOURCE4_LIBRPC_INTERNALS
36 #define SOURCE4_LIBRPC_INTERNALS_BEGIN
37 #define SOURCE4_LIBRPC_INTERNALS_END
38 #else /* SOURCE4_LIBRPC_INTERNALS */
39 #define SOURCE4_LIBRPC_INTERNALS_BEGIN struct {
40 #define SOURCE4_LIBRPC_INTERNALS_END } internal;
41 #endif /* not SOURCE4_LIBRPC_INTERNALS */
43 struct tevent_context
;
45 struct dcerpc_binding_handle
;
46 struct tstream_context
;
47 struct ndr_interface_table
;
48 struct resolve_context
;
51 this defines a generic security context for signed/sealed dcerpc pipes.
53 struct dcecli_connection
;
54 struct gensec_settings
;
55 struct cli_credentials
;
56 struct dcecli_security
{
57 SOURCE4_LIBRPC_INTERNALS_BEGIN
59 enum dcerpc_AuthType auth_type
;
60 enum dcerpc_AuthLevel auth_level
;
61 uint32_t auth_context_id
;
63 struct dcerpc_auth
*out
;
64 struct dcerpc_auth
*in
;
67 struct gensec_security
*generic_state
;
69 /* get the session key */
70 NTSTATUS (*session_key
)(struct dcecli_connection
*, DATA_BLOB
*);
72 bool verified_bitmask1
;
74 SOURCE4_LIBRPC_INTERNALS_END
78 this holds the information that is not specific to a particular rpc context_id
81 struct dcecli_connection
{
82 SOURCE4_LIBRPC_INTERNALS_BEGIN
85 uint32_t srv_max_xmit_frag
;
86 uint32_t srv_max_recv_frag
;
88 struct dcecli_security security_state
;
89 struct tevent_context
*event_ctx
;
91 struct tevent_immediate
*io_trigger
;
92 bool io_trigger_pending
;
94 /** Directory in which to save ndrdump-parseable files */
95 const char *packet_log_dir
;
100 struct dcerpc_transport
{
101 enum dcerpc_transport_t transport
;
105 struct tstream_context
*stream
;
106 /** to serialize write events */
107 struct tevent_queue
*write_queue
;
108 /** the current active read request if any */
109 struct tevent_req
*read_subreq
;
110 /** number of read requests other than the current active */
111 uint32_t pending_reads
;
114 const char *server_name
;
116 /* Requests that have been sent, waiting for a reply */
117 struct rpc_request
*pending
;
119 /* Sync requests waiting to be shipped */
120 struct rpc_request
*request_queue
;
122 /* the next context_id to be assigned */
123 uint32_t next_context_id
;
125 /* The maximum total payload of reassembled response pdus */
126 size_t max_total_response_size
;
128 /* the negotiated bind time features */
129 uint16_t bind_time_features
;
131 SOURCE4_LIBRPC_INTERNALS_END
135 this encapsulates a full dcerpc client side pipe
138 struct dcerpc_binding_handle
*binding_handle
;
140 SOURCE4_LIBRPC_INTERNALS_BEGIN
145 struct ndr_syntax_id syntax
;
146 struct ndr_syntax_id transfer_syntax
;
148 struct dcecli_connection
*conn
;
149 const struct dcerpc_binding
*binding
;
151 /** the last fault code from a DCERPC fault */
152 uint32_t last_fault_code
;
154 /** timeout for individual rpc requests, in seconds */
155 uint32_t request_timeout
;
158 * Set for the timeout in dcerpc_pipe_connect_b_send(), to
159 * allow the timeout not to destroy the stack during a nested
160 * event loop caused by gensec_update()
162 bool inhibit_timeout_processing
;
165 bool verified_pcontext
;
167 SOURCE4_LIBRPC_INTERNALS_END
170 /* default timeout for all rpc requests, in seconds */
171 #define DCERPC_REQUEST_TIMEOUT 60
179 struct smbXcli_session
;
181 struct roh_connection
;
182 struct tstream_tls_params
;
183 struct socket_address
;
185 NTSTATUS
dcerpc_pipe_connect(TALLOC_CTX
*parent_ctx
,
186 struct dcerpc_pipe
**pp
,
188 const struct ndr_interface_table
*table
,
189 struct cli_credentials
*credentials
,
190 struct tevent_context
*ev
,
191 struct loadparm_context
*lp_ctx
);
192 const char *dcerpc_server_name(struct dcerpc_pipe
*p
);
193 struct dcerpc_pipe
*dcerpc_pipe_init(TALLOC_CTX
*mem_ctx
, struct tevent_context
*ev
);
194 NTSTATUS
dcerpc_pipe_open_smb(struct dcerpc_pipe
*p
,
195 struct smbcli_tree
*tree
,
196 const char *pipe_name
);
197 NTSTATUS
dcerpc_pipe_open_smb2(struct dcerpc_pipe
*p
,
198 struct smb2_tree
*tree
,
199 const char *pipe_name
);
200 NTSTATUS
dcerpc_bind_auth_none(struct dcerpc_pipe
*p
,
201 const struct ndr_interface_table
*table
);
202 struct composite_context
;
203 NTSTATUS
dcerpc_secondary_connection_recv(struct composite_context
*c
,
204 struct dcerpc_pipe
**p2
);
206 struct composite_context
* dcerpc_pipe_connect_b_send(TALLOC_CTX
*parent_ctx
,
207 const struct dcerpc_binding
*binding
,
208 const struct ndr_interface_table
*table
,
209 struct cli_credentials
*credentials
,
210 struct tevent_context
*ev
,
211 struct loadparm_context
*lp_ctx
);
213 NTSTATUS
dcerpc_pipe_connect_b_recv(struct composite_context
*c
, TALLOC_CTX
*mem_ctx
,
214 struct dcerpc_pipe
**p
);
216 NTSTATUS
dcerpc_pipe_connect_b(TALLOC_CTX
*parent_ctx
,
217 struct dcerpc_pipe
**pp
,
218 const struct dcerpc_binding
*binding
,
219 const struct ndr_interface_table
*table
,
220 struct cli_credentials
*credentials
,
221 struct tevent_context
*ev
,
222 struct loadparm_context
*lp_ctx
);
224 NTSTATUS
dcerpc_pipe_auth(TALLOC_CTX
*mem_ctx
,
225 struct dcerpc_pipe
**p
,
226 const struct dcerpc_binding
*binding
,
227 const struct ndr_interface_table
*table
,
228 struct cli_credentials
*credentials
,
229 struct loadparm_context
*lp_ctx
);
230 NTSTATUS
dcerpc_init(void);
231 struct composite_context
*dcerpc_secondary_smb_send(struct dcecli_connection
*c1
,
232 struct dcecli_connection
*c2
,
233 const char *pipe_name
);
234 NTSTATUS
dcerpc_secondary_smb_recv(struct composite_context
*c
);
235 NTSTATUS
dcerpc_secondary_context(struct dcerpc_pipe
*p
,
236 struct dcerpc_pipe
**pp2
,
237 const struct ndr_interface_table
*table
);
238 NTSTATUS
dcerpc_alter_context(struct dcerpc_pipe
*p
,
240 const struct ndr_syntax_id
*syntax
,
241 const struct ndr_syntax_id
*transfer_syntax
);
243 NTSTATUS
dcerpc_bind_auth(struct dcerpc_pipe
*p
,
244 const struct ndr_interface_table
*table
,
245 struct cli_credentials
*credentials
,
246 struct gensec_settings
*gensec_settings
,
247 uint8_t auth_type
, uint8_t auth_level
,
248 const char *service
);
249 struct composite_context
* dcerpc_pipe_connect_send(TALLOC_CTX
*parent_ctx
,
251 const struct ndr_interface_table
*table
,
252 struct cli_credentials
*credentials
,
253 struct tevent_context
*ev
, struct loadparm_context
*lp_ctx
);
254 NTSTATUS
dcerpc_pipe_connect_recv(struct composite_context
*c
,
256 struct dcerpc_pipe
**pp
);
258 NTSTATUS
dcerpc_epm_map_binding(TALLOC_CTX
*mem_ctx
, struct dcerpc_binding
*binding
,
259 const struct ndr_interface_table
*table
, struct tevent_context
*ev
,
260 struct loadparm_context
*lp_ctx
);
261 struct composite_context
* dcerpc_secondary_auth_connection_send(struct dcerpc_pipe
*p
,
262 const struct dcerpc_binding
*binding
,
263 const struct ndr_interface_table
*table
,
264 struct cli_credentials
*credentials
,
265 struct loadparm_context
*lp_ctx
);
266 NTSTATUS
dcerpc_secondary_auth_connection_recv(struct composite_context
*c
,
268 struct dcerpc_pipe
**p
);
269 NTSTATUS
dcerpc_secondary_auth_connection(struct dcerpc_pipe
*p
,
270 const struct dcerpc_binding
*binding
,
271 const struct ndr_interface_table
*table
,
272 struct cli_credentials
*credentials
,
273 struct loadparm_context
*lp_ctx
,
275 struct dcerpc_pipe
**p2
);
277 struct composite_context
* dcerpc_secondary_connection_send(struct dcerpc_pipe
*p
,
278 const struct dcerpc_binding
*b
);
280 #endif /* __S4_DCERPC_H__ */