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