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 struct dcerpc_auth
*auth_info
;
50 struct gensec_security
*generic_state
;
52 /* get the session key */
53 NTSTATUS (*session_key
)(struct dcecli_connection
*, DATA_BLOB
*);
57 this holds the information that is not specific to a particular rpc context_id
60 struct dcecli_connection
{
62 uint32_t srv_max_xmit_frag
;
63 uint32_t srv_max_recv_frag
;
65 struct dcecli_security security_state
;
66 struct tevent_context
*event_ctx
;
68 struct tevent_immediate
*io_trigger
;
69 bool io_trigger_pending
;
71 /** Directory in which to save ndrdump-parseable files */
72 const char *packet_log_dir
;
77 struct dcerpc_transport
{
78 enum dcerpc_transport_t transport
;
81 struct tstream_context
*stream
;
82 /** to serialize write events */
83 struct tevent_queue
*write_queue
;
84 /** the current active read request if any */
85 struct tevent_req
*read_subreq
;
86 /** number of read requests other than the current active */
87 uint32_t pending_reads
;
90 const char *server_name
;
92 /* Requests that have been sent, waiting for a reply */
93 struct rpc_request
*pending
;
95 /* Sync requests waiting to be shipped */
96 struct rpc_request
*request_queue
;
98 /* the next context_id to be assigned */
99 uint32_t next_context_id
;
103 this encapsulates a full dcerpc client side pipe
106 struct dcerpc_binding_handle
*binding_handle
;
110 struct ndr_syntax_id syntax
;
111 struct ndr_syntax_id transfer_syntax
;
113 struct dcecli_connection
*conn
;
114 const struct dcerpc_binding
*binding
;
116 /** the last fault code from a DCERPC fault */
117 uint32_t last_fault_code
;
119 /** timeout for individual rpc requests, in seconds */
120 uint32_t request_timeout
;
123 * Set for the timeout in dcerpc_pipe_connect_b_send(), to
124 * allow the timeout not to destory the stack during a nested
125 * event loop caused by gensec_update()
127 bool inhibit_timeout_processing
;
131 /* default timeout for all rpc requests, in seconds */
132 #define DCERPC_REQUEST_TIMEOUT 60
140 struct smbXcli_session
;
142 struct roh_connection
;
143 struct tstream_tls_params
;
144 struct socket_address
;
146 NTSTATUS
dcerpc_pipe_connect(TALLOC_CTX
*parent_ctx
,
147 struct dcerpc_pipe
**pp
,
149 const struct ndr_interface_table
*table
,
150 struct cli_credentials
*credentials
,
151 struct tevent_context
*ev
,
152 struct loadparm_context
*lp_ctx
);
153 const char *dcerpc_server_name(struct dcerpc_pipe
*p
);
154 struct dcerpc_pipe
*dcerpc_pipe_init(TALLOC_CTX
*mem_ctx
, struct tevent_context
*ev
);
155 NTSTATUS
dcerpc_pipe_open_smb(struct dcerpc_pipe
*p
,
156 struct smbcli_tree
*tree
,
157 const char *pipe_name
);
158 NTSTATUS
dcerpc_pipe_open_smb2(struct dcerpc_pipe
*p
,
159 struct smb2_tree
*tree
,
160 const char *pipe_name
);
161 NTSTATUS
dcerpc_bind_auth_none(struct dcerpc_pipe
*p
,
162 const struct ndr_interface_table
*table
);
163 NTSTATUS
dcerpc_fetch_session_key(struct dcerpc_pipe
*p
,
164 DATA_BLOB
*session_key
);
165 struct composite_context
;
166 NTSTATUS
dcerpc_secondary_connection_recv(struct composite_context
*c
,
167 struct dcerpc_pipe
**p2
);
169 struct composite_context
* dcerpc_pipe_connect_b_send(TALLOC_CTX
*parent_ctx
,
170 const struct dcerpc_binding
*binding
,
171 const struct ndr_interface_table
*table
,
172 struct cli_credentials
*credentials
,
173 struct tevent_context
*ev
,
174 struct loadparm_context
*lp_ctx
);
176 NTSTATUS
dcerpc_pipe_connect_b_recv(struct composite_context
*c
, TALLOC_CTX
*mem_ctx
,
177 struct dcerpc_pipe
**p
);
179 NTSTATUS
dcerpc_pipe_connect_b(TALLOC_CTX
*parent_ctx
,
180 struct dcerpc_pipe
**pp
,
181 const struct dcerpc_binding
*binding
,
182 const struct ndr_interface_table
*table
,
183 struct cli_credentials
*credentials
,
184 struct tevent_context
*ev
,
185 struct loadparm_context
*lp_ctx
);
187 NTSTATUS
dcerpc_pipe_auth(TALLOC_CTX
*mem_ctx
,
188 struct dcerpc_pipe
**p
,
189 const struct dcerpc_binding
*binding
,
190 const struct ndr_interface_table
*table
,
191 struct cli_credentials
*credentials
,
192 struct loadparm_context
*lp_ctx
);
193 NTSTATUS
dcerpc_secondary_connection(struct dcerpc_pipe
*p
,
194 struct dcerpc_pipe
**p2
,
195 const struct dcerpc_binding
*b
);
196 NTSTATUS
dcerpc_bind_auth_schannel(TALLOC_CTX
*tmp_ctx
,
197 struct dcerpc_pipe
*p
,
198 const struct ndr_interface_table
*table
,
199 struct cli_credentials
*credentials
,
200 struct loadparm_context
*lp_ctx
,
202 NTSTATUS
dcerpc_init(void);
203 struct composite_context
*dcerpc_secondary_smb_send(struct dcecli_connection
*c1
,
204 struct dcecli_connection
*c2
,
205 const char *pipe_name
);
206 NTSTATUS
dcerpc_secondary_smb_recv(struct composite_context
*c
);
207 NTSTATUS
dcerpc_secondary_context(struct dcerpc_pipe
*p
,
208 struct dcerpc_pipe
**pp2
,
209 const struct ndr_interface_table
*table
);
210 NTSTATUS
dcerpc_alter_context(struct dcerpc_pipe
*p
,
212 const struct ndr_syntax_id
*syntax
,
213 const struct ndr_syntax_id
*transfer_syntax
);
215 NTSTATUS
dcerpc_bind_auth(struct dcerpc_pipe
*p
,
216 const struct ndr_interface_table
*table
,
217 struct cli_credentials
*credentials
,
218 struct gensec_settings
*gensec_settings
,
219 uint8_t auth_type
, uint8_t auth_level
,
220 const char *service
);
221 struct composite_context
* dcerpc_pipe_connect_send(TALLOC_CTX
*parent_ctx
,
223 const struct ndr_interface_table
*table
,
224 struct cli_credentials
*credentials
,
225 struct tevent_context
*ev
, struct loadparm_context
*lp_ctx
);
226 NTSTATUS
dcerpc_pipe_connect_recv(struct composite_context
*c
,
228 struct dcerpc_pipe
**pp
);
230 NTSTATUS
dcerpc_epm_map_binding(TALLOC_CTX
*mem_ctx
, struct dcerpc_binding
*binding
,
231 const struct ndr_interface_table
*table
, struct tevent_context
*ev
,
232 struct loadparm_context
*lp_ctx
);
233 struct composite_context
* dcerpc_secondary_auth_connection_send(struct dcerpc_pipe
*p
,
234 const struct dcerpc_binding
*binding
,
235 const struct ndr_interface_table
*table
,
236 struct cli_credentials
*credentials
,
237 struct loadparm_context
*lp_ctx
);
238 NTSTATUS
dcerpc_secondary_auth_connection_recv(struct composite_context
*c
,
240 struct dcerpc_pipe
**p
);
241 NTSTATUS
dcerpc_secondary_auth_connection(struct dcerpc_pipe
*p
,
242 const struct dcerpc_binding
*binding
,
243 const struct ndr_interface_table
*table
,
244 struct cli_credentials
*credentials
,
245 struct loadparm_context
*lp_ctx
,
247 struct dcerpc_pipe
**p2
);
249 struct composite_context
* dcerpc_secondary_connection_send(struct dcerpc_pipe
*p
,
250 const struct dcerpc_binding
*b
);
251 void dcerpc_log_packet(const char *lockdir
,
252 const struct ndr_interface_table
*ndr
,
253 uint32_t opnum
, uint32_t flags
,
254 const DATA_BLOB
*pkt
);
256 #endif /* __S4_DCERPC_H__ */