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 struct tevent_context
;
37 struct dcerpc_binding_handle
;
38 struct tstream_context
;
39 struct ndr_interface_table
;
40 struct resolve_context
;
43 this defines a generic security context for signed/sealed dcerpc pipes.
45 struct dcecli_connection
;
46 struct gensec_settings
;
47 struct cli_credentials
;
48 struct dcecli_security
{
49 enum dcerpc_AuthType auth_type
;
50 enum dcerpc_AuthLevel auth_level
;
51 uint32_t auth_context_id
;
53 struct dcerpc_auth
*out
;
54 struct dcerpc_auth
*in
;
57 struct gensec_security
*generic_state
;
59 /* get the session key */
60 NTSTATUS (*session_key
)(struct dcecli_connection
*, DATA_BLOB
*);
62 bool verified_bitmask1
;
67 this holds the information that is not specific to a particular rpc context_id
70 struct dcecli_connection
{
72 uint32_t srv_max_xmit_frag
;
73 uint32_t srv_max_recv_frag
;
75 struct dcecli_security security_state
;
76 struct tevent_context
*event_ctx
;
78 struct tevent_immediate
*io_trigger
;
79 bool io_trigger_pending
;
81 /** Directory in which to save ndrdump-parseable files */
82 const char *packet_log_dir
;
87 struct dcerpc_transport
{
88 enum dcerpc_transport_t transport
;
92 struct tstream_context
*stream
;
93 /** to serialize write events */
94 struct tevent_queue
*write_queue
;
95 /** the current active read request if any */
96 struct tevent_req
*read_subreq
;
97 /** number of read requests other than the current active */
98 uint32_t pending_reads
;
101 const char *server_name
;
103 /* Requests that have been sent, waiting for a reply */
104 struct rpc_request
*pending
;
106 /* Sync requests waiting to be shipped */
107 struct rpc_request
*request_queue
;
109 /* the next context_id to be assigned */
110 uint32_t next_context_id
;
112 /* The maximum total payload of reassembled response pdus */
113 size_t max_total_response_size
;
115 /* the negotiated bind time features */
116 uint16_t bind_time_features
;
120 this encapsulates a full dcerpc client side pipe
123 struct dcerpc_binding_handle
*binding_handle
;
128 struct ndr_syntax_id syntax
;
129 struct ndr_syntax_id transfer_syntax
;
131 struct dcecli_connection
*conn
;
132 const struct dcerpc_binding
*binding
;
134 /** the last fault code from a DCERPC fault */
135 uint32_t last_fault_code
;
137 /** timeout for individual rpc requests, in seconds */
138 uint32_t request_timeout
;
141 * Set for the timeout in dcerpc_pipe_connect_b_send(), to
142 * allow the timeout not to destroy the stack during a nested
143 * event loop caused by gensec_update()
145 bool inhibit_timeout_processing
;
148 bool verified_pcontext
;
151 /* default timeout for all rpc requests, in seconds */
152 #define DCERPC_REQUEST_TIMEOUT 60
160 struct smbXcli_session
;
162 struct roh_connection
;
163 struct tstream_tls_params
;
164 struct socket_address
;
166 NTSTATUS
dcerpc_pipe_connect(TALLOC_CTX
*parent_ctx
,
167 struct dcerpc_pipe
**pp
,
169 const struct ndr_interface_table
*table
,
170 struct cli_credentials
*credentials
,
171 struct tevent_context
*ev
,
172 struct loadparm_context
*lp_ctx
);
173 const char *dcerpc_server_name(struct dcerpc_pipe
*p
);
174 struct dcerpc_pipe
*dcerpc_pipe_init(TALLOC_CTX
*mem_ctx
, struct tevent_context
*ev
);
175 NTSTATUS
dcerpc_pipe_open_smb(struct dcerpc_pipe
*p
,
176 struct smbcli_tree
*tree
,
177 const char *pipe_name
);
178 NTSTATUS
dcerpc_pipe_open_smb2(struct dcerpc_pipe
*p
,
179 struct smb2_tree
*tree
,
180 const char *pipe_name
);
181 NTSTATUS
dcerpc_bind_auth_none(struct dcerpc_pipe
*p
,
182 const struct ndr_interface_table
*table
);
183 NTSTATUS
dcerpc_fetch_session_key(struct dcerpc_pipe
*p
,
184 DATA_BLOB
*session_key
);
185 bool dcerpc_transport_encrypted(struct dcerpc_pipe
*p
);
186 struct composite_context
;
187 NTSTATUS
dcerpc_secondary_connection_recv(struct composite_context
*c
,
188 struct dcerpc_pipe
**p2
);
190 struct composite_context
* dcerpc_pipe_connect_b_send(TALLOC_CTX
*parent_ctx
,
191 const struct dcerpc_binding
*binding
,
192 const struct ndr_interface_table
*table
,
193 struct cli_credentials
*credentials
,
194 struct tevent_context
*ev
,
195 struct loadparm_context
*lp_ctx
);
197 NTSTATUS
dcerpc_pipe_connect_b_recv(struct composite_context
*c
, TALLOC_CTX
*mem_ctx
,
198 struct dcerpc_pipe
**p
);
200 NTSTATUS
dcerpc_pipe_connect_b(TALLOC_CTX
*parent_ctx
,
201 struct dcerpc_pipe
**pp
,
202 const struct dcerpc_binding
*binding
,
203 const struct ndr_interface_table
*table
,
204 struct cli_credentials
*credentials
,
205 struct tevent_context
*ev
,
206 struct loadparm_context
*lp_ctx
);
208 NTSTATUS
dcerpc_pipe_auth(TALLOC_CTX
*mem_ctx
,
209 struct dcerpc_pipe
**p
,
210 const struct dcerpc_binding
*binding
,
211 const struct ndr_interface_table
*table
,
212 struct cli_credentials
*credentials
,
213 struct loadparm_context
*lp_ctx
);
214 NTSTATUS
dcerpc_init(void);
215 struct composite_context
*dcerpc_secondary_smb_send(struct dcecli_connection
*c1
,
216 struct dcecli_connection
*c2
,
217 const char *pipe_name
);
218 NTSTATUS
dcerpc_secondary_smb_recv(struct composite_context
*c
);
219 NTSTATUS
dcerpc_secondary_context(struct dcerpc_pipe
*p
,
220 struct dcerpc_pipe
**pp2
,
221 const struct ndr_interface_table
*table
);
222 NTSTATUS
dcerpc_alter_context(struct dcerpc_pipe
*p
,
224 const struct ndr_syntax_id
*syntax
,
225 const struct ndr_syntax_id
*transfer_syntax
);
227 NTSTATUS
dcerpc_bind_auth(struct dcerpc_pipe
*p
,
228 const struct ndr_interface_table
*table
,
229 struct cli_credentials
*credentials
,
230 struct gensec_settings
*gensec_settings
,
231 uint8_t auth_type
, uint8_t auth_level
,
232 const char *service
);
233 struct composite_context
* dcerpc_pipe_connect_send(TALLOC_CTX
*parent_ctx
,
235 const struct ndr_interface_table
*table
,
236 struct cli_credentials
*credentials
,
237 struct tevent_context
*ev
, struct loadparm_context
*lp_ctx
);
238 NTSTATUS
dcerpc_pipe_connect_recv(struct composite_context
*c
,
240 struct dcerpc_pipe
**pp
);
242 NTSTATUS
dcerpc_epm_map_binding(TALLOC_CTX
*mem_ctx
, struct dcerpc_binding
*binding
,
243 const struct ndr_interface_table
*table
, struct tevent_context
*ev
,
244 struct loadparm_context
*lp_ctx
);
245 struct composite_context
* dcerpc_secondary_auth_connection_send(struct dcerpc_pipe
*p
,
246 const struct dcerpc_binding
*binding
,
247 const struct ndr_interface_table
*table
,
248 struct cli_credentials
*credentials
,
249 struct loadparm_context
*lp_ctx
);
250 NTSTATUS
dcerpc_secondary_auth_connection_recv(struct composite_context
*c
,
252 struct dcerpc_pipe
**p
);
253 NTSTATUS
dcerpc_secondary_auth_connection(struct dcerpc_pipe
*p
,
254 const struct dcerpc_binding
*binding
,
255 const struct ndr_interface_table
*table
,
256 struct cli_credentials
*credentials
,
257 struct loadparm_context
*lp_ctx
,
259 struct dcerpc_pipe
**p2
);
261 struct composite_context
* dcerpc_secondary_connection_send(struct dcerpc_pipe
*p
,
262 const struct dcerpc_binding
*b
);
264 #endif /* __S4_DCERPC_H__ */