f6a5fd98c361239c0d1f75a8ae711a914aa867c6
[kai/samba-autobuild/.git] / source3 / librpc / idl / smbXsrv.idl
1 #include "idl_types.h"
2
3 import "misc.idl";
4 import "server_id.idl";
5 import "security.idl";
6 import "auth.idl";
7
8 [
9         uuid("07408340-ae31-11e1-97dc-539f7fddc06f"),
10         version(0.0),
11         pointer_default(unique),
12         helpstring("smbXsrv structures")
13 ]
14 interface smbXsrv
15 {
16         /*
17          * smbXsrv_version* is designed to allow
18          * rolling code upgrades in future (within a cluster).
19          *
20          * This just adds the infrastructure,
21          * but we does not implement it yet!
22          *
23          * Currently it only prevents that
24          * nodes with a different version numbers
25          * cannot run at the same time.
26          *
27          * Each node checks at startup, if the version
28          * matches the version of all other nodes.
29          * And it exits if the version does not match
30          * to avoid corruption.
31          *
32          * While it would be possible to add versioning
33          * to each of our internal databases it is easier
34          * use a dedicated database "smbXsrv_version_global.tdb"
35          * to hold the global version information.
36          *
37          * This removes extra complexity from the individual
38          * databases and allows that we add/remove databases
39          * or use different indexing keys.
40          *
41          */
42         typedef [v1_enum] enum {
43                 /*
44                  * NOTE: Version 0 is designed to be unstable and the format
45                  * may change during development.
46                  */
47                 SMBXSRV_VERSION_0 = 0x00000000
48         } smbXsrv_version_values;
49
50         const uint32 SMBXSRV_VERSION_CURRENT = SMBXSRV_VERSION_0;
51
52         typedef struct {
53                 server_id                               server_id;
54                 smbXsrv_version_values                  min_version;
55                 smbXsrv_version_values                  max_version;
56                 smbXsrv_version_values                  current_version;
57         } smbXsrv_version_node0;
58
59         typedef struct {
60                 [ignore] db_record                      *db_rec;
61                 [range(1, 1024)] uint32                 num_nodes;
62                 smbXsrv_version_node0                   nodes[num_nodes];
63         } smbXsrv_version_global0;
64
65         typedef union {
66                 [case(0)] smbXsrv_version_global0       *info0;
67                 [default] hyper                         *dummy;
68         } smbXsrv_version_globalU;
69
70         typedef [public] struct {
71                 smbXsrv_version_values                  version;
72                 uint32                                  seqnum;
73                 [switch_is(version)] smbXsrv_version_globalU info;
74         } smbXsrv_version_globalB;
75
76         void smbXsrv_version_global_decode(
77                 [in] smbXsrv_version_globalB blob
78                 );
79
80         /* client */
81
82         typedef [public] struct {
83                 [ignore] struct tevent_context          *ev_ctx;
84                 [ignore] struct messaging_context       *msg_ctx;
85
86                 /*
87                  * There's just one 'sconn' per client.
88                  * It holds the FSA layer details, which are global
89                  * per client (process).
90                  */
91                 [ignore] struct smbd_server_connection  *sconn;
92
93                 /*
94                  * this session_table is used for SMB1 and SMB2,
95                  */
96                 [ignore] struct smbXsrv_session_table   *session_table;
97                 [ignore] hyper                          last_session_id;
98                 /*
99                  * this tcon_table is only used for SMB1.
100                  */
101                 [ignore] struct smbXsrv_tcon_table      *tcon_table;
102                 /*
103                  * this open_table is used for SMB1 and SMB2,
104                  * because we have a global sconn->real_max_open_files
105                  * limit.
106                  */
107                 [ignore] struct smbXsrv_open_table      *open_table;
108
109                 /*
110                  * For now this is only one connection!
111                  * With multi-channel support we'll get more than
112                  * one in future.
113                  */
114                 [ignore] struct smbXsrv_connection      *connections;
115         } smbXsrv_client;
116
117         /* sessions */
118
119         typedef [public,bitmap8bit] bitmap {
120                 SMBXSRV_ENCRYPTION_REQUIRED             = 0x01,
121                 SMBXSRV_ENCRYPTION_DESIRED              = 0x02,
122                 SMBXSRV_PROCESSED_ENCRYPTED_PACKET      = 0x04,
123                 SMBXSRV_PROCESSED_UNENCRYPTED_PACKET    = 0x08
124         } smbXsrv_encrpytion_flags;
125
126         typedef [public,bitmap8bit] bitmap {
127                 SMBXSRV_SIGNING_REQUIRED                = 0x01
128         } smbXsrv_signing_flags;
129
130         typedef struct {
131                 server_id                               server_id;
132                 [charset(UTF8),string] char             local_address[];
133                 [charset(UTF8),string] char             remote_address[];
134                 [charset(UTF8),string] char             remote_name[];
135                 [noprint] DATA_BLOB                     signing_key;
136                 uint32                                  auth_session_info_seqnum;
137                 [ignore] smbXsrv_connection             *connection;
138                 uint16                                  encryption_cipher;
139         } smbXsrv_channel_global0;
140
141         typedef struct {
142                 [ignore] db_record                      *db_rec;
143                 uint32                                  session_global_id;
144                 hyper                                   session_wire_id;
145                 NTTIME                                  creation_time;
146                 NTTIME                                  expiration_time;
147                 /*
148                  * auth_session is NULL until the
149                  * session is valid for the first time.
150                  */
151                 NTTIME                                  auth_time;
152                 uint32                                  auth_session_info_seqnum;
153                 auth_session_info                       *auth_session_info;
154                 uint16                                  connection_dialect;
155                 smbXsrv_signing_flags                   signing_flags;
156                 smbXsrv_encrpytion_flags                encryption_flags;
157                 [noprint] DATA_BLOB                     signing_key;
158                 [noprint] DATA_BLOB                     encryption_key;
159                 [noprint] DATA_BLOB                     decryption_key;
160                 [noprint] DATA_BLOB                     application_key;
161                 [range(1, 1024)] uint32                 num_channels;
162                 smbXsrv_channel_global0                 channels[num_channels];
163         } smbXsrv_session_global0;
164
165         typedef union {
166                 [case(0)] smbXsrv_session_global0       *info0;
167                 [default] hyper                         *dummy;
168         } smbXsrv_session_globalU;
169
170         typedef [public] struct {
171                 smbXsrv_version_values                  version;
172                 uint32                                  seqnum;
173                 [switch_is(version)] smbXsrv_session_globalU info;
174         } smbXsrv_session_globalB;
175
176         void smbXsrv_session_global_decode(
177                 [in] smbXsrv_session_globalB blob
178                 );
179
180         /*
181          * The main server code should just work with
182          * 'struct smbXsrv_session' and never use
183          * smbXsrv_session0, smbXsrv_sessionU
184          * and smbXsrv_sessionB directly.
185          *
186          * If we need to change the smbXsrv_session,
187          * we can just rename smbXsrv_session
188          * to smbXsrv_session0 and add a new
189          * smbXsrv_session for version 1
190          * and could implement transparent mapping.
191          */
192
193         typedef struct {
194                 [ignore] smbXsrv_session_auth0          *prev;
195                 smbXsrv_session_auth0                   *next;
196                 [ignore] smbXsrv_session                *session;
197                 [ignore] smbXsrv_connection             *connection;
198                 [ignore] gensec_security                *gensec;
199                 [ignore] smbXsrv_preauth                *preauth;
200                 uint8                                   in_flags;
201                 uint8                                   in_security_mode;
202                 NTTIME                                  creation_time;
203                 NTTIME                                  idle_time;
204         } smbXsrv_session_auth0;
205
206         typedef struct {
207                 [ignore] smbXsrv_session_table          *table;
208                 [ignore] db_record                      *db_rec;
209                 [ignore] smbXsrv_client                 *client;
210                 uint32                                  local_id;
211                 [ref] smbXsrv_session_global0           *global;
212                 NTSTATUS                                status;
213                 NTTIME                                  idle_time;
214                 hyper                                   nonce_high_random;
215                 hyper                                   nonce_high_max;
216                 hyper                                   nonce_high;
217                 hyper                                   nonce_low;
218                 [ignore] user_struct                    *compat;
219                 [ignore] smbXsrv_tcon_table             *tcon_table;
220                 smbXsrv_session_auth0                   *pending_auth;
221         } smbXsrv_session;
222
223         typedef union {
224                 [case(0)] smbXsrv_session               *info0;
225                 [default] hyper                         *dummy;
226         } smbXsrv_sessionU;
227
228         typedef [public] struct {
229                 smbXsrv_version_values                  version;
230                 [value(0)] uint32                       reserved;
231                 [switch_is(version)] smbXsrv_sessionU   info;
232         } smbXsrv_sessionB;
233
234         void smbXsrv_session_decode(
235                 [in] smbXsrv_sessionB blob
236                 );
237
238         /*
239          * smbXsrv_session_close is use in the MSG_SMBXSRV_SESSION_CLOSE
240          * message
241          */
242         typedef struct {
243                 uint32                                  old_session_global_id;
244                 hyper                                   old_session_wire_id;
245                 NTTIME                                  old_creation_time;
246                 hyper                                   new_session_wire_id;
247         } smbXsrv_session_close0;
248
249         typedef union {
250                 [case(0)] smbXsrv_session_close0        *info0;
251                 [default] hyper                         *dummy;
252         } smbXsrv_session_closeU;
253
254         typedef [public] struct {
255                 smbXsrv_version_values                  version;
256                 [value(0)] uint32                       reserved;
257                 [switch_is(version)] smbXsrv_session_closeU     info;
258         } smbXsrv_session_closeB;
259
260         void smbXsrv_session_close_decode(
261                 [in] smbXsrv_session_closeB blob
262                 );
263
264         /* tree connects */
265
266         typedef struct {
267                 [ignore] db_record                      *db_rec;
268                 uint32                                  tcon_global_id;
269                 uint32                                  tcon_wire_id;
270                 server_id                               server_id;
271                 NTTIME                                  creation_time;
272                 [charset(UTF8),string] char             share_name[];
273                 smbXsrv_encrpytion_flags                encryption_flags;
274                 /*
275                  * for SMB1 this is the session that the tcon was opened on
276                  */
277                 uint32                                  session_global_id;
278         } smbXsrv_tcon_global0;
279
280         typedef union {
281                 [case(0)] smbXsrv_tcon_global0          *info0;
282                 [default] hyper                         *dummy;
283         } smbXsrv_tcon_globalU;
284
285         typedef [public] struct {
286                 smbXsrv_version_values                  version;
287                 uint32                                  seqnum;
288                 [switch_is(version)] smbXsrv_tcon_globalU info;
289         } smbXsrv_tcon_globalB;
290
291         void smbXsrv_tcon_global_decode(
292                 [in] smbXsrv_tcon_globalB blob
293                 );
294
295         /*
296          * The main server code should just work with
297          * 'struct smbXsrv_tcon' and never use
298          * smbXsrv_tcon0, smbXsrv_tconU
299          * and smbXsrv_tconB directly.
300          *
301          * If we need to change the smbXsrv_tcon,
302          * we can just rename smbXsrv_tcon
303          * to smbXsrv_tcon0 and add a new
304          * smbXsrv_tcon for version 1
305          * and could implement transparent mapping.
306          */
307         typedef struct {
308                 [ignore] smbXsrv_tcon_table             *table;
309                 [ignore] db_record                      *db_rec;
310                 uint32                                  local_id;
311                 [ref] smbXsrv_tcon_global0              *global;
312                 NTSTATUS                                status;
313                 NTTIME                                  idle_time;
314                 [ignore] connection_struct              *compat;
315         } smbXsrv_tcon;
316
317         typedef union {
318                 [case(0)] smbXsrv_tcon                  *info0;
319                 [default] hyper                         *dummy;
320         } smbXsrv_tconU;
321
322         typedef [public] struct {
323                 smbXsrv_version_values                  version;
324                 [value(0)] uint32                       reserved;
325                 [switch_is(version)] smbXsrv_tconU      info;
326         } smbXsrv_tconB;
327
328         void smbXsrv_tcon_decode(
329                 [in] smbXsrv_tconB blob
330                 );
331
332         /* open files */
333
334         typedef struct {
335                 [ignore] db_record                      *db_rec;
336                 server_id                               server_id;
337                 uint32                                  open_global_id;
338                 hyper                                   open_persistent_id;
339                 hyper                                   open_volatile_id;
340                 dom_sid                                 open_owner;
341                 NTTIME                                  open_time;
342                 GUID                                    create_guid;
343                 GUID                                    client_guid;
344                 GUID                                    app_instance_id;
345                 /*
346                  * TODO: for durable/resilient/persistent handles we need more
347                  *       things here. See [MS-SMB2] 3.3.1.10 Per Open
348                  *
349                  * NOTE: this is still version 0, which is not a stable format!
350                  */
351                 NTTIME                                  disconnect_time;
352                 uint32                                  durable_timeout_msec;
353                 boolean8                                durable;
354                 DATA_BLOB                               backend_cookie;
355         } smbXsrv_open_global0;
356
357         typedef union {
358                 [case(0)] smbXsrv_open_global0          *info0;
359                 [default] hyper                         *dummy;
360         } smbXsrv_open_globalU;
361
362         typedef [public] struct {
363
364                 smbXsrv_version_values                  version;
365                 uint32                                  seqnum;
366                 [switch_is(version)] smbXsrv_open_globalU info;
367         } smbXsrv_open_globalB;
368
369         void smbXsrv_open_global_decode(
370                 [in] smbXsrv_open_globalB blob
371                 );
372
373         /*
374          * The main server code should just work with
375          * 'struct smbXsrv_open' and never use
376          * smbXsrv_open0, smbXsrv_openU
377          * and smbXsrv_openB directly.
378          *
379          * If we need to change the smbXsrv_open,
380          * we can just rename smbXsrv_open
381          * to smbXsrv_open0 and add a new
382          * smbXsrv_open for version 1
383          * and could implement transparent mapping.
384          */
385         typedef struct {
386                 [ignore] smbXsrv_open_table             *table;
387                 [ignore] db_record                      *db_rec;
388                 uint32                                  local_id;
389                 [ref] smbXsrv_open_global0              *global;
390                 NTSTATUS                                status;
391                 NTTIME                                  idle_time;
392                 [ignore] files_struct                   *compat;
393         } smbXsrv_open;
394
395         typedef union {
396                 [case(0)] smbXsrv_open                  *info0;
397                 [default] hyper                         *dummy;
398         } smbXsrv_openU;
399
400         typedef [public] struct {
401                 smbXsrv_version_values                  version;
402                 [value(0)] uint32                       reserved;
403                 [switch_is(version)] smbXsrv_openU      info;
404         } smbXsrv_openB;
405
406         void smbXsrv_open_decode(
407                 [in] smbXsrv_openB blob
408                 );
409 }