s4.2/fsmo.py: fixed fsmo transfer exception
[Samba.git] / source4 / librpc / rpc / dcerpc.h
blobef830865e8bfc55604f75feac385b8f3228ea025
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;
41 this defines a generic security context for signed/sealed dcerpc pipes.
43 struct dcecli_connection;
44 struct gensec_settings;
45 struct dcecli_security {
46 struct dcerpc_auth *auth_info;
47 struct gensec_security *generic_state;
49 /* get the session key */
50 NTSTATUS (*session_key)(struct dcecli_connection *, DATA_BLOB *);
54 this holds the information that is not specific to a particular rpc context_id
56 struct rpc_request;
57 struct dcecli_connection {
58 uint32_t call_id;
59 uint32_t srv_max_xmit_frag;
60 uint32_t srv_max_recv_frag;
61 uint32_t flags;
62 struct dcecli_security security_state;
63 const char *binding_string;
64 struct tevent_context *event_ctx;
66 struct tevent_immediate *io_trigger;
67 bool io_trigger_pending;
69 /** Directory in which to save ndrdump-parseable files */
70 const char *packet_log_dir;
72 bool dead;
73 bool free_skipped;
75 struct dcerpc_transport {
76 enum dcerpc_transport_t transport;
77 void *private_data;
79 NTSTATUS (*shutdown_pipe)(struct dcecli_connection *, NTSTATUS status);
81 const char *(*peer_name)(struct dcecli_connection *);
83 const char *(*target_hostname)(struct dcecli_connection *);
85 /* send a request to the server */
86 NTSTATUS (*send_request)(struct dcecli_connection *, DATA_BLOB *, bool trigger_read);
88 /* send a read request to the server */
89 NTSTATUS (*send_read)(struct dcecli_connection *);
91 /* a callback to the dcerpc code when a full fragment
92 has been received */
93 void (*recv_data)(struct dcecli_connection *, DATA_BLOB *, NTSTATUS status);
94 } transport;
96 /* Requests that have been sent, waiting for a reply */
97 struct rpc_request *pending;
99 /* Sync requests waiting to be shipped */
100 struct rpc_request *request_queue;
102 /* the next context_id to be assigned */
103 uint32_t next_context_id;
107 this encapsulates a full dcerpc client side pipe
109 struct dcerpc_pipe {
110 struct dcerpc_binding_handle *binding_handle;
112 uint32_t context_id;
114 uint32_t assoc_group_id;
116 struct ndr_syntax_id syntax;
117 struct ndr_syntax_id transfer_syntax;
119 struct dcecli_connection *conn;
120 struct dcerpc_binding *binding;
122 /** the last fault code from a DCERPC fault */
123 uint32_t last_fault_code;
125 /** timeout for individual rpc requests, in seconds */
126 uint32_t request_timeout;
129 * Set for the timeout in dcerpc_pipe_connect_b_send(), to
130 * allow the timeout not to destory the stack during a nested
131 * event loop caused by gensec_update()
133 bool inhibit_timeout_processing;
134 bool timed_out;
137 /* default timeout for all rpc requests, in seconds */
138 #define DCERPC_REQUEST_TIMEOUT 60
141 struct dcerpc_pipe_connect {
142 struct dcerpc_pipe *pipe;
143 struct dcerpc_binding *binding;
144 const char *pipe_name;
145 const struct ndr_interface_table *interface;
146 struct cli_credentials *creds;
147 struct resolve_context *resolve_ctx;
151 struct epm_tower;
152 struct epm_floor;
154 struct smbcli_tree;
155 struct smb2_tree;
156 struct socket_address;
158 NTSTATUS dcerpc_pipe_connect(TALLOC_CTX *parent_ctx,
159 struct dcerpc_pipe **pp,
160 const char *binding,
161 const struct ndr_interface_table *table,
162 struct cli_credentials *credentials,
163 struct tevent_context *ev,
164 struct loadparm_context *lp_ctx);
165 const char *dcerpc_server_name(struct dcerpc_pipe *p);
166 struct dcerpc_pipe *dcerpc_pipe_init(TALLOC_CTX *mem_ctx, struct tevent_context *ev);
167 NTSTATUS dcerpc_pipe_open_smb(struct dcerpc_pipe *p,
168 struct smbcli_tree *tree,
169 const char *pipe_name);
170 NTSTATUS dcerpc_bind_auth_none(struct dcerpc_pipe *p,
171 const struct ndr_interface_table *table);
172 NTSTATUS dcerpc_fetch_session_key(struct dcerpc_pipe *p,
173 DATA_BLOB *session_key);
174 struct composite_context;
175 NTSTATUS dcerpc_secondary_connection_recv(struct composite_context *c,
176 struct dcerpc_pipe **p2);
178 struct composite_context* dcerpc_pipe_connect_b_send(TALLOC_CTX *parent_ctx,
179 struct dcerpc_binding *binding,
180 const struct ndr_interface_table *table,
181 struct cli_credentials *credentials,
182 struct tevent_context *ev,
183 struct loadparm_context *lp_ctx);
185 NTSTATUS dcerpc_pipe_connect_b_recv(struct composite_context *c, TALLOC_CTX *mem_ctx,
186 struct dcerpc_pipe **p);
188 NTSTATUS dcerpc_pipe_connect_b(TALLOC_CTX *parent_ctx,
189 struct dcerpc_pipe **pp,
190 struct dcerpc_binding *binding,
191 const struct ndr_interface_table *table,
192 struct cli_credentials *credentials,
193 struct tevent_context *ev,
194 struct loadparm_context *lp_ctx);
196 NTSTATUS dcerpc_pipe_auth(TALLOC_CTX *mem_ctx,
197 struct dcerpc_pipe **p,
198 struct dcerpc_binding *binding,
199 const struct ndr_interface_table *table,
200 struct cli_credentials *credentials,
201 struct loadparm_context *lp_ctx);
202 NTSTATUS dcerpc_secondary_connection(struct dcerpc_pipe *p,
203 struct dcerpc_pipe **p2,
204 struct dcerpc_binding *b);
205 NTSTATUS dcerpc_bind_auth_schannel(TALLOC_CTX *tmp_ctx,
206 struct dcerpc_pipe *p,
207 const struct ndr_interface_table *table,
208 struct cli_credentials *credentials,
209 struct loadparm_context *lp_ctx,
210 uint8_t auth_level);
211 struct tevent_context *dcerpc_event_context(struct dcerpc_pipe *p);
212 NTSTATUS dcerpc_init(void);
213 struct smbcli_tree *dcerpc_smb_tree(struct dcecli_connection *c);
214 uint16_t dcerpc_smb_fnum(struct dcecli_connection *c);
215 NTSTATUS dcerpc_secondary_context(struct dcerpc_pipe *p,
216 struct dcerpc_pipe **pp2,
217 const struct ndr_interface_table *table);
218 NTSTATUS dcerpc_alter_context(struct dcerpc_pipe *p,
219 TALLOC_CTX *mem_ctx,
220 const struct ndr_syntax_id *syntax,
221 const struct ndr_syntax_id *transfer_syntax);
223 NTSTATUS dcerpc_bind_auth(struct dcerpc_pipe *p,
224 const struct ndr_interface_table *table,
225 struct cli_credentials *credentials,
226 struct gensec_settings *gensec_settings,
227 uint8_t auth_type, uint8_t auth_level,
228 const char *service);
229 struct composite_context* dcerpc_pipe_connect_send(TALLOC_CTX *parent_ctx,
230 const char *binding,
231 const struct ndr_interface_table *table,
232 struct cli_credentials *credentials,
233 struct tevent_context *ev, struct loadparm_context *lp_ctx);
234 NTSTATUS dcerpc_pipe_connect_recv(struct composite_context *c,
235 TALLOC_CTX *mem_ctx,
236 struct dcerpc_pipe **pp);
238 NTSTATUS dcerpc_epm_map_binding(TALLOC_CTX *mem_ctx, struct dcerpc_binding *binding,
239 const struct ndr_interface_table *table, struct tevent_context *ev,
240 struct loadparm_context *lp_ctx);
241 struct composite_context* dcerpc_secondary_auth_connection_send(struct dcerpc_pipe *p,
242 struct dcerpc_binding *binding,
243 const struct ndr_interface_table *table,
244 struct cli_credentials *credentials,
245 struct loadparm_context *lp_ctx);
246 NTSTATUS dcerpc_secondary_auth_connection_recv(struct composite_context *c,
247 TALLOC_CTX *mem_ctx,
248 struct dcerpc_pipe **p);
250 struct composite_context* dcerpc_secondary_connection_send(struct dcerpc_pipe *p,
251 struct dcerpc_binding *b);
252 void dcerpc_log_packet(const char *lockdir,
253 const struct ndr_interface_table *ndr,
254 uint32_t opnum, uint32_t flags,
255 const DATA_BLOB *pkt);
258 enum dcerpc_transport_t dcerpc_transport_by_endpoint_protocol(int prot);
260 const char *dcerpc_floor_get_rhs_data(TALLOC_CTX *mem_ctx, struct epm_floor *epm_floor);
262 #endif /* __S4_DCERPC_H__ */