r5126: the composite code is no longer client specific or smb specific, so
[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
53
54 /*
55   a composite open/read(s)/close request that loads a whole file
56   into memory. Used as a demo of the composite system.
57 */
58 struct smb_composite_loadfile {
59         struct {
60                 const char *fname;
61         } in;
62         struct {
63                 uint8_t *data;
64                 uint32_t size;
65         } out;
66 };
67
68 struct smb_composite_fetchfile {
69         struct {
70                 const char *dest_host;
71                 int port;
72                 const char *called_name;
73                 const char *calling_name;
74                 const char *service;
75                 const char *service_type;
76                 const char *user;
77                 const char *domain;
78                 const char *password;
79                 const char *filename;
80         } in;
81         struct {
82                 uint8_t *data;
83                 uint32_t size;
84         } out;
85 };
86
87 /*
88   a composite open/write(s)/close request that saves a whole file from
89   memory. Used as a demo of the composite system.
90 */
91 struct smb_composite_savefile {
92         struct {
93                 const char *fname;
94                 uint8_t *data;
95                 uint32_t size;
96         } in;
97 };
98
99
100 /*
101   a composite request for a full connection to a remote server. Includes
102
103     - socket establishment
104     - session request
105     - negprot
106     - session setup
107     - tree connect
108 */
109 struct smb_composite_connect {
110         struct {
111                 const char *dest_host;
112                 int port;
113                 const char *called_name;
114                 const char *calling_name;
115                 const char *service;
116                 const char *service_type;
117                 const char *user;
118                 const char *domain;
119                 const char *password;
120         } in;
121         struct {
122                 struct smbcli_tree *tree;
123         } out;
124 };
125
126
127 /*
128   generic session setup interface that takes care of which
129   session setup varient to use
130 */
131 struct smb_composite_sesssetup {
132         struct {
133                 uint32_t sesskey;
134                 uint32_t capabilities;
135                 const char *password;
136                 const char *user;
137                 const char *domain;
138         } in;
139         struct {
140                 uint16_t vuid;
141         } out;          
142 };