be7fbd99726b7e3d439919d7e57712bc19df2003
[kai/samba.git] / source4 / libcli / composite / 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 2 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, write to the Free Software
20    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */
22
23 /*
24   this defines the structures associated with "composite"
25   requests. Composite requests are libcli requests that are internally
26   implemented as multiple libcli/raw/ calls, but can be treated as a
27   single call via these composite calls. The composite calls are
28   particularly designed to be used in async applications
29 */
30
31
32 struct composite_context {
33         /* the external state - will be queried by the caller */
34         enum smbcli_request_state state;
35
36         /* a private pointer for use by the composite function
37            implementation */
38         void *private;
39
40         /* status code when finished */
41         NTSTATUS status;
42
43         /* the event context we are using */
44         struct event_context *event_ctx;
45
46         /* information on what to do on completion */
47         struct {
48                 void (*fn)(struct composite_context *);
49                 void *private;
50         } async;
51
52         /* information about the progress */
53         void (*monitor_fn)(struct monitor_msg *);
54 };
55
56
57 /*
58   a composite open/read(s)/close request that loads a whole file
59   into memory. Used as a demo of the composite system.
60 */
61 struct smb_composite_loadfile {
62         struct {
63                 const char *fname;
64         } in;
65         struct {
66                 uint8_t *data;
67                 uint32_t size;
68         } out;
69 };
70
71 struct smb_composite_fetchfile {
72         struct {
73                 const char *dest_host;
74                 int port;
75                 const char *called_name;
76                 const char *service;
77                 const char *service_type;
78                 struct cli_credentials *credentials;
79                 const char *workgroup;
80                 const char *filename;
81         } in;
82         struct {
83                 uint8_t *data;
84                 uint32_t size;
85         } out;
86 };
87
88 /*
89   a composite open/write(s)/close request that saves a whole file from
90   memory. Used as a demo of the composite system.
91 */
92 struct smb_composite_savefile {
93         struct {
94                 const char *fname;
95                 uint8_t *data;
96                 uint32_t size;
97         } in;
98 };
99
100
101 /*
102   a composite request for a full connection to a remote server. Includes
103
104     - socket establishment
105     - session request
106     - negprot
107     - session setup
108     - tree connect
109 */
110 struct smb_composite_connect {
111         struct {
112                 const char *dest_host;
113                 int port;
114                 const char *called_name;
115                 const char *service;
116                 const char *service_type;
117                 struct cli_credentials *credentials;
118                 const char *workgroup;
119         } in;
120         struct {
121                 struct smbcli_tree *tree;
122         } out;
123 };
124
125
126 /*
127   generic session setup interface that takes care of which
128   session setup varient to use
129 */
130 struct smb_composite_sesssetup {
131         struct {
132                 uint32_t sesskey;
133                 uint32_t capabilities;
134                 struct cli_credentials *credentials;
135                 const char *workgroup;
136         } in;
137         struct {
138                 uint16_t vuid;
139         } out;          
140 };
141
142 /*
143   query file system info
144 */
145 struct smb_composite_fsinfo {
146         struct {
147                 const char *dest_host;
148                 int port;
149                 const char *called_name;
150                 const char *service;
151                 const char *service_type;
152                 struct cli_credentials *credentials;
153                 const char *workgroup;
154                 enum smb_fsinfo_level level;
155         } in;
156         
157         struct {
158                 union smb_fsinfo *fsinfo;
159         } out;
160 };
161
162 /*
163   composite call for appending new acl to the file's security descriptor and get 
164   new full acl
165 */
166
167 struct smb_composite_appendacl {
168         struct {
169                 const char *fname;
170
171                 const struct security_descriptor *sd;
172         } in;
173         
174         struct {
175                 struct security_descriptor *sd;
176         } out;
177 };