Update 4.2 Roadmap file
[mat/samba.git] / source4 / librpc / rpc / dcerpc.h
1 /* 
2    Unix SMB/CIFS implementation.
3
4    DCERPC client side interface structures
5
6    Copyright (C) Tim Potter 2003
7    Copyright (C) Andrew Tridgell 2003-2005
8    
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.
13    
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.
18    
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/>.
21 */
22
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. */
26
27 #ifndef __S4_DCERPC_H__
28 #define __S4_DCERPC_H__
29
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"
34
35 struct tevent_context;
36 struct tevent_req;
37 struct dcerpc_binding_handle;
38 struct tstream_context;
39 struct ndr_interface_table;
40 struct resolve_context;
41
42 /*
43   this defines a generic security context for signed/sealed dcerpc pipes.
44 */
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;
51
52         /* get the session key */
53         NTSTATUS (*session_key)(struct dcecli_connection *, DATA_BLOB *);
54 };
55
56 /*
57   this holds the information that is not specific to a particular rpc context_id
58 */
59 struct rpc_request;
60 struct dcecli_connection {
61         uint32_t call_id;
62         uint32_t srv_max_xmit_frag;
63         uint32_t srv_max_recv_frag;
64         uint32_t flags;
65         struct dcecli_security security_state;
66         struct tevent_context *event_ctx;
67
68         struct tevent_immediate *io_trigger;
69         bool io_trigger_pending;
70
71         /** Directory in which to save ndrdump-parseable files */
72         const char *packet_log_dir;
73
74         bool dead;
75         bool free_skipped;
76
77         struct dcerpc_transport {
78                 enum dcerpc_transport_t transport;
79                 void *private_data;
80
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;
88         } transport;
89
90         const char *server_name;
91
92         /* Requests that have been sent, waiting for a reply */
93         struct rpc_request *pending;
94
95         /* Sync requests waiting to be shipped */
96         struct rpc_request *request_queue;
97
98         /* the next context_id to be assigned */
99         uint32_t next_context_id;
100 };
101
102 /*
103   this encapsulates a full dcerpc client side pipe 
104 */
105 struct dcerpc_pipe {
106         struct dcerpc_binding_handle *binding_handle;
107
108         uint32_t context_id;
109
110         struct ndr_syntax_id syntax;
111         struct ndr_syntax_id transfer_syntax;
112
113         struct dcecli_connection *conn;
114         const struct dcerpc_binding *binding;
115
116         /** the last fault code from a DCERPC fault */
117         uint32_t last_fault_code;
118
119         /** timeout for individual rpc requests, in seconds */
120         uint32_t request_timeout;
121
122         /*
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()
126          */
127         bool inhibit_timeout_processing;
128         bool timed_out;
129 };
130
131 /* default timeout for all rpc requests, in seconds */
132 #define DCERPC_REQUEST_TIMEOUT 60
133
134 struct epm_tower;
135 struct epm_floor;
136
137 struct smbcli_tree;
138 struct smb2_tree;
139 struct smbXcli_conn;
140 struct smbXcli_session;
141 struct smbXcli_tcon;
142 struct roh_connection;
143 struct tstream_tls_params;
144 struct socket_address;
145
146 NTSTATUS dcerpc_pipe_connect(TALLOC_CTX *parent_ctx, 
147                              struct dcerpc_pipe **pp, 
148                              const char *binding,
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);
168
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);
175
176 NTSTATUS dcerpc_pipe_connect_b_recv(struct composite_context *c, TALLOC_CTX *mem_ctx,
177                                     struct dcerpc_pipe **p);
178
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);
186
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,
201                                    uint8_t auth_level);
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, 
211                               TALLOC_CTX *mem_ctx,
212                               const struct ndr_syntax_id *syntax,
213                               const struct ndr_syntax_id *transfer_syntax);
214
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,
222                                                    const char *binding,
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,
227                                   TALLOC_CTX *mem_ctx,
228                                   struct dcerpc_pipe **pp);
229
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, 
239                                                TALLOC_CTX *mem_ctx,
240                                                struct dcerpc_pipe **p);
241
242 struct composite_context* dcerpc_secondary_connection_send(struct dcerpc_pipe *p,
243                                                            const struct dcerpc_binding *b);
244 void dcerpc_log_packet(const char *lockdir, 
245                        const struct ndr_interface_table *ndr,
246                        uint32_t opnum, uint32_t flags,
247                        const DATA_BLOB *pkt);
248
249 #endif /* __S4_DCERPC_H__ */