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