9569ba9b0cacd3726b06059742f6be5b23212f12
[samba.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 it 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                 [range(1, 1024)] uint32                 num_nodes;
61                 smbXsrv_version_node0                   nodes[num_nodes];
62         } smbXsrv_version_global0;
63
64         typedef union {
65                 [case(0)] smbXsrv_version_global0       *info0;
66                 [default] hyper                         *dummy;
67         } smbXsrv_version_globalU;
68
69         typedef [public] struct {
70                 smbXsrv_version_values                  version;
71                 uint32                                  seqnum;
72                 [switch_is(version)] smbXsrv_version_globalU info;
73         } smbXsrv_version_globalB;
74
75         /* client */
76
77         typedef struct {
78                 [ignore] db_record                      *db_rec;
79                 server_id                               server_id;
80                 [charset(UTF8),string] char             local_address[];
81                 [charset(UTF8),string] char             remote_address[];
82                 [charset(UTF8),string] char             remote_name[];
83                 NTTIME                                  initial_connect_time;
84                 GUID                                    client_guid;
85                 boolean8                                stored;
86         } smbXsrv_client_global0;
87
88         typedef union {
89                 [case(0)] smbXsrv_client_global0        *info0;
90                 [default] hyper                         *dummy;
91         } smbXsrv_client_globalU;
92
93         typedef [public] struct {
94                 smbXsrv_version_values                  version;
95                 uint32                                  seqnum;
96                 [switch_is(version)] smbXsrv_client_globalU info;
97         } smbXsrv_client_globalB;
98
99         typedef [public] struct {
100                 [ignore] smbXsrv_client_table           *table;
101                 [ignore] struct tevent_context          *raw_ev_ctx;
102                 [ignore] struct messaging_context       *msg_ctx;
103
104                 [ref] smbXsrv_client_global0            *global;
105
106                 /*
107                  * There's just one 'sconn' per client.
108                  * It holds the FSA layer details, which are global
109                  * per client (process).
110                  */
111                 [ignore] struct smbd_server_connection  *sconn;
112
113                 /*
114                  * this session_table is used for SMB1 and SMB2,
115                  */
116                 [ignore] struct smbXsrv_session_table   *session_table;
117                 /*
118                  * this tcon_table is only used for SMB1.
119                  */
120                 [ignore] struct smbXsrv_tcon_table      *tcon_table;
121                 /*
122                  * this open_table is used for SMB1 and SMB2,
123                  * because we have a global sconn->real_max_open_files
124                  * limit.
125                  */
126                 [ignore] struct smbXsrv_open_table      *open_table;
127
128                 /*
129                  * For now this is only one connection!
130                  * With multi-channel support we'll get more than
131                  * one in future.
132                  */
133                 [ignore] struct smbXsrv_connection      *connections;
134                 boolean8                server_multi_channel_enabled;
135                 hyper                   next_channel_id;
136                 [ignore] struct tevent_req              *connection_pass_subreq;
137                 [ignore] struct tevent_req              *connection_drop_subreq;
138
139                 /*
140                  * A List of pending breaks.
141                  */
142                 [ignore] struct smbXsrv_pending_break *pending_breaks;
143         } smbXsrv_client;
144
145         typedef union {
146                 [case(0)] smbXsrv_client                *info0;
147                 [default] hyper                         *dummy;
148         } smbXsrv_clientU;
149
150         typedef [public] struct {
151                 smbXsrv_version_values                  version;
152                 [value(0)] uint32                       reserved;
153                 [switch_is(version)] smbXsrv_clientU    info;
154         } smbXsrv_clientB;
155
156         /*
157          * smbXsrv_connection_pass is used in the MSG_SMBXSRV_CONNECTION_PASS
158          * message and echo'ed as MSG_SMBXSRV_CONNECTION_PASSED message with
159          * negotiate_request.length = 0.
160          */
161         typedef struct {
162                 GUID                                    client_guid;
163                 server_id                               src_server_id;
164                 NTTIME                                  xconn_connect_time;
165                 server_id                               dst_server_id;
166                 NTTIME                                  client_connect_time;
167                 DATA_BLOB                               negotiate_request;
168         } smbXsrv_connection_pass0;
169
170         typedef union {
171                 [case(0)] smbXsrv_connection_pass0      *info0;
172                 [default] hyper                         *dummy;
173         } smbXsrv_connection_passU;
174
175         typedef [public] struct {
176                 smbXsrv_version_values                  version;
177                 [value(0)] uint32                       reserved;
178                 [switch_is(version)] smbXsrv_connection_passU   info;
179         } smbXsrv_connection_passB;
180
181         /*
182          * smbXsrv_connection_drop is used in the MSG_SMBXSRV_CONNECTION_DROP
183          * message as reaction the record is deleted.
184          */
185         typedef struct {
186                 GUID                                    client_guid;
187                 server_id                               src_server_id;
188                 NTTIME                                  xconn_connect_time;
189                 server_id                               dst_server_id;
190                 NTTIME                                  client_connect_time;
191         } smbXsrv_connection_drop0;
192
193         typedef union {
194                 [case(0)] smbXsrv_connection_drop0      *info0;
195                 [default] hyper                         *dummy;
196         } smbXsrv_connection_dropU;
197
198         typedef [public] struct {
199                 smbXsrv_version_values                  version;
200                 [value(0)] uint32                       reserved;
201                 [switch_is(version)] smbXsrv_connection_dropU   info;
202         } smbXsrv_connection_dropB;
203
204         /* sessions */
205
206         typedef [public,bitmap8bit] bitmap {
207                 SMBXSRV_ENCRYPTION_REQUIRED             = 0x01,
208                 SMBXSRV_ENCRYPTION_DESIRED              = 0x02,
209                 SMBXSRV_PROCESSED_ENCRYPTED_PACKET      = 0x04,
210                 SMBXSRV_PROCESSED_UNENCRYPTED_PACKET    = 0x08
211         } smbXsrv_encrpytion_flags;
212
213         typedef [public,bitmap8bit] bitmap {
214                 SMBXSRV_SIGNING_REQUIRED                = 0x01,
215                 SMBXSRV_PROCESSED_SIGNED_PACKET         = 0x02,
216                 SMBXSRV_PROCESSED_UNSIGNED_PACKET       = 0x04
217         } smbXsrv_signing_flags;
218
219         typedef struct {
220                 server_id                               server_id;
221                 hyper                                   channel_id;
222                 NTTIME                                  creation_time;
223                 [charset(UTF8),string] char             local_address[];
224                 [charset(UTF8),string] char             remote_address[];
225                 [charset(UTF8),string] char             remote_name[];
226                 [noprint] DATA_BLOB                     signing_key_blob;
227                 [ignore] smb2_signing_key               *signing_key;
228                 uint32                                  auth_session_info_seqnum;
229                 [ignore] smbXsrv_connection             *connection;
230                 uint16                                  signing_algo;
231                 uint16                                  encryption_cipher;
232         } smbXsrv_channel_global0;
233
234         typedef struct {
235                 [ignore] db_record                      *db_rec;
236                 uint32                                  session_global_id;
237                 hyper                                   session_wire_id;
238                 NTTIME                                  creation_time;
239                 NTTIME                                  expiration_time;
240                 /*
241                  * auth_session is NULL until the
242                  * session is valid for the first time.
243                  */
244                 NTTIME                                  auth_time;
245                 uint32                                  auth_session_info_seqnum;
246                 auth_session_info                       *auth_session_info;
247                 uint16                                  connection_dialect;
248                 GUID                                    client_guid;
249                 smbXsrv_signing_flags                   signing_flags;
250                 uint16                                  signing_algo;
251                 smbXsrv_encrpytion_flags                encryption_flags;
252                 uint16                                  encryption_cipher;
253                 [noprint] DATA_BLOB                     signing_key_blob;
254                 [ignore] smb2_signing_key               *signing_key;
255                 [noprint] DATA_BLOB                     encryption_key_blob;
256                 [ignore] smb2_signing_key               *encryption_key;
257                 [noprint] DATA_BLOB                     decryption_key_blob;
258                 [ignore] smb2_signing_key               *decryption_key;
259                 [noprint] DATA_BLOB                     application_key_blob;
260                 [ignore] smb2_signing_key               *application_key;
261                 [range(1, 1024)] uint32                 num_channels;
262                 smbXsrv_channel_global0                 channels[num_channels];
263         } smbXsrv_session_global0;
264
265         typedef union {
266                 [case(0)] smbXsrv_session_global0       *info0;
267                 [default] hyper                         *dummy;
268         } smbXsrv_session_globalU;
269
270         typedef [public] struct {
271                 smbXsrv_version_values                  version;
272                 uint32                                  seqnum;
273                 [switch_is(version)] smbXsrv_session_globalU info;
274         } smbXsrv_session_globalB;
275
276         /*
277          * The main server code should just work with
278          * 'struct smbXsrv_session' and never use
279          * smbXsrv_session0, smbXsrv_sessionU
280          * and smbXsrv_sessionB directly.
281          *
282          * If we need to change the smbXsrv_session,
283          * we can just rename smbXsrv_session
284          * to smbXsrv_session0 and add a new
285          * smbXsrv_session for version 1
286          * and could implement transparent mapping.
287          */
288
289         typedef struct {
290                 [ignore] smbXsrv_session_auth0          *prev;
291                 [max_recursion(20000)] smbXsrv_session_auth0 *next;
292                 [ignore] smbXsrv_session                *session;
293                 [ignore] smbXsrv_connection             *connection;
294                 [ignore] gensec_security                *gensec;
295                 [ignore] smbXsrv_preauth                *preauth;
296                 uint8                                   in_flags;
297                 uint8                                   in_security_mode;
298                 NTTIME                                  creation_time;
299                 NTTIME                                  idle_time;
300                 hyper                                   channel_id;
301         } smbXsrv_session_auth0;
302
303         typedef struct {
304                 [ignore] smbXsrv_session_table          *table;
305                 [ignore] db_record                      *db_rec;
306                 [ignore] smbXsrv_client                 *client;
307                 uint32                                  local_id;
308                 [ref] smbXsrv_session_global0           *global;
309                 NTSTATUS                                status;
310                 NTTIME                                  idle_time;
311                 hyper                                   nonce_high_random;
312                 hyper                                   nonce_high_max;
313                 hyper                                   nonce_high;
314                 hyper                                   nonce_low;
315                 [ignore] smbXsrv_tcon_table             *tcon_table;
316                 [ignore] uint32                         homes_snum;
317                 smbXsrv_session_auth0                   *pending_auth;
318         } smbXsrv_session;
319
320         typedef union {
321                 [case(0)] smbXsrv_session               *info0;
322                 [default] hyper                         *dummy;
323         } smbXsrv_sessionU;
324
325         typedef [public] struct {
326                 smbXsrv_version_values                  version;
327                 [value(0)] uint32                       reserved;
328                 [switch_is(version)] smbXsrv_sessionU   info;
329         } smbXsrv_sessionB;
330
331         /*
332          * smbXsrv_session_close is used in the MSG_SMBXSRV_SESSION_CLOSE
333          * message
334          */
335         typedef struct {
336                 uint32                                  old_session_global_id;
337                 hyper                                   old_session_wire_id;
338                 NTTIME                                  old_creation_time;
339                 hyper                                   new_session_wire_id;
340         } smbXsrv_session_close0;
341
342         typedef union {
343                 [case(0)] smbXsrv_session_close0        *info0;
344                 [default] hyper                         *dummy;
345         } smbXsrv_session_closeU;
346
347         typedef [public] struct {
348                 smbXsrv_version_values                  version;
349                 [value(0)] uint32                       reserved;
350                 [switch_is(version)] smbXsrv_session_closeU     info;
351         } smbXsrv_session_closeB;
352
353         /* tree connects */
354
355         typedef struct {
356                 [ignore] db_record                      *db_rec;
357                 uint32                                  tcon_global_id;
358                 uint32                                  tcon_wire_id;
359                 server_id                               server_id;
360                 NTTIME                                  creation_time;
361                 [charset(UTF8),string] char             share_name[];
362                 smbXsrv_encrpytion_flags                encryption_flags;
363                 /*
364                  * for SMB1 this is the session that the tcon was opened on
365                  */
366                 uint32                                  session_global_id;
367                 smbXsrv_signing_flags                   signing_flags;
368         } smbXsrv_tcon_global0;
369
370         typedef union {
371                 [case(0)] smbXsrv_tcon_global0          *info0;
372                 [default] hyper                         *dummy;
373         } smbXsrv_tcon_globalU;
374
375         typedef [public] struct {
376                 smbXsrv_version_values                  version;
377                 uint32                                  seqnum;
378                 [switch_is(version)] smbXsrv_tcon_globalU info;
379         } smbXsrv_tcon_globalB;
380
381         /*
382          * The main server code should just work with
383          * 'struct smbXsrv_tcon' and never use
384          * smbXsrv_tcon0, smbXsrv_tconU
385          * and smbXsrv_tconB directly.
386          *
387          * If we need to change the smbXsrv_tcon,
388          * we can just rename smbXsrv_tcon
389          * to smbXsrv_tcon0 and add a new
390          * smbXsrv_tcon for version 1
391          * and could implement transparent mapping.
392          */
393         typedef struct {
394                 [ignore] smbXsrv_tcon_table             *table;
395                 [ignore] db_record                      *db_rec;
396                 uint32                                  local_id;
397                 [ref] smbXsrv_tcon_global0              *global;
398                 NTSTATUS                                status;
399                 NTTIME                                  idle_time;
400                 [ignore] connection_struct              *compat;
401         } smbXsrv_tcon;
402
403         typedef union {
404                 [case(0)] smbXsrv_tcon                  *info0;
405                 [default] hyper                         *dummy;
406         } smbXsrv_tconU;
407
408         typedef [public] struct {
409                 smbXsrv_version_values                  version;
410                 [value(0)] uint32                       reserved;
411                 [switch_is(version)] smbXsrv_tconU      info;
412         } smbXsrv_tconB;
413
414         /* open files */
415
416         typedef [public,bitmap8bit] bitmap {
417                 SMBXSRV_OPEN_NEED_REPLAY_CACHE          = 0x01,
418                 SMBXSRV_OPEN_HAVE_REPLAY_CACHE          = 0x02
419         } smbXsrv_open_flags;
420
421         typedef struct {
422                 server_id                               server_id;
423                 uint32                                  open_global_id;
424                 hyper                                   open_persistent_id;
425                 hyper                                   open_volatile_id;
426                 dom_sid                                 open_owner;
427                 NTTIME                                  open_time;
428                 GUID                                    create_guid;
429                 GUID                                    client_guid;
430                 GUID                                    app_instance_id;
431                 /*
432                  * TODO: for durable/resilient/persistent handles we need more
433                  *       things here. See [MS-SMB2] 3.3.1.10 Per Open
434                  *
435                  * NOTE: this is still version 0, which is not a stable format!
436                  */
437                 NTTIME                                  disconnect_time;
438                 uint32                                  durable_timeout_msec;
439                 boolean8                                durable;
440                 DATA_BLOB                               backend_cookie;
441                 uint16                                  channel_sequence;
442                 hyper                                   channel_generation;
443                 [flag(NDR_PAHEX)] uint8                 lock_sequence_array[64];
444         } smbXsrv_open_global0;
445
446         typedef union {
447                 [case(0)] smbXsrv_open_global0          *info0;
448                 [default] hyper                         *dummy;
449         } smbXsrv_open_globalU;
450
451         typedef [public] struct {
452
453                 smbXsrv_version_values                  version;
454                 uint32                                  seqnum;
455                 [switch_is(version)] smbXsrv_open_globalU info;
456         } smbXsrv_open_globalB;
457
458         /*
459          * The main server code should just work with
460          * 'struct smbXsrv_open' and never use
461          * smbXsrv_open0, smbXsrv_openU
462          * and smbXsrv_openB directly.
463          *
464          * If we need to change the smbXsrv_open,
465          * we can just rename smbXsrv_open
466          * to smbXsrv_open0 and add a new
467          * smbXsrv_open for version 1
468          * and could implement transparent mapping.
469          */
470         typedef struct {
471                 [ignore] smbXsrv_open_table             *table;
472                 uint32                                  local_id;
473                 [ref] smbXsrv_open_global0              *global;
474                 NTSTATUS                                status;
475                 NTTIME                                  idle_time;
476                 [ignore] files_struct                   *compat;
477                 smbXsrv_open_flags                      flags;
478                 uint32                                  create_action;
479                 hyper                                   request_count;
480                 hyper                                   pre_request_count;
481         } smbXsrv_open;
482
483         typedef union {
484                 [case(0)] smbXsrv_open                  *info0;
485                 [default] hyper                         *dummy;
486         } smbXsrv_openU;
487
488         typedef [public] struct {
489                 smbXsrv_version_values                  version;
490                 [value(0)] uint32                       reserved;
491                 [switch_is(version)] smbXsrv_openU      info;
492         } smbXsrv_openB;
493
494         const uint32 SMBXSRV_OPEN_REPLAY_CACHE_FIXED_SIZE = 28;
495         typedef [public] struct {
496                 GUID                                    holder_req_guid;
497                 NTTIME                                  idle_time;
498                 uint32                                  local_id;
499         } smbXsrv_open_replay_cache;
500 }