7f4b9d73e4b48da338817e9558b39018119b6a25
[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 #include "libcli/raw/signing.h"
31 #include "libcli/raw/libcliraw.h"
32 #include "libcli/smb2/smb2.h"
33
34
35 /*
36   a composite open/read(s)/close request that loads a whole file
37   into memory. Used as a demo of the composite system.
38 */
39 struct smb_composite_loadfile {
40         struct {
41                 const char *fname;
42         } in;
43         struct {
44                 uint8_t *data;
45                 uint32_t size;
46         } out;
47 };
48
49 struct smb_composite_fetchfile {
50         struct {
51                 const char *dest_host;
52                 const char **ports;
53                 const char *called_name;
54                 const char *service;
55                 const char *service_type;
56                 struct cli_credentials *credentials;
57                 const char *workgroup;
58                 const char *filename;
59                 struct smbcli_options options;
60                 struct resolve_context *resolve_ctx;
61         } in;
62         struct {
63                 uint8_t *data;
64                 uint32_t size;
65         } out;
66 };
67
68 /*
69   a composite open/write(s)/close request that saves a whole file from
70   memory. Used as a demo of the composite system.
71 */
72 struct smb_composite_savefile {
73         struct {
74                 const char *fname;
75                 uint8_t *data;
76                 uint32_t size;
77         } in;
78 };
79
80
81 /*
82   a composite request for a full connection to a remote server. Includes
83
84     - socket establishment
85     - session request
86     - negprot
87     - session setup (if credentials are not NULL)
88     - tree connect (if service is not NULL)
89 */
90 struct smb_composite_connect {
91         struct {
92                 const char *dest_host;
93                 const char **dest_ports;
94                 const char *called_name;
95                 const char *service;
96                 const char *service_type;
97                 struct cli_credentials *credentials;
98                 bool fallback_to_anonymous;
99                 const char *workgroup;
100                 struct smbcli_options options;
101         } in;
102         struct {
103                 struct smbcli_tree *tree;
104                 bool anonymous_fallback_done;
105         } out;
106 };
107
108
109 /*
110   generic session setup interface that takes care of which
111   session setup varient to use
112 */
113 struct smb_composite_sesssetup {
114         struct {
115                 uint32_t sesskey;
116                 uint32_t capabilities;
117                 struct cli_credentials *credentials;
118                 const char *workgroup;
119         } in;
120         struct {
121                 uint16_t vuid;
122         } out;          
123 };
124
125 /*
126   query file system info
127 */
128 struct smb_composite_fsinfo {
129         struct {
130                 const char *dest_host;
131                 const char **dest_ports;
132                 const char *called_name;
133                 const char *service;
134                 const char *service_type;
135                 struct cli_credentials *credentials;
136                 const char *workgroup;
137                 enum smb_fsinfo_level level;
138         } in;
139         
140         struct {
141                 union smb_fsinfo *fsinfo;
142         } out;
143 };
144
145 /*
146   composite call for appending new acl to the file's security descriptor and get 
147   new full acl
148 */
149
150 struct smb_composite_appendacl {
151         struct {
152                 const char *fname;
153
154                 const struct security_descriptor *sd;
155         } in;
156         
157         struct {
158                 struct security_descriptor *sd;
159         } out;
160 };
161
162 /*
163   a composite API to fire connect() calls to multiple targets, picking the
164   first one.
165 */
166
167 struct smb_composite_connectmulti {
168         struct {
169                 int num_dests;
170                 const char **hostnames;
171                 const char **addresses;
172                 int *ports;     /* Either NULL for lp_smb_ports() per
173                                  * destination or a list of explicit ports */
174         } in;
175         struct {
176                 struct smbcli_socket *socket;
177         } out;
178 };
179
180 struct smbcli_session;
181 struct resolve_context;
182
183 #include "libcli/smb_composite/proto.h"