s4:librpc: factor out xxx_shutdown_pipe() to dcerpc_shutdown_pipe()
[Samba.git] / source4 / librpc / rpc / dcerpc.h
blobcb78421cb2f9a5e22cca3e50244b009273f0b01a
1 /*
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;
36 struct tevent_req;
37 struct dcerpc_binding_handle;
38 struct tstream_context;
39 struct ndr_interface_table;
42 this defines a generic security context for signed/sealed dcerpc pipes.
44 struct dcecli_connection;
45 struct gensec_settings;
46 struct cli_credentials;
47 struct dcecli_security {
48 struct dcerpc_auth *auth_info;
49 struct gensec_security *generic_state;
51 /* get the session key */
52 NTSTATUS (*session_key)(struct dcecli_connection *, DATA_BLOB *);
56 this holds the information that is not specific to a particular rpc context_id
58 struct rpc_request;
59 struct dcecli_connection {
60 uint32_t call_id;
61 uint32_t srv_max_xmit_frag;
62 uint32_t srv_max_recv_frag;
63 uint32_t flags;
64 struct dcecli_security security_state;
65 const char *binding_string;
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;
74 bool dead;
75 bool free_skipped;
77 struct dcerpc_transport {
78 enum dcerpc_transport_t transport;
79 void *private_data;
81 /* send a request to the server */
82 NTSTATUS (*send_request)(struct dcecli_connection *, DATA_BLOB *, bool trigger_read);
84 /* send a read request to the server */
85 NTSTATUS (*send_read)(struct dcecli_connection *);
87 /* a callback to the dcerpc code when a full fragment
88 has been received */
89 void (*recv_data)(struct dcecli_connection *, DATA_BLOB *, NTSTATUS status);
91 struct tstream_context *stream;
92 /** to serialize write events */
93 struct tevent_queue *write_queue;
94 /** the current active read request if any */
95 struct tevent_req *read_subreq;
96 /** number of read requests other than the current active */
97 uint32_t pending_reads;
98 } transport;
100 const char *server_name;
102 /* Requests that have been sent, waiting for a reply */
103 struct rpc_request *pending;
105 /* Sync requests waiting to be shipped */
106 struct rpc_request *request_queue;
108 /* the next context_id to be assigned */
109 uint32_t next_context_id;
113 this encapsulates a full dcerpc client side pipe
115 struct dcerpc_pipe {
116 struct dcerpc_binding_handle *binding_handle;
118 uint32_t context_id;
120 uint32_t assoc_group_id;
122 struct ndr_syntax_id syntax;
123 struct ndr_syntax_id transfer_syntax;
125 struct dcecli_connection *conn;
126 struct dcerpc_binding *binding;
128 /** the last fault code from a DCERPC fault */
129 uint32_t last_fault_code;
131 /** timeout for individual rpc requests, in seconds */
132 uint32_t request_timeout;
135 * Set for the timeout in dcerpc_pipe_connect_b_send(), to
136 * allow the timeout not to destory the stack during a nested
137 * event loop caused by gensec_update()
139 bool inhibit_timeout_processing;
140 bool timed_out;
143 /* default timeout for all rpc requests, in seconds */
144 #define DCERPC_REQUEST_TIMEOUT 60
146 struct epm_tower;
147 struct epm_floor;
149 struct smbcli_tree;
150 struct smb2_tree;
151 struct smbXcli_conn;
152 struct smbXcli_session;
153 struct smbXcli_tcon;
154 struct socket_address;
156 NTSTATUS dcerpc_pipe_connect(TALLOC_CTX *parent_ctx,
157 struct dcerpc_pipe **pp,
158 const char *binding,
159 const struct ndr_interface_table *table,
160 struct cli_credentials *credentials,
161 struct tevent_context *ev,
162 struct loadparm_context *lp_ctx);
163 const char *dcerpc_server_name(struct dcerpc_pipe *p);
164 struct dcerpc_pipe *dcerpc_pipe_init(TALLOC_CTX *mem_ctx, struct tevent_context *ev);
165 NTSTATUS dcerpc_pipe_open_smb(struct dcerpc_pipe *p,
166 struct smbcli_tree *tree,
167 const char *pipe_name);
168 NTSTATUS dcerpc_pipe_open_smb2(struct dcerpc_pipe *p,
169 struct smb2_tree *tree,
170 const char *pipe_name);
171 NTSTATUS dcerpc_bind_auth_none(struct dcerpc_pipe *p,
172 const struct ndr_interface_table *table);
173 NTSTATUS dcerpc_fetch_session_key(struct dcerpc_pipe *p,
174 DATA_BLOB *session_key);
175 struct composite_context;
176 NTSTATUS dcerpc_secondary_connection_recv(struct composite_context *c,
177 struct dcerpc_pipe **p2);
179 struct composite_context* dcerpc_pipe_connect_b_send(TALLOC_CTX *parent_ctx,
180 struct dcerpc_binding *binding,
181 const struct ndr_interface_table *table,
182 struct cli_credentials *credentials,
183 struct tevent_context *ev,
184 struct loadparm_context *lp_ctx);
186 NTSTATUS dcerpc_pipe_connect_b_recv(struct composite_context *c, TALLOC_CTX *mem_ctx,
187 struct dcerpc_pipe **p);
189 NTSTATUS dcerpc_pipe_connect_b(TALLOC_CTX *parent_ctx,
190 struct dcerpc_pipe **pp,
191 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_auth(TALLOC_CTX *mem_ctx,
198 struct dcerpc_pipe **p,
199 struct dcerpc_binding *binding,
200 const struct ndr_interface_table *table,
201 struct cli_credentials *credentials,
202 struct loadparm_context *lp_ctx);
203 NTSTATUS dcerpc_secondary_connection(struct dcerpc_pipe *p,
204 struct dcerpc_pipe **p2,
205 struct dcerpc_binding *b);
206 NTSTATUS dcerpc_bind_auth_schannel(TALLOC_CTX *tmp_ctx,
207 struct dcerpc_pipe *p,
208 const struct ndr_interface_table *table,
209 struct cli_credentials *credentials,
210 struct loadparm_context *lp_ctx,
211 uint8_t auth_level);
212 struct tevent_context *dcerpc_event_context(struct dcerpc_pipe *p);
213 NTSTATUS dcerpc_init(void);
214 struct composite_context *dcerpc_secondary_smb_send(struct dcecli_connection *c1,
215 struct dcecli_connection *c2,
216 const char *pipe_name);
217 NTSTATUS dcerpc_secondary_smb_recv(struct composite_context *c);
218 NTSTATUS dcerpc_secondary_context(struct dcerpc_pipe *p,
219 struct dcerpc_pipe **pp2,
220 const struct ndr_interface_table *table);
221 NTSTATUS dcerpc_alter_context(struct dcerpc_pipe *p,
222 TALLOC_CTX *mem_ctx,
223 const struct ndr_syntax_id *syntax,
224 const struct ndr_syntax_id *transfer_syntax);
226 NTSTATUS dcerpc_bind_auth(struct dcerpc_pipe *p,
227 const struct ndr_interface_table *table,
228 struct cli_credentials *credentials,
229 struct gensec_settings *gensec_settings,
230 uint8_t auth_type, uint8_t auth_level,
231 const char *service);
232 struct composite_context* dcerpc_pipe_connect_send(TALLOC_CTX *parent_ctx,
233 const char *binding,
234 const struct ndr_interface_table *table,
235 struct cli_credentials *credentials,
236 struct tevent_context *ev, struct loadparm_context *lp_ctx);
237 NTSTATUS dcerpc_pipe_connect_recv(struct composite_context *c,
238 TALLOC_CTX *mem_ctx,
239 struct dcerpc_pipe **pp);
241 NTSTATUS dcerpc_epm_map_binding(TALLOC_CTX *mem_ctx, struct dcerpc_binding *binding,
242 const struct ndr_interface_table *table, struct tevent_context *ev,
243 struct loadparm_context *lp_ctx);
244 struct composite_context* dcerpc_secondary_auth_connection_send(struct dcerpc_pipe *p,
245 struct dcerpc_binding *binding,
246 const struct ndr_interface_table *table,
247 struct cli_credentials *credentials,
248 struct loadparm_context *lp_ctx);
249 NTSTATUS dcerpc_secondary_auth_connection_recv(struct composite_context *c,
250 TALLOC_CTX *mem_ctx,
251 struct dcerpc_pipe **p);
253 struct composite_context* dcerpc_secondary_connection_send(struct dcerpc_pipe *p,
254 struct dcerpc_binding *b);
255 void dcerpc_log_packet(const char *lockdir,
256 const struct ndr_interface_table *ndr,
257 uint32_t opnum, uint32_t flags,
258 const DATA_BLOB *pkt);
261 enum dcerpc_transport_t dcerpc_transport_by_endpoint_protocol(int prot);
263 const char *dcerpc_floor_get_rhs_data(TALLOC_CTX *mem_ctx, struct epm_floor *epm_floor);
265 #endif /* __S4_DCERPC_H__ */