smb_composite: Remove unnecessary include of signing header.
[amitay/samba.git] / source4 / libcli / smb_composite / smb_composite.h
1 /* 
2    Unix SMB/CIFS implementation.
3
4    SMB composite request interfaces
5
6    Copyright (C) Andrew Tridgell 2005
7    
8    This program is free software; you can redistribute it and/or modify
9    it under the terms of the GNU General Public License as published by
10    the Free Software Foundation; either version 3 of the License, or
11    (at your option) any later version.
12    
13    This program is distributed in the hope that it will be useful,
14    but WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16    GNU General Public License for more details.
17    
18    You should have received a copy of the GNU General Public License
19    along with this program.  If not, see <http://www.gnu.org/licenses/>.
20 */
21
22 /*
23   this defines the structures associated with "composite"
24   requests. Composite requests are libcli requests that are internally
25   implemented as multiple libcli/raw/ calls, but can be treated as a
26   single call via these composite calls. The composite calls are
27   particularly designed to be used in async applications
28 */
29
30 #ifndef __SMB_COMPOSITE_H__
31 #define __SMB_COMPOSITE_H__
32
33 #include "libcli/raw/libcliraw.h"
34 #include "libcli/smb2/smb2.h"
35
36 /*
37   a composite open/read(s)/close request that loads a whole file
38   into memory. Used as a demo of the composite system.
39 */
40 struct smb_composite_loadfile {
41         struct {
42                 const char *fname;
43         } in;
44         struct {
45                 uint8_t *data;
46                 uint32_t size;
47         } out;
48 };
49
50 struct composite_context *smb_composite_loadfile_send(struct smbcli_tree *tree, 
51                                                      struct smb_composite_loadfile *io);
52 NTSTATUS smb_composite_loadfile_recv(struct composite_context *c, TALLOC_CTX *mem_ctx);
53 NTSTATUS smb_composite_loadfile(struct smbcli_tree *tree, 
54                                 TALLOC_CTX *mem_ctx,
55                                 struct smb_composite_loadfile *io);
56
57 struct smb_composite_fetchfile {
58         struct {
59                 const char *dest_host;
60                 const char **ports;
61                 const char *called_name;
62                 const char *service;
63                 const char *service_type;
64                 const char *socket_options;
65                 struct cli_credentials *credentials;
66                 const char *workgroup;
67                 const char *filename;
68                 struct smbcli_options options;
69                 struct smbcli_session_options session_options;
70                 struct resolve_context *resolve_ctx;
71                 struct gensec_settings *gensec_settings;
72         } in;
73         struct {
74                 uint8_t *data;
75                 uint32_t size;
76         } out;
77 };
78
79 struct composite_context *smb_composite_fetchfile_send(struct smb_composite_fetchfile *io,
80                                                        struct tevent_context *event_ctx);
81 NTSTATUS smb_composite_fetchfile_recv(struct composite_context *c,
82                                       TALLOC_CTX *mem_ctx);
83 NTSTATUS smb_composite_fetchfile(struct smb_composite_fetchfile *io,
84                                  TALLOC_CTX *mem_ctx);
85
86 /*
87   a composite open/write(s)/close request that saves a whole file from
88   memory. Used as a demo of the composite system.
89 */
90 struct smb_composite_savefile {
91         struct {
92                 const char *fname;
93                 uint8_t *data;
94                 uint32_t size;
95         } in;
96 };
97
98 struct composite_context *smb_composite_savefile_send(struct smbcli_tree *tree, 
99                                                       struct smb_composite_savefile *io);
100 NTSTATUS smb_composite_savefile_recv(struct composite_context *c);
101 NTSTATUS smb_composite_savefile(struct smbcli_tree *tree, 
102                                 struct smb_composite_savefile *io);
103
104 /*
105   a composite request for a full connection to a remote server. Includes
106
107     - socket establishment
108     - session request
109     - negprot
110     - session setup (if credentials are not NULL)
111     - tree connect (if service is not NULL)
112 */
113 struct smb_composite_connect {
114         struct {
115                 const char *dest_host;
116                 const char **dest_ports;
117                 const char *socket_options;
118                 const char *called_name;
119                 const char *service;
120                 const char *service_type;
121                 struct cli_credentials *credentials;
122                 bool fallback_to_anonymous;
123                 const char *workgroup;
124                 struct smbcli_options options;
125                 struct smbcli_session_options session_options;
126                 struct gensec_settings *gensec_settings;
127         } in;
128         struct {
129                 struct smbcli_tree *tree;
130                 bool anonymous_fallback_done;
131         } out;
132 };
133
134 struct composite_context *smb_composite_connect_send(struct smb_composite_connect *io,
135                                                      TALLOC_CTX *mem_ctx,
136                                                      struct resolve_context *resolve_ctx,
137                                                      struct tevent_context *event_ctx);
138 NTSTATUS smb_composite_connect_recv(struct composite_context *c, TALLOC_CTX *mem_ctx);
139 NTSTATUS smb_composite_connect(struct smb_composite_connect *io, TALLOC_CTX *mem_ctx,
140                                struct resolve_context *resolve_ctx,
141                                struct tevent_context *ev);
142
143
144 /*
145   generic session setup interface that takes care of which
146   session setup varient to use
147 */
148 struct smb_composite_sesssetup {
149         struct {
150                 uint32_t sesskey;
151                 uint32_t capabilities;
152                 struct cli_credentials *credentials;
153                 const char *workgroup;
154                 struct gensec_settings *gensec_settings;
155         } in;
156         struct {
157                 uint16_t vuid;
158         } out;          
159 };
160
161 struct composite_context *smb_composite_sesssetup_send(struct smbcli_session *session, 
162                                                        struct smb_composite_sesssetup *io);
163 NTSTATUS smb_composite_sesssetup_recv(struct composite_context *c);
164 NTSTATUS smb_composite_sesssetup(struct smbcli_session *session, struct smb_composite_sesssetup *io);
165
166 /*
167   query file system info
168 */
169 struct smb_composite_fsinfo {
170         struct {
171                 const char *dest_host;
172                 const char **dest_ports;
173                 const char *socket_options;
174                 const char *called_name;
175                 const char *service;
176                 const char *service_type;
177                 struct cli_credentials *credentials;
178                 const char *workgroup;
179                 enum smb_fsinfo_level level;
180                 struct gensec_settings *gensec_settings;
181         } in;
182         
183         struct {
184                 union smb_fsinfo *fsinfo;
185         } out;
186 };
187
188 struct composite_context *smb_composite_fsinfo_send(struct smbcli_tree *tree, 
189                                                     struct smb_composite_fsinfo *io,
190                                                     struct resolve_context *resolve_ctx);
191 NTSTATUS smb_composite_fsinfo_recv(struct composite_context *c, TALLOC_CTX *mem_ctx);
192 NTSTATUS smb_composite_fsinfo(struct smbcli_tree *tree, 
193                               TALLOC_CTX *mem_ctx,
194                               struct smb_composite_fsinfo *io,
195                               struct resolve_context *resolve_ctx);
196
197 /*
198   composite call for appending new acl to the file's security descriptor and get 
199   new full acl
200 */
201
202 struct smb_composite_appendacl {
203         struct {
204                 const char *fname;
205
206                 const struct security_descriptor *sd;
207         } in;
208         
209         struct {
210                 struct security_descriptor *sd;
211         } out;
212 };
213
214 struct composite_context *smb_composite_appendacl_send(struct smbcli_tree *tree, 
215                                                         struct smb_composite_appendacl *io);
216 NTSTATUS smb_composite_appendacl_recv(struct composite_context *c, TALLOC_CTX *mem_ctx);
217 NTSTATUS smb_composite_appendacl(struct smbcli_tree *tree, 
218                                 TALLOC_CTX *mem_ctx,
219                                 struct smb_composite_appendacl *io);
220
221 /*
222   a composite API to fire connect() calls to multiple targets, picking the
223   first one.
224 */
225
226 struct smb_composite_connectmulti {
227         struct {
228                 int num_dests;
229                 const char **hostnames;
230                 const char **addresses;
231                 int *ports;     /* Either NULL for lpcfg_smb_ports() per
232                                  * destination or a list of explicit ports */
233         } in;
234         struct {
235                 struct smbcli_socket *socket;
236         } out;
237 };
238
239 struct smbcli_session;
240 struct resolve_context;
241
242 struct composite_context *smb2_composite_unlink_send(struct smb2_tree *tree, 
243                                                      union smb_unlink *io);
244 NTSTATUS smb2_composite_unlink(struct smb2_tree *tree, union smb_unlink *io);
245 struct composite_context *smb2_composite_mkdir_send(struct smb2_tree *tree, 
246                                                      union smb_mkdir *io);
247 NTSTATUS smb2_composite_mkdir(struct smb2_tree *tree, union smb_mkdir *io);
248 struct composite_context *smb2_composite_rmdir_send(struct smb2_tree *tree, 
249                                                     struct smb_rmdir *io);
250 NTSTATUS smb2_composite_rmdir(struct smb2_tree *tree, struct smb_rmdir *io);
251 struct tevent_req *smb2_composite_setpathinfo_send(TALLOC_CTX *mem_ctx,
252                                                    struct tevent_context *ev,
253                                                    struct smb2_tree *tree,
254                                                    const union smb_setfileinfo *io);
255 NTSTATUS smb2_composite_setpathinfo_recv(struct tevent_req *req);
256 NTSTATUS smb2_composite_setpathinfo(struct smb2_tree *tree, union smb_setfileinfo *io);
257
258 #endif /* __SMB_COMPOSITE_H__ */