0001
0002 #ifndef _COMMON_SMB2PDU_H
0003 #define _COMMON_SMB2PDU_H
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018 #define SMB2_NEGOTIATE_HE 0x0000
0019 #define SMB2_SESSION_SETUP_HE 0x0001
0020 #define SMB2_LOGOFF_HE 0x0002
0021 #define SMB2_TREE_CONNECT_HE 0x0003
0022 #define SMB2_TREE_DISCONNECT_HE 0x0004
0023 #define SMB2_CREATE_HE 0x0005
0024 #define SMB2_CLOSE_HE 0x0006
0025 #define SMB2_FLUSH_HE 0x0007
0026 #define SMB2_READ_HE 0x0008
0027 #define SMB2_WRITE_HE 0x0009
0028 #define SMB2_LOCK_HE 0x000A
0029 #define SMB2_IOCTL_HE 0x000B
0030 #define SMB2_CANCEL_HE 0x000C
0031 #define SMB2_ECHO_HE 0x000D
0032 #define SMB2_QUERY_DIRECTORY_HE 0x000E
0033 #define SMB2_CHANGE_NOTIFY_HE 0x000F
0034 #define SMB2_QUERY_INFO_HE 0x0010
0035 #define SMB2_SET_INFO_HE 0x0011
0036 #define SMB2_OPLOCK_BREAK_HE 0x0012
0037
0038
0039 #define SMB2_NEGOTIATE cpu_to_le16(SMB2_NEGOTIATE_HE)
0040 #define SMB2_SESSION_SETUP cpu_to_le16(SMB2_SESSION_SETUP_HE)
0041 #define SMB2_LOGOFF cpu_to_le16(SMB2_LOGOFF_HE)
0042 #define SMB2_TREE_CONNECT cpu_to_le16(SMB2_TREE_CONNECT_HE)
0043 #define SMB2_TREE_DISCONNECT cpu_to_le16(SMB2_TREE_DISCONNECT_HE)
0044 #define SMB2_CREATE cpu_to_le16(SMB2_CREATE_HE)
0045 #define SMB2_CLOSE cpu_to_le16(SMB2_CLOSE_HE)
0046 #define SMB2_FLUSH cpu_to_le16(SMB2_FLUSH_HE)
0047 #define SMB2_READ cpu_to_le16(SMB2_READ_HE)
0048 #define SMB2_WRITE cpu_to_le16(SMB2_WRITE_HE)
0049 #define SMB2_LOCK cpu_to_le16(SMB2_LOCK_HE)
0050 #define SMB2_IOCTL cpu_to_le16(SMB2_IOCTL_HE)
0051 #define SMB2_CANCEL cpu_to_le16(SMB2_CANCEL_HE)
0052 #define SMB2_ECHO cpu_to_le16(SMB2_ECHO_HE)
0053 #define SMB2_QUERY_DIRECTORY cpu_to_le16(SMB2_QUERY_DIRECTORY_HE)
0054 #define SMB2_CHANGE_NOTIFY cpu_to_le16(SMB2_CHANGE_NOTIFY_HE)
0055 #define SMB2_QUERY_INFO cpu_to_le16(SMB2_QUERY_INFO_HE)
0056 #define SMB2_SET_INFO cpu_to_le16(SMB2_SET_INFO_HE)
0057 #define SMB2_OPLOCK_BREAK cpu_to_le16(SMB2_OPLOCK_BREAK_HE)
0058
0059 #define SMB2_INTERNAL_CMD cpu_to_le16(0xFFFF)
0060
0061 #define NUMBER_OF_SMB2_COMMANDS 0x0013
0062
0063
0064
0065
0066 #define SMB2_NTLMV2_SESSKEY_SIZE 16
0067 #define SMB2_SIGNATURE_SIZE 16
0068 #define SMB2_HMACSHA256_SIZE 32
0069 #define SMB2_CMACAES_SIZE 16
0070 #define SMB3_GCM128_CRYPTKEY_SIZE 16
0071 #define SMB3_GCM256_CRYPTKEY_SIZE 32
0072
0073
0074
0075
0076
0077 #define SMB3_ENC_DEC_KEY_SIZE 32
0078
0079
0080
0081
0082 #define SMB3_SIGN_KEY_SIZE 16
0083
0084 #define CIFS_CLIENT_CHALLENGE_SIZE 8
0085
0086
0087 #define SMB2_MAX_BUFFER_SIZE 65536
0088
0089
0090
0091
0092
0093
0094
0095 #define SMB3_DEFAULT_IOSIZE (4 * 1024 * 1024)
0096
0097
0098
0099
0100
0101
0102
0103
0104
0105
0106 #define __SMB2_HEADER_STRUCTURE_SIZE 64
0107 #define SMB2_HEADER_STRUCTURE_SIZE \
0108 cpu_to_le16(__SMB2_HEADER_STRUCTURE_SIZE)
0109
0110 #define SMB2_PROTO_NUMBER cpu_to_le32(0x424d53fe)
0111 #define SMB2_TRANSFORM_PROTO_NUM cpu_to_le32(0x424d53fd)
0112 #define SMB2_COMPRESSION_TRANSFORM_ID cpu_to_le32(0x424d53fc)
0113
0114
0115
0116
0117 #define SMB2_FLAGS_SERVER_TO_REDIR cpu_to_le32(0x00000001)
0118 #define SMB2_FLAGS_ASYNC_COMMAND cpu_to_le32(0x00000002)
0119 #define SMB2_FLAGS_RELATED_OPERATIONS cpu_to_le32(0x00000004)
0120 #define SMB2_FLAGS_SIGNED cpu_to_le32(0x00000008)
0121 #define SMB2_FLAGS_PRIORITY_MASK cpu_to_le32(0x00000070)
0122 #define SMB2_FLAGS_DFS_OPERATIONS cpu_to_le32(0x10000000)
0123 #define SMB2_FLAGS_REPLAY_OPERATION cpu_to_le32(0x20000000)
0124
0125
0126
0127
0128
0129
0130
0131
0132
0133
0134
0135 struct smb2_hdr {
0136 __le32 ProtocolId;
0137 __le16 StructureSize;
0138 __le16 CreditCharge;
0139 __le32 Status;
0140 __le16 Command;
0141 __le16 CreditRequest;
0142 __le32 Flags;
0143 __le32 NextCommand;
0144 __le64 MessageId;
0145 union {
0146 struct {
0147 __le32 ProcessId;
0148 __le32 TreeId;
0149 } __packed SyncId;
0150 __le64 AsyncId;
0151 } __packed Id;
0152 __le64 SessionId;
0153 __u8 Signature[16];
0154 } __packed;
0155
0156 struct smb2_pdu {
0157 struct smb2_hdr hdr;
0158 __le16 StructureSize2;
0159 } __packed;
0160
0161 #define SMB2_ERROR_STRUCTURE_SIZE2 9
0162 #define SMB2_ERROR_STRUCTURE_SIZE2_LE cpu_to_le16(SMB2_ERROR_STRUCTURE_SIZE2)
0163
0164 struct smb2_err_rsp {
0165 struct smb2_hdr hdr;
0166 __le16 StructureSize;
0167 __u8 ErrorContextCount;
0168 __u8 Reserved;
0169 __le32 ByteCount;
0170 __u8 ErrorData[1];
0171 } __packed;
0172
0173 #define SMB3_AES_CCM_NONCE 11
0174 #define SMB3_AES_GCM_NONCE 12
0175
0176
0177 #define TRANSFORM_FLAG_ENCRYPTED 0x0001
0178 struct smb2_transform_hdr {
0179 __le32 ProtocolId;
0180 __u8 Signature[16];
0181 __u8 Nonce[16];
0182 __le32 OriginalMessageSize;
0183 __u16 Reserved1;
0184 __le16 Flags;
0185 __le64 SessionId;
0186 } __packed;
0187
0188
0189
0190 struct smb2_compression_transform_hdr_unchained {
0191 __le32 ProtocolId;
0192 __le32 OriginalCompressedSegmentSize;
0193 __le16 CompressionAlgorithm;
0194 __le16 Flags;
0195 __le16 Length;
0196 } __packed;
0197
0198
0199 #define SMB2_COMPRESSION_FLAG_NONE 0x0000
0200 #define SMB2_COMPRESSION_FLAG_CHAINED 0x0001
0201
0202 struct compression_payload_header {
0203 __le16 CompressionAlgorithm;
0204 __le16 Flags;
0205 __le32 Length;
0206
0207 } __packed;
0208
0209
0210 struct smb2_compression_transform_hdr_chained {
0211 __le32 ProtocolId;
0212 __le32 OriginalCompressedSegmentSize;
0213
0214 } __packed;
0215
0216
0217 struct compression_pattern_payload_v1 {
0218 __le16 Pattern;
0219 __le16 Reserved1;
0220 __le16 Reserved2;
0221 __le32 Repetitions;
0222 } __packed;
0223
0224
0225
0226 #define SMB2_RESERVED_TREE_CONNECT_CONTEXT_ID 0x0000
0227 #define SMB2_REMOTED_IDENTITY_TREE_CONNECT_CONTEXT_ID cpu_to_le16(0x0001)
0228
0229 struct tree_connect_contexts {
0230 __le16 ContextType;
0231 __le16 DataLength;
0232 __le32 Reserved;
0233 __u8 Data[];
0234 } __packed;
0235
0236
0237 struct smb3_blob_data {
0238 __le16 BlobSize;
0239 __u8 BlobData[];
0240 } __packed;
0241
0242
0243 #define SE_GROUP_MANDATORY 0x00000001
0244 #define SE_GROUP_ENABLED_BY_DEFAULT 0x00000002
0245 #define SE_GROUP_ENABLED 0x00000004
0246 #define SE_GROUP_OWNER 0x00000008
0247 #define SE_GROUP_USE_FOR_DENY_ONLY 0x00000010
0248 #define SE_GROUP_INTEGRITY 0x00000020
0249 #define SE_GROUP_INTEGRITY_ENABLED 0x00000040
0250 #define SE_GROUP_RESOURCE 0x20000000
0251 #define SE_GROUP_LOGON_ID 0xC0000000
0252
0253
0254
0255 struct sid_array_data {
0256 __le16 SidAttrCount;
0257
0258 } __packed;
0259
0260 struct luid_attr_data {
0261
0262 } __packed;
0263
0264
0265
0266
0267
0268
0269 struct privilege_array_data {
0270 __le16 PrivilegeCount;
0271
0272 } __packed;
0273
0274 struct remoted_identity_tcon_context {
0275 __le16 TicketType;
0276 __le16 TicketSize;
0277 __le16 User;
0278 __le16 UserName;
0279 __le16 Domain;
0280 __le16 Groups;
0281 __le16 RestrictedGroups;
0282 __le16 Privileges;
0283 __le16 PrimaryGroup;
0284 __le16 Owner;
0285 __le16 DefaultDacl;
0286 __le16 DeviceGroups;
0287 __le16 UserClaims;
0288 __le16 DeviceClaims;
0289 __u8 TicketInfo[];
0290 } __packed;
0291
0292 struct smb2_tree_connect_req_extension {
0293 __le32 TreeConnectContextOffset;
0294 __le16 TreeConnectContextCount;
0295 __u8 Reserved[10];
0296 __u8 PathName[];
0297
0298 } __packed;
0299
0300
0301 #define SMB2_TREE_CONNECT_FLAG_CLUSTER_RECONNECT cpu_to_le16(0x0001)
0302 #define SMB2_TREE_CONNECT_FLAG_REDIRECT_TO_OWNER cpu_to_le16(0x0002)
0303 #define SMB2_TREE_CONNECT_FLAG_EXTENSION_PRESENT cpu_to_le16(0x0004)
0304
0305 struct smb2_tree_connect_req {
0306 struct smb2_hdr hdr;
0307 __le16 StructureSize;
0308 __le16 Flags;
0309 __le16 PathOffset;
0310 __le16 PathLength;
0311 __u8 Buffer[1];
0312 } __packed;
0313
0314
0315 #define SMB2_SHARE_TYPE_DISK 0x01
0316 #define SMB2_SHARE_TYPE_PIPE 0x02
0317 #define SMB2_SHARE_TYPE_PRINT 0x03
0318
0319
0320
0321
0322
0323
0324 #define SMB2_SHAREFLAG_MANUAL_CACHING 0x00000000
0325 #define SMB2_SHAREFLAG_AUTO_CACHING 0x00000010
0326 #define SMB2_SHAREFLAG_VDO_CACHING 0x00000020
0327 #define SMB2_SHAREFLAG_NO_CACHING 0x00000030
0328 #define SHI1005_FLAGS_DFS 0x00000001
0329 #define SHI1005_FLAGS_DFS_ROOT 0x00000002
0330 #define SHI1005_FLAGS_RESTRICT_EXCLUSIVE_OPENS 0x00000100
0331 #define SHI1005_FLAGS_FORCE_SHARED_DELETE 0x00000200
0332 #define SHI1005_FLAGS_ALLOW_NAMESPACE_CACHING 0x00000400
0333 #define SHI1005_FLAGS_ACCESS_BASED_DIRECTORY_ENUM 0x00000800
0334 #define SHI1005_FLAGS_FORCE_LEVELII_OPLOCK 0x00001000
0335 #define SHI1005_FLAGS_ENABLE_HASH_V1 0x00002000
0336 #define SHI1005_FLAGS_ENABLE_HASH_V2 0x00004000
0337 #define SHI1005_FLAGS_ENCRYPT_DATA 0x00008000
0338 #define SMB2_SHAREFLAG_IDENTITY_REMOTING 0x00040000
0339 #define SMB2_SHAREFLAG_COMPRESS_DATA 0x00100000
0340 #define SHI1005_FLAGS_ALL 0x0014FF33
0341
0342
0343 #define SMB2_SHARE_CAP_DFS cpu_to_le32(0x00000008)
0344 #define SMB2_SHARE_CAP_CONTINUOUS_AVAILABILITY cpu_to_le32(0x00000010)
0345 #define SMB2_SHARE_CAP_SCALEOUT cpu_to_le32(0x00000020)
0346 #define SMB2_SHARE_CAP_CLUSTER cpu_to_le32(0x00000040)
0347 #define SMB2_SHARE_CAP_ASYMMETRIC cpu_to_le32(0x00000080)
0348 #define SMB2_SHARE_CAP_REDIRECT_TO_OWNER cpu_to_le32(0x00000100)
0349
0350 struct smb2_tree_connect_rsp {
0351 struct smb2_hdr hdr;
0352 __le16 StructureSize;
0353 __u8 ShareType;
0354 __u8 Reserved;
0355 __le32 ShareFlags;
0356 __le32 Capabilities;
0357 __le32 MaximalAccess;
0358 } __packed;
0359
0360 struct smb2_tree_disconnect_req {
0361 struct smb2_hdr hdr;
0362 __le16 StructureSize;
0363 __le16 Reserved;
0364 } __packed;
0365
0366 struct smb2_tree_disconnect_rsp {
0367 struct smb2_hdr hdr;
0368 __le16 StructureSize;
0369 __le16 Reserved;
0370 } __packed;
0371
0372
0373
0374
0375
0376
0377 #define SMB2_NEGOTIATE_SIGNING_ENABLED 0x0001
0378 #define SMB2_NEGOTIATE_SIGNING_ENABLED_LE cpu_to_le16(0x0001)
0379 #define SMB2_NEGOTIATE_SIGNING_REQUIRED 0x0002
0380 #define SMB2_NEGOTIATE_SIGNING_REQUIRED_LE cpu_to_le16(0x0002)
0381 #define SMB2_SEC_MODE_FLAGS_ALL 0x0003
0382
0383
0384 #define SMB2_GLOBAL_CAP_DFS 0x00000001
0385 #define SMB2_GLOBAL_CAP_LEASING 0x00000002
0386 #define SMB2_GLOBAL_CAP_LARGE_MTU 0X00000004
0387 #define SMB2_GLOBAL_CAP_MULTI_CHANNEL 0x00000008
0388 #define SMB2_GLOBAL_CAP_PERSISTENT_HANDLES 0x00000010
0389 #define SMB2_GLOBAL_CAP_DIRECTORY_LEASING 0x00000020
0390 #define SMB2_GLOBAL_CAP_ENCRYPTION 0x00000040
0391
0392 #define SMB2_NT_FIND 0x00100000
0393 #define SMB2_LARGE_FILES 0x00200000
0394
0395 #define SMB2_CLIENT_GUID_SIZE 16
0396 #define SMB2_CREATE_GUID_SIZE 16
0397
0398
0399 #define SMB10_PROT_ID 0x0000
0400 #define SMB20_PROT_ID 0x0202
0401 #define SMB21_PROT_ID 0x0210
0402 #define SMB2X_PROT_ID 0x02FF
0403 #define SMB30_PROT_ID 0x0300
0404 #define SMB302_PROT_ID 0x0302
0405 #define SMB311_PROT_ID 0x0311
0406 #define BAD_PROT_ID 0xFFFF
0407
0408 #define SMB311_SALT_SIZE 32
0409
0410 #define SMB2_PREAUTH_INTEGRITY_SHA512 cpu_to_le16(0x0001)
0411 #define SMB2_PREAUTH_HASH_SIZE 64
0412
0413
0414 #define SMB2_PREAUTH_INTEGRITY_CAPABILITIES cpu_to_le16(1)
0415 #define SMB2_ENCRYPTION_CAPABILITIES cpu_to_le16(2)
0416 #define SMB2_COMPRESSION_CAPABILITIES cpu_to_le16(3)
0417 #define SMB2_NETNAME_NEGOTIATE_CONTEXT_ID cpu_to_le16(5)
0418 #define SMB2_TRANSPORT_CAPABILITIES cpu_to_le16(6)
0419 #define SMB2_RDMA_TRANSFORM_CAPABILITIES cpu_to_le16(7)
0420 #define SMB2_SIGNING_CAPABILITIES cpu_to_le16(8)
0421 #define SMB2_POSIX_EXTENSIONS_AVAILABLE cpu_to_le16(0x100)
0422
0423 struct smb2_neg_context {
0424 __le16 ContextType;
0425 __le16 DataLength;
0426 __le32 Reserved;
0427
0428 } __packed;
0429
0430
0431
0432
0433
0434
0435
0436
0437 #define MIN_PREAUTH_CTXT_DATA_LEN 6
0438
0439 struct smb2_preauth_neg_context {
0440 __le16 ContextType;
0441 __le16 DataLength;
0442 __le32 Reserved;
0443 __le16 HashAlgorithmCount;
0444 __le16 SaltLength;
0445 __le16 HashAlgorithms;
0446 __u8 Salt[SMB311_SALT_SIZE];
0447 } __packed;
0448
0449
0450 #define SMB2_ENCRYPTION_AES128_CCM cpu_to_le16(0x0001)
0451 #define SMB2_ENCRYPTION_AES128_GCM cpu_to_le16(0x0002)
0452 #define SMB2_ENCRYPTION_AES256_CCM cpu_to_le16(0x0003)
0453 #define SMB2_ENCRYPTION_AES256_GCM cpu_to_le16(0x0004)
0454
0455
0456 #define MIN_ENCRYPT_CTXT_DATA_LEN 4
0457 struct smb2_encryption_neg_context {
0458 __le16 ContextType;
0459 __le16 DataLength;
0460 __le32 Reserved;
0461
0462 __le16 CipherCount;
0463 __le16 Ciphers[];
0464 } __packed;
0465
0466
0467 #define SMB3_COMPRESS_NONE cpu_to_le16(0x0000)
0468 #define SMB3_COMPRESS_LZNT1 cpu_to_le16(0x0001)
0469 #define SMB3_COMPRESS_LZ77 cpu_to_le16(0x0002)
0470 #define SMB3_COMPRESS_LZ77_HUFF cpu_to_le16(0x0003)
0471
0472 #define SMB3_COMPRESS_PATTERN cpu_to_le16(0x0004)
0473
0474
0475 #define SMB2_COMPRESSION_CAPABILITIES_FLAG_NONE cpu_to_le32(0x00000000)
0476 #define SMB2_COMPRESSION_CAPABILITIES_FLAG_CHAINED cpu_to_le32(0x00000001)
0477
0478 struct smb2_compression_capabilities_context {
0479 __le16 ContextType;
0480 __le16 DataLength;
0481 __le32 Reserved;
0482 __le16 CompressionAlgorithmCount;
0483 __le16 Padding;
0484 __le32 Flags;
0485 __le16 CompressionAlgorithms[3];
0486 __u16 Pad;
0487
0488 } __packed;
0489
0490
0491
0492
0493
0494 struct smb2_netname_neg_context {
0495 __le16 ContextType;
0496 __le16 DataLength;
0497 __le32 Reserved;
0498 __le16 NetName[];
0499 } __packed;
0500
0501
0502
0503
0504
0505
0506
0507 #define SMB2_ACCEPT_TRANSPORT_LEVEL_SECURITY 0x00000001
0508
0509 struct smb2_transport_capabilities_context {
0510 __le16 ContextType;
0511 __le16 DataLength;
0512 __u32 Reserved;
0513 __le32 Flags;
0514 __u32 Pad;
0515 } __packed;
0516
0517
0518
0519
0520
0521
0522
0523 #define SMB2_RDMA_TRANSFORM_NONE 0x0000
0524 #define SMB2_RDMA_TRANSFORM_ENCRYPTION 0x0001
0525 #define SMB2_RDMA_TRANSFORM_SIGNING 0x0002
0526
0527 struct smb2_rdma_transform_capabilities_context {
0528 __le16 ContextType;
0529 __le16 DataLength;
0530 __u32 Reserved;
0531 __le16 TransformCount;
0532 __u16 Reserved1;
0533 __u32 Reserved2;
0534 __le16 RDMATransformIds[];
0535 } __packed;
0536
0537
0538
0539
0540
0541
0542
0543 #define SIGNING_ALG_HMAC_SHA256 0
0544 #define SIGNING_ALG_HMAC_SHA256_LE cpu_to_le16(0)
0545 #define SIGNING_ALG_AES_CMAC 1
0546 #define SIGNING_ALG_AES_CMAC_LE cpu_to_le16(1)
0547 #define SIGNING_ALG_AES_GMAC 2
0548 #define SIGNING_ALG_AES_GMAC_LE cpu_to_le16(2)
0549
0550 struct smb2_signing_capabilities {
0551 __le16 ContextType;
0552 __le16 DataLength;
0553 __le32 Reserved;
0554 __le16 SigningAlgorithmCount;
0555 __le16 SigningAlgorithms[];
0556
0557 } __packed;
0558
0559 #define POSIX_CTXT_DATA_LEN 16
0560 struct smb2_posix_neg_context {
0561 __le16 ContextType;
0562 __le16 DataLength;
0563 __le32 Reserved;
0564 __u8 Name[16];
0565 } __packed;
0566
0567 struct smb2_negotiate_req {
0568 struct smb2_hdr hdr;
0569 __le16 StructureSize;
0570 __le16 DialectCount;
0571 __le16 SecurityMode;
0572 __le16 Reserved;
0573 __le32 Capabilities;
0574 __u8 ClientGUID[SMB2_CLIENT_GUID_SIZE];
0575
0576 __le32 NegotiateContextOffset;
0577 __le16 NegotiateContextCount;
0578 __le16 Reserved2;
0579 __le16 Dialects[];
0580 } __packed;
0581
0582 struct smb2_negotiate_rsp {
0583 struct smb2_hdr hdr;
0584 __le16 StructureSize;
0585 __le16 SecurityMode;
0586 __le16 DialectRevision;
0587 __le16 NegotiateContextCount;
0588 __u8 ServerGUID[16];
0589 __le32 Capabilities;
0590 __le32 MaxTransactSize;
0591 __le32 MaxReadSize;
0592 __le32 MaxWriteSize;
0593 __le64 SystemTime;
0594 __le64 ServerStartTime;
0595 __le16 SecurityBufferOffset;
0596 __le16 SecurityBufferLength;
0597 __le32 NegotiateContextOffset;
0598 __u8 Buffer[1];
0599 } __packed;
0600
0601
0602
0603
0604
0605
0606 #define SMB2_SESSION_REQ_FLAG_BINDING 0x01
0607 #define SMB2_SESSION_REQ_FLAG_ENCRYPT_DATA 0x04
0608
0609 struct smb2_sess_setup_req {
0610 struct smb2_hdr hdr;
0611 __le16 StructureSize;
0612 __u8 Flags;
0613 __u8 SecurityMode;
0614 __le32 Capabilities;
0615 __le32 Channel;
0616 __le16 SecurityBufferOffset;
0617 __le16 SecurityBufferLength;
0618 __le64 PreviousSessionId;
0619 __u8 Buffer[1];
0620 } __packed;
0621
0622
0623 #define SMB2_SESSION_FLAG_IS_GUEST 0x0001
0624 #define SMB2_SESSION_FLAG_IS_GUEST_LE cpu_to_le16(0x0001)
0625 #define SMB2_SESSION_FLAG_IS_NULL 0x0002
0626 #define SMB2_SESSION_FLAG_IS_NULL_LE cpu_to_le16(0x0002)
0627 #define SMB2_SESSION_FLAG_ENCRYPT_DATA 0x0004
0628 #define SMB2_SESSION_FLAG_ENCRYPT_DATA_LE cpu_to_le16(0x0004)
0629
0630 struct smb2_sess_setup_rsp {
0631 struct smb2_hdr hdr;
0632 __le16 StructureSize;
0633 __le16 SessionFlags;
0634 __le16 SecurityBufferOffset;
0635 __le16 SecurityBufferLength;
0636 __u8 Buffer[1];
0637 } __packed;
0638
0639
0640
0641
0642
0643 struct smb2_logoff_req {
0644 struct smb2_hdr hdr;
0645 __le16 StructureSize;
0646 __le16 Reserved;
0647 } __packed;
0648
0649 struct smb2_logoff_rsp {
0650 struct smb2_hdr hdr;
0651 __le16 StructureSize;
0652 __le16 Reserved;
0653 } __packed;
0654
0655
0656
0657
0658
0659
0660 #define SMB2_CLOSE_FLAG_POSTQUERY_ATTRIB cpu_to_le16(0x0001)
0661 struct smb2_close_req {
0662 struct smb2_hdr hdr;
0663 __le16 StructureSize;
0664 __le16 Flags;
0665 __le32 Reserved;
0666 __u64 PersistentFileId;
0667 __u64 VolatileFileId;
0668 } __packed;
0669
0670
0671
0672
0673 #define MAX_SMB2_CLOSE_RESPONSE_SIZE 124
0674
0675 struct smb2_close_rsp {
0676 struct smb2_hdr hdr;
0677 __le16 StructureSize;
0678 __le16 Flags;
0679 __le32 Reserved;
0680 __le64 CreationTime;
0681 __le64 LastAccessTime;
0682 __le64 LastWriteTime;
0683 __le64 ChangeTime;
0684 __le64 AllocationSize;
0685 __le64 EndOfFile;
0686 __le32 Attributes;
0687 } __packed;
0688
0689
0690
0691
0692
0693
0694 #define SMB2_READFLAG_READ_UNBUFFERED 0x01
0695 #define SMB2_READFLAG_REQUEST_COMPRESSED 0x02
0696
0697
0698 #define SMB2_CHANNEL_NONE cpu_to_le32(0x00000000)
0699 #define SMB2_CHANNEL_RDMA_V1 cpu_to_le32(0x00000001)
0700 #define SMB2_CHANNEL_RDMA_V1_INVALIDATE cpu_to_le32(0x00000002)
0701 #define SMB2_CHANNEL_RDMA_TRANSFORM cpu_to_le32(0x00000003)
0702
0703
0704 struct smb2_read_req {
0705 struct smb2_hdr hdr;
0706 __le16 StructureSize;
0707 __u8 Padding;
0708 __u8 Flags;
0709 __le32 Length;
0710 __le64 Offset;
0711 __u64 PersistentFileId;
0712 __u64 VolatileFileId;
0713 __le32 MinimumCount;
0714 __le32 Channel;
0715 __le32 RemainingBytes;
0716 __le16 ReadChannelInfoOffset;
0717 __le16 ReadChannelInfoLength;
0718 __u8 Buffer[1];
0719 } __packed;
0720
0721
0722 #define SMB2_READFLAG_RESPONSE_NONE cpu_to_le32(0x00000000)
0723 #define SMB2_READFLAG_RESPONSE_RDMA_TRANSFORM cpu_to_le32(0x00000001)
0724
0725 struct smb2_read_rsp {
0726 struct smb2_hdr hdr;
0727 __le16 StructureSize;
0728 __u8 DataOffset;
0729 __u8 Reserved;
0730 __le32 DataLength;
0731 __le32 DataRemaining;
0732 __le32 Flags;
0733 __u8 Buffer[1];
0734 } __packed;
0735
0736
0737
0738
0739
0740
0741 #define SMB2_WRITEFLAG_WRITE_THROUGH 0x00000001
0742 #define SMB2_WRITEFLAG_WRITE_UNBUFFERED 0x00000002
0743
0744 struct smb2_write_req {
0745 struct smb2_hdr hdr;
0746 __le16 StructureSize;
0747 __le16 DataOffset;
0748 __le32 Length;
0749 __le64 Offset;
0750 __u64 PersistentFileId;
0751 __u64 VolatileFileId;
0752 __le32 Channel;
0753 __le32 RemainingBytes;
0754 __le16 WriteChannelInfoOffset;
0755 __le16 WriteChannelInfoLength;
0756 __le32 Flags;
0757 __u8 Buffer[1];
0758 } __packed;
0759
0760 struct smb2_write_rsp {
0761 struct smb2_hdr hdr;
0762 __le16 StructureSize;
0763 __u8 DataOffset;
0764 __u8 Reserved;
0765 __le32 DataLength;
0766 __le32 DataRemaining;
0767 __u32 Reserved2;
0768 __u8 Buffer[1];
0769 } __packed;
0770
0771
0772
0773
0774
0775 struct smb2_flush_req {
0776 struct smb2_hdr hdr;
0777 __le16 StructureSize;
0778 __le16 Reserved1;
0779 __le32 Reserved2;
0780 __u64 PersistentFileId;
0781 __u64 VolatileFileId;
0782 } __packed;
0783
0784 struct smb2_flush_rsp {
0785 struct smb2_hdr hdr;
0786 __le16 StructureSize;
0787 __le16 Reserved;
0788 } __packed;
0789
0790 #define SMB2_LOCKFLAG_SHARED 0x0001
0791 #define SMB2_LOCKFLAG_EXCLUSIVE 0x0002
0792 #define SMB2_LOCKFLAG_UNLOCK 0x0004
0793 #define SMB2_LOCKFLAG_FAIL_IMMEDIATELY 0x0010
0794 #define SMB2_LOCKFLAG_MASK 0x0007
0795
0796 struct smb2_lock_element {
0797 __le64 Offset;
0798 __le64 Length;
0799 __le32 Flags;
0800 __le32 Reserved;
0801 } __packed;
0802
0803 struct smb2_lock_req {
0804 struct smb2_hdr hdr;
0805 __le16 StructureSize;
0806 __le16 LockCount;
0807
0808
0809
0810
0811 __le32 LockSequenceNumber;
0812 __u64 PersistentFileId;
0813 __u64 VolatileFileId;
0814
0815 struct smb2_lock_element locks[1];
0816 } __packed;
0817
0818 struct smb2_lock_rsp {
0819 struct smb2_hdr hdr;
0820 __le16 StructureSize;
0821 __le16 Reserved;
0822 } __packed;
0823
0824 struct smb2_echo_req {
0825 struct smb2_hdr hdr;
0826 __le16 StructureSize;
0827 __u16 Reserved;
0828 } __packed;
0829
0830 struct smb2_echo_rsp {
0831 struct smb2_hdr hdr;
0832 __le16 StructureSize;
0833 __u16 Reserved;
0834 } __packed;
0835
0836
0837
0838
0839
0840
0841
0842
0843
0844
0845
0846
0847
0848
0849
0850
0851
0852
0853 #define SMB2_RESTART_SCANS 0x01
0854 #define SMB2_RETURN_SINGLE_ENTRY 0x02
0855 #define SMB2_INDEX_SPECIFIED 0x04
0856 #define SMB2_REOPEN 0x10
0857
0858 struct smb2_query_directory_req {
0859 struct smb2_hdr hdr;
0860 __le16 StructureSize;
0861 __u8 FileInformationClass;
0862 __u8 Flags;
0863 __le32 FileIndex;
0864 __u64 PersistentFileId;
0865 __u64 VolatileFileId;
0866 __le16 FileNameOffset;
0867 __le16 FileNameLength;
0868 __le32 OutputBufferLength;
0869 __u8 Buffer[1];
0870 } __packed;
0871
0872 struct smb2_query_directory_rsp {
0873 struct smb2_hdr hdr;
0874 __le16 StructureSize;
0875 __le16 OutputBufferOffset;
0876 __le32 OutputBufferLength;
0877 __u8 Buffer[1];
0878 } __packed;
0879
0880
0881
0882
0883
0884
0885
0886
0887 #define SMB2_SET_INFO_IOV_SIZE 3
0888
0889 struct smb2_set_info_req {
0890 struct smb2_hdr hdr;
0891 __le16 StructureSize;
0892 __u8 InfoType;
0893 __u8 FileInfoClass;
0894 __le32 BufferLength;
0895 __le16 BufferOffset;
0896 __u16 Reserved;
0897 __le32 AdditionalInformation;
0898 __u64 PersistentFileId;
0899 __u64 VolatileFileId;
0900 __u8 Buffer[1];
0901 } __packed;
0902
0903 struct smb2_set_info_rsp {
0904 struct smb2_hdr hdr;
0905 __le16 StructureSize;
0906 } __packed;
0907
0908
0909
0910
0911
0912 #define SMB2_WATCH_TREE 0x0001
0913
0914
0915 #define FILE_NOTIFY_CHANGE_FILE_NAME 0x00000001
0916 #define FILE_NOTIFY_CHANGE_DIR_NAME 0x00000002
0917 #define FILE_NOTIFY_CHANGE_ATTRIBUTES 0x00000004
0918 #define FILE_NOTIFY_CHANGE_SIZE 0x00000008
0919 #define FILE_NOTIFY_CHANGE_LAST_WRITE 0x00000010
0920 #define FILE_NOTIFY_CHANGE_LAST_ACCESS 0x00000020
0921 #define FILE_NOTIFY_CHANGE_CREATION 0x00000040
0922 #define FILE_NOTIFY_CHANGE_EA 0x00000080
0923 #define FILE_NOTIFY_CHANGE_SECURITY 0x00000100
0924 #define FILE_NOTIFY_CHANGE_STREAM_NAME 0x00000200
0925 #define FILE_NOTIFY_CHANGE_STREAM_SIZE 0x00000400
0926 #define FILE_NOTIFY_CHANGE_STREAM_WRITE 0x00000800
0927
0928
0929 #define FILE_ACTION_ADDED 0x00000001
0930 #define FILE_ACTION_REMOVED 0x00000002
0931 #define FILE_ACTION_MODIFIED 0x00000003
0932 #define FILE_ACTION_RENAMED_OLD_NAME 0x00000004
0933 #define FILE_ACTION_RENAMED_NEW_NAME 0x00000005
0934 #define FILE_ACTION_ADDED_STREAM 0x00000006
0935 #define FILE_ACTION_REMOVED_STREAM 0x00000007
0936 #define FILE_ACTION_MODIFIED_STREAM 0x00000008
0937 #define FILE_ACTION_REMOVED_BY_DELETE 0x00000009
0938
0939 struct smb2_change_notify_req {
0940 struct smb2_hdr hdr;
0941 __le16 StructureSize;
0942 __le16 Flags;
0943 __le32 OutputBufferLength;
0944 __u64 PersistentFileId;
0945 __u64 VolatileFileId;
0946 __le32 CompletionFilter;
0947 __u32 Reserved;
0948 } __packed;
0949
0950 struct smb2_change_notify_rsp {
0951 struct smb2_hdr hdr;
0952 __le16 StructureSize;
0953 __le16 OutputBufferOffset;
0954 __le32 OutputBufferLength;
0955 __u8 Buffer[1];
0956 } __packed;
0957
0958
0959
0960
0961
0962
0963 #define SMB2_OPLOCK_LEVEL_NONE 0x00
0964 #define SMB2_OPLOCK_LEVEL_II 0x01
0965 #define SMB2_OPLOCK_LEVEL_EXCLUSIVE 0x08
0966 #define SMB2_OPLOCK_LEVEL_BATCH 0x09
0967 #define SMB2_OPLOCK_LEVEL_LEASE 0xFF
0968
0969 #define SMB2_OPLOCK_LEVEL_NOCHANGE 0x99
0970
0971
0972 #define IL_ANONYMOUS cpu_to_le32(0x00000000)
0973 #define IL_IDENTIFICATION cpu_to_le32(0x00000001)
0974 #define IL_IMPERSONATION cpu_to_le32(0x00000002)
0975 #define IL_DELEGATE cpu_to_le32(0x00000003)
0976
0977
0978 #define FILE_ATTRIBUTE_READONLY 0x00000001
0979 #define FILE_ATTRIBUTE_HIDDEN 0x00000002
0980 #define FILE_ATTRIBUTE_SYSTEM 0x00000004
0981 #define FILE_ATTRIBUTE_DIRECTORY 0x00000010
0982 #define FILE_ATTRIBUTE_ARCHIVE 0x00000020
0983 #define FILE_ATTRIBUTE_NORMAL 0x00000080
0984 #define FILE_ATTRIBUTE_TEMPORARY 0x00000100
0985 #define FILE_ATTRIBUTE_SPARSE_FILE 0x00000200
0986 #define FILE_ATTRIBUTE_REPARSE_POINT 0x00000400
0987 #define FILE_ATTRIBUTE_COMPRESSED 0x00000800
0988 #define FILE_ATTRIBUTE_OFFLINE 0x00001000
0989 #define FILE_ATTRIBUTE_NOT_CONTENT_INDEXED 0x00002000
0990 #define FILE_ATTRIBUTE_ENCRYPTED 0x00004000
0991 #define FILE_ATTRIBUTE_INTEGRITY_STREAM 0x00008000
0992 #define FILE_ATTRIBUTE_NO_SCRUB_DATA 0x00020000
0993 #define FILE_ATTRIBUTE__MASK 0x00007FB7
0994
0995 #define FILE_ATTRIBUTE_READONLY_LE cpu_to_le32(0x00000001)
0996 #define FILE_ATTRIBUTE_HIDDEN_LE cpu_to_le32(0x00000002)
0997 #define FILE_ATTRIBUTE_SYSTEM_LE cpu_to_le32(0x00000004)
0998 #define FILE_ATTRIBUTE_DIRECTORY_LE cpu_to_le32(0x00000010)
0999 #define FILE_ATTRIBUTE_ARCHIVE_LE cpu_to_le32(0x00000020)
1000 #define FILE_ATTRIBUTE_NORMAL_LE cpu_to_le32(0x00000080)
1001 #define FILE_ATTRIBUTE_TEMPORARY_LE cpu_to_le32(0x00000100)
1002 #define FILE_ATTRIBUTE_SPARSE_FILE_LE cpu_to_le32(0x00000200)
1003 #define FILE_ATTRIBUTE_REPARSE_POINT_LE cpu_to_le32(0x00000400)
1004 #define FILE_ATTRIBUTE_COMPRESSED_LE cpu_to_le32(0x00000800)
1005 #define FILE_ATTRIBUTE_OFFLINE_LE cpu_to_le32(0x00001000)
1006 #define FILE_ATTRIBUTE_NOT_CONTENT_INDEXED_LE cpu_to_le32(0x00002000)
1007 #define FILE_ATTRIBUTE_ENCRYPTED_LE cpu_to_le32(0x00004000)
1008 #define FILE_ATTRIBUTE_INTEGRITY_STREAM_LE cpu_to_le32(0x00008000)
1009 #define FILE_ATTRIBUTE_NO_SCRUB_DATA_LE cpu_to_le32(0x00020000)
1010 #define FILE_ATTRIBUTE_MASK_LE cpu_to_le32(0x00007FB7)
1011
1012
1013 #define FILE_READ_DATA_LE cpu_to_le32(0x00000001)
1014 #define FILE_LIST_DIRECTORY_LE cpu_to_le32(0x00000001)
1015 #define FILE_WRITE_DATA_LE cpu_to_le32(0x00000002)
1016 #define FILE_APPEND_DATA_LE cpu_to_le32(0x00000004)
1017 #define FILE_ADD_SUBDIRECTORY_LE cpu_to_le32(0x00000004)
1018 #define FILE_READ_EA_LE cpu_to_le32(0x00000008)
1019 #define FILE_WRITE_EA_LE cpu_to_le32(0x00000010)
1020 #define FILE_EXECUTE_LE cpu_to_le32(0x00000020)
1021 #define FILE_DELETE_CHILD_LE cpu_to_le32(0x00000040)
1022 #define FILE_READ_ATTRIBUTES_LE cpu_to_le32(0x00000080)
1023 #define FILE_WRITE_ATTRIBUTES_LE cpu_to_le32(0x00000100)
1024 #define FILE_DELETE_LE cpu_to_le32(0x00010000)
1025 #define FILE_READ_CONTROL_LE cpu_to_le32(0x00020000)
1026 #define FILE_WRITE_DAC_LE cpu_to_le32(0x00040000)
1027 #define FILE_WRITE_OWNER_LE cpu_to_le32(0x00080000)
1028 #define FILE_SYNCHRONIZE_LE cpu_to_le32(0x00100000)
1029 #define FILE_ACCESS_SYSTEM_SECURITY_LE cpu_to_le32(0x01000000)
1030 #define FILE_MAXIMAL_ACCESS_LE cpu_to_le32(0x02000000)
1031 #define FILE_GENERIC_ALL_LE cpu_to_le32(0x10000000)
1032 #define FILE_GENERIC_EXECUTE_LE cpu_to_le32(0x20000000)
1033 #define FILE_GENERIC_WRITE_LE cpu_to_le32(0x40000000)
1034 #define FILE_GENERIC_READ_LE cpu_to_le32(0x80000000)
1035 #define DESIRED_ACCESS_MASK cpu_to_le32(0xF21F01FF)
1036
1037
1038 #define FILE_READ_DESIRED_ACCESS_LE (FILE_READ_DATA_LE | \
1039 FILE_READ_EA_LE | \
1040 FILE_GENERIC_READ_LE)
1041 #define FILE_WRITE_DESIRE_ACCESS_LE (FILE_WRITE_DATA_LE | \
1042 FILE_APPEND_DATA_LE | \
1043 FILE_WRITE_EA_LE | \
1044 FILE_WRITE_ATTRIBUTES_LE | \
1045 FILE_GENERIC_WRITE_LE)
1046
1047
1048 #define FILE_SHARE_READ_LE cpu_to_le32(0x00000001)
1049 #define FILE_SHARE_WRITE_LE cpu_to_le32(0x00000002)
1050 #define FILE_SHARE_DELETE_LE cpu_to_le32(0x00000004)
1051 #define FILE_SHARE_ALL_LE cpu_to_le32(0x00000007)
1052
1053
1054 #define FILE_SUPERSEDE_LE cpu_to_le32(0x00000000)
1055 #define FILE_OPEN_LE cpu_to_le32(0x00000001)
1056 #define FILE_CREATE_LE cpu_to_le32(0x00000002)
1057 #define FILE_OPEN_IF_LE cpu_to_le32(0x00000003)
1058 #define FILE_OVERWRITE_LE cpu_to_le32(0x00000004)
1059 #define FILE_OVERWRITE_IF_LE cpu_to_le32(0x00000005)
1060 #define FILE_CREATE_MASK_LE cpu_to_le32(0x00000007)
1061
1062 #define FILE_READ_RIGHTS (FILE_READ_DATA | FILE_READ_EA \
1063 | FILE_READ_ATTRIBUTES)
1064 #define FILE_WRITE_RIGHTS (FILE_WRITE_DATA | FILE_APPEND_DATA \
1065 | FILE_WRITE_EA | FILE_WRITE_ATTRIBUTES)
1066 #define FILE_EXEC_RIGHTS (FILE_EXECUTE)
1067
1068
1069 #define FILE_DIRECTORY_FILE_LE cpu_to_le32(0x00000001)
1070
1071 #define FILE_WRITE_THROUGH_LE cpu_to_le32(0x00000002)
1072 #define FILE_SEQUENTIAL_ONLY_LE cpu_to_le32(0x00000004)
1073 #define FILE_NO_INTERMEDIATE_BUFFERING_LE cpu_to_le32(0x00000008)
1074 #define FILE_NON_DIRECTORY_FILE_LE cpu_to_le32(0x00000040)
1075 #define FILE_COMPLETE_IF_OPLOCKED_LE cpu_to_le32(0x00000100)
1076 #define FILE_NO_EA_KNOWLEDGE_LE cpu_to_le32(0x00000200)
1077 #define FILE_RANDOM_ACCESS_LE cpu_to_le32(0x00000800)
1078 #define FILE_DELETE_ON_CLOSE_LE cpu_to_le32(0x00001000)
1079 #define FILE_OPEN_BY_FILE_ID_LE cpu_to_le32(0x00002000)
1080 #define FILE_OPEN_FOR_BACKUP_INTENT_LE cpu_to_le32(0x00004000)
1081 #define FILE_NO_COMPRESSION_LE cpu_to_le32(0x00008000)
1082 #define FILE_OPEN_REPARSE_POINT_LE cpu_to_le32(0x00200000)
1083 #define FILE_OPEN_NO_RECALL_LE cpu_to_le32(0x00400000)
1084 #define CREATE_OPTIONS_MASK_LE cpu_to_le32(0x00FFFFFF)
1085
1086 #define FILE_READ_RIGHTS_LE (FILE_READ_DATA_LE | FILE_READ_EA_LE \
1087 | FILE_READ_ATTRIBUTES_LE)
1088 #define FILE_WRITE_RIGHTS_LE (FILE_WRITE_DATA_LE | FILE_APPEND_DATA_LE \
1089 | FILE_WRITE_EA_LE | FILE_WRITE_ATTRIBUTES_LE)
1090 #define FILE_EXEC_RIGHTS_LE (FILE_EXECUTE_LE)
1091
1092
1093 #define SMB2_CREATE_EA_BUFFER "ExtA"
1094 #define SMB2_CREATE_SD_BUFFER "SecD"
1095 #define SMB2_CREATE_DURABLE_HANDLE_REQUEST "DHnQ"
1096 #define SMB2_CREATE_DURABLE_HANDLE_RECONNECT "DHnC"
1097 #define SMB2_CREATE_ALLOCATION_SIZE "AISi"
1098 #define SMB2_CREATE_QUERY_MAXIMAL_ACCESS_REQUEST "MxAc"
1099 #define SMB2_CREATE_TIMEWARP_REQUEST "TWrp"
1100 #define SMB2_CREATE_QUERY_ON_DISK_ID "QFid"
1101 #define SMB2_CREATE_REQUEST_LEASE "RqLs"
1102 #define SMB2_CREATE_DURABLE_HANDLE_REQUEST_V2 "DH2Q"
1103 #define SMB2_CREATE_DURABLE_HANDLE_RECONNECT_V2 "DH2C"
1104 #define SMB2_CREATE_TAG_POSIX "\x93\xAD\x25\x50\x9C\xB4\x11\xE7\xB4\x23\x83\xDE\x96\x8B\xCD\x7C"
1105
1106
1107 #define SMB2_CREATE_FLAG_REPARSEPOINT 0x01
1108
1109 struct create_context {
1110 __le32 Next;
1111 __le16 NameOffset;
1112 __le16 NameLength;
1113 __le16 Reserved;
1114 __le16 DataOffset;
1115 __le32 DataLength;
1116 __u8 Buffer[];
1117 } __packed;
1118
1119 struct smb2_create_req {
1120 struct smb2_hdr hdr;
1121 __le16 StructureSize;
1122 __u8 SecurityFlags;
1123 __u8 RequestedOplockLevel;
1124 __le32 ImpersonationLevel;
1125 __le64 SmbCreateFlags;
1126 __le64 Reserved;
1127 __le32 DesiredAccess;
1128 __le32 FileAttributes;
1129 __le32 ShareAccess;
1130 __le32 CreateDisposition;
1131 __le32 CreateOptions;
1132 __le16 NameOffset;
1133 __le16 NameLength;
1134 __le32 CreateContextsOffset;
1135 __le32 CreateContextsLength;
1136 __u8 Buffer[];
1137 } __packed;
1138
1139 struct smb2_create_rsp {
1140 struct smb2_hdr hdr;
1141 __le16 StructureSize;
1142 __u8 OplockLevel;
1143 __u8 Flags;
1144 __le32 CreateAction;
1145 __le64 CreationTime;
1146 __le64 LastAccessTime;
1147 __le64 LastWriteTime;
1148 __le64 ChangeTime;
1149 __le64 AllocationSize;
1150 __le64 EndofFile;
1151 __le32 FileAttributes;
1152 __le32 Reserved2;
1153 __u64 PersistentFileId;
1154 __u64 VolatileFileId;
1155 __le32 CreateContextsOffset;
1156 __le32 CreateContextsLength;
1157 __u8 Buffer[1];
1158 } __packed;
1159
1160 struct create_posix {
1161 struct create_context ccontext;
1162 __u8 Name[16];
1163 __le32 Mode;
1164 __u32 Reserved;
1165 } __packed;
1166
1167 #define SMB2_LEASE_NONE_LE cpu_to_le32(0x00)
1168 #define SMB2_LEASE_READ_CACHING_LE cpu_to_le32(0x01)
1169 #define SMB2_LEASE_HANDLE_CACHING_LE cpu_to_le32(0x02)
1170 #define SMB2_LEASE_WRITE_CACHING_LE cpu_to_le32(0x04)
1171
1172 #define SMB2_LEASE_FLAG_BREAK_IN_PROGRESS_LE cpu_to_le32(0x02)
1173
1174 #define SMB2_LEASE_KEY_SIZE 16
1175
1176 struct lease_context {
1177 __u8 LeaseKey[SMB2_LEASE_KEY_SIZE];
1178 __le32 LeaseState;
1179 __le32 LeaseFlags;
1180 __le64 LeaseDuration;
1181 } __packed;
1182
1183 struct lease_context_v2 {
1184 __u8 LeaseKey[SMB2_LEASE_KEY_SIZE];
1185 __le32 LeaseState;
1186 __le32 LeaseFlags;
1187 __le64 LeaseDuration;
1188 __u8 ParentLeaseKey[SMB2_LEASE_KEY_SIZE];
1189 __le16 Epoch;
1190 __le16 Reserved;
1191 } __packed;
1192
1193 struct create_lease {
1194 struct create_context ccontext;
1195 __u8 Name[8];
1196 struct lease_context lcontext;
1197 } __packed;
1198
1199 struct create_lease_v2 {
1200 struct create_context ccontext;
1201 __u8 Name[8];
1202 struct lease_context_v2 lcontext;
1203 __u8 Pad[4];
1204 } __packed;
1205
1206
1207 struct smb2_ioctl_req {
1208 struct smb2_hdr hdr;
1209 __le16 StructureSize;
1210 __le16 Reserved;
1211 __le32 CtlCode;
1212 __u64 PersistentFileId;
1213 __u64 VolatileFileId;
1214 __le32 InputOffset;
1215 __le32 InputCount;
1216 __le32 MaxInputResponse;
1217 __le32 OutputOffset;
1218 __le32 OutputCount;
1219 __le32 MaxOutputResponse;
1220 __le32 Flags;
1221 __le32 Reserved2;
1222 __u8 Buffer[];
1223 } __packed;
1224
1225 struct smb2_ioctl_rsp {
1226 struct smb2_hdr hdr;
1227 __le16 StructureSize;
1228 __le16 Reserved;
1229 __le32 CtlCode;
1230 __u64 PersistentFileId;
1231 __u64 VolatileFileId;
1232 __le32 InputOffset;
1233 __le32 InputCount;
1234 __le32 OutputOffset;
1235 __le32 OutputCount;
1236 __le32 Flags;
1237 __le32 Reserved2;
1238 __u8 Buffer[];
1239 } __packed;
1240
1241
1242 struct file_zero_data_information {
1243 __le64 FileOffset;
1244 __le64 BeyondFinalZero;
1245 } __packed;
1246
1247
1248 struct duplicate_extents_to_file {
1249 __u64 PersistentFileHandle;
1250 __u64 VolatileFileHandle;
1251 __le64 SourceFileOffset;
1252 __le64 TargetFileOffset;
1253 __le64 ByteCount;
1254 } __packed;
1255
1256
1257 #define DUPLICATE_EXTENTS_DATA_EX_SOURCE_ATOMIC 0x00000001
1258 struct duplicate_extents_to_file_ex {
1259 __u64 PersistentFileHandle;
1260 __u64 VolatileFileHandle;
1261 __le64 SourceFileOffset;
1262 __le64 TargetFileOffset;
1263 __le64 ByteCount;
1264 __le32 Flags;
1265 __le32 Reserved;
1266 } __packed;
1267
1268
1269
1270 struct fsctl_get_integrity_information_rsp {
1271 __le16 ChecksumAlgorithm;
1272 __le16 Reserved;
1273 __le32 Flags;
1274 __le32 ChecksumChunkSizeInBytes;
1275 __le32 ClusterSizeInBytes;
1276 } __packed;
1277
1278
1279 struct fsctl_query_file_regions_req {
1280 __le64 FileOffset;
1281 __le64 Length;
1282 __le32 DesiredUsage;
1283 __le32 Reserved;
1284 } __packed;
1285
1286
1287 #define FILE_USAGE_INVALID_RANGE 0x00000000
1288 #define FILE_USAGE_VALID_CACHED_DATA 0x00000001
1289 #define FILE_USAGE_NONCACHED_DATA 0x00000002
1290
1291 struct file_region_info {
1292 __le64 FileOffset;
1293 __le64 Length;
1294 __le32 DesiredUsage;
1295 __le32 Reserved;
1296 } __packed;
1297
1298
1299 struct fsctl_query_file_region_rsp {
1300 __le32 Flags;
1301 __le32 TotalRegionEntryCount;
1302 __le32 RegionEntryCount;
1303 __u32 Reserved;
1304 struct file_region_info Regions[];
1305 } __packed;
1306
1307
1308 struct fsctl_query_on_disk_vol_info_rsp {
1309 __le64 DirectoryCount;
1310 __le64 FileCount;
1311 __le16 FsFormatMajVersion;
1312 __le16 FsFormatMinVersion;
1313 __u8 FsFormatName[24];
1314 __le64 FormatTime;
1315 __le64 LastUpdateTime;
1316 __u8 CopyrightInfo[68];
1317 __u8 AbstractInfo[68];
1318 __u8 FormatImplInfo[68];
1319 __u8 LastModifyImplInfo[68];
1320 } __packed;
1321
1322
1323 struct fsctl_set_integrity_information_req {
1324 __le16 ChecksumAlgorithm;
1325 __le16 Reserved;
1326 __le32 Flags;
1327 } __packed;
1328
1329
1330 struct fsctl_set_integrity_info_ex_req {
1331 __u8 EnableIntegrity;
1332 __u8 KeepState;
1333 __u16 Reserved;
1334 __le32 Flags;
1335 __u8 Version;
1336 __u8 Reserved2[7];
1337 } __packed;
1338
1339
1340 #define CHECKSUM_TYPE_NONE 0x0000
1341 #define CHECKSUM_TYPE_CRC64 0x0002
1342 #define CHECKSUM_TYPE_UNCHANGED 0xFFFF
1343
1344
1345 #define FSCTL_INTEGRITY_FLAG_CHECKSUM_ENFORCEMENT_OFF 0x00000001
1346
1347
1348
1349
1350 struct reparse_data_buffer {
1351 __le32 ReparseTag;
1352 __le16 ReparseDataLength;
1353 __u16 Reserved;
1354 __u8 DataBuffer[];
1355 } __packed;
1356
1357 struct reparse_guid_data_buffer {
1358 __le32 ReparseTag;
1359 __le16 ReparseDataLength;
1360 __u16 Reserved;
1361 __u8 ReparseGuid[16];
1362 __u8 DataBuffer[];
1363 } __packed;
1364
1365 struct reparse_mount_point_data_buffer {
1366 __le32 ReparseTag;
1367 __le16 ReparseDataLength;
1368 __u16 Reserved;
1369 __le16 SubstituteNameOffset;
1370 __le16 SubstituteNameLength;
1371 __le16 PrintNameOffset;
1372 __le16 PrintNameLength;
1373 __u8 PathBuffer[];
1374 } __packed;
1375
1376 #define SYMLINK_FLAG_RELATIVE 0x00000001
1377
1378 struct reparse_symlink_data_buffer {
1379 __le32 ReparseTag;
1380 __le16 ReparseDataLength;
1381 __u16 Reserved;
1382 __le16 SubstituteNameOffset;
1383 __le16 SubstituteNameLength;
1384 __le16 PrintNameOffset;
1385 __le16 PrintNameLength;
1386 __le32 Flags;
1387 __u8 PathBuffer[];
1388 } __packed;
1389
1390
1391
1392 struct validate_negotiate_info_req {
1393 __le32 Capabilities;
1394 __u8 Guid[SMB2_CLIENT_GUID_SIZE];
1395 __le16 SecurityMode;
1396 __le16 DialectCount;
1397 __le16 Dialects[4];
1398 } __packed;
1399
1400 struct validate_negotiate_info_rsp {
1401 __le32 Capabilities;
1402 __u8 Guid[SMB2_CLIENT_GUID_SIZE];
1403 __le16 SecurityMode;
1404 __le16 Dialect;
1405 } __packed;
1406
1407
1408
1409 #define SMB2_O_INFO_FILE 0x01
1410 #define SMB2_O_INFO_FILESYSTEM 0x02
1411 #define SMB2_O_INFO_SECURITY 0x03
1412 #define SMB2_O_INFO_QUOTA 0x04
1413
1414
1415
1416
1417 #define FILE_DIRECTORY_INFORMATION 1
1418 #define FILE_FULL_DIRECTORY_INFORMATION 2
1419 #define FILE_BOTH_DIRECTORY_INFORMATION 3
1420 #define FILE_BASIC_INFORMATION 4
1421 #define FILE_STANDARD_INFORMATION 5
1422 #define FILE_INTERNAL_INFORMATION 6
1423 #define FILE_EA_INFORMATION 7
1424 #define FILE_ACCESS_INFORMATION 8
1425 #define FILE_NAME_INFORMATION 9
1426 #define FILE_RENAME_INFORMATION 10
1427 #define FILE_LINK_INFORMATION 11
1428 #define FILE_NAMES_INFORMATION 12
1429 #define FILE_DISPOSITION_INFORMATION 13
1430 #define FILE_POSITION_INFORMATION 14
1431 #define FILE_FULL_EA_INFORMATION 15
1432 #define FILE_MODE_INFORMATION 16
1433 #define FILE_ALIGNMENT_INFORMATION 17
1434 #define FILE_ALL_INFORMATION 18
1435 #define FILE_ALLOCATION_INFORMATION 19
1436 #define FILE_END_OF_FILE_INFORMATION 20
1437 #define FILE_ALTERNATE_NAME_INFORMATION 21
1438 #define FILE_STREAM_INFORMATION 22
1439 #define FILE_PIPE_INFORMATION 23
1440 #define FILE_PIPE_LOCAL_INFORMATION 24
1441 #define FILE_PIPE_REMOTE_INFORMATION 25
1442 #define FILE_MAILSLOT_QUERY_INFORMATION 26
1443 #define FILE_MAILSLOT_SET_INFORMATION 27
1444 #define FILE_COMPRESSION_INFORMATION 28
1445 #define FILE_OBJECT_ID_INFORMATION 29
1446
1447 #define FILE_MOVE_CLUSTER_INFORMATION 31
1448 #define FILE_QUOTA_INFORMATION 32
1449 #define FILE_REPARSE_POINT_INFORMATION 33
1450 #define FILE_NETWORK_OPEN_INFORMATION 34
1451 #define FILE_ATTRIBUTE_TAG_INFORMATION 35
1452 #define FILE_TRACKING_INFORMATION 36
1453 #define FILEID_BOTH_DIRECTORY_INFORMATION 37
1454 #define FILEID_FULL_DIRECTORY_INFORMATION 38
1455 #define FILE_VALID_DATA_LENGTH_INFORMATION 39
1456 #define FILE_SHORT_NAME_INFORMATION 40
1457 #define FILE_SFIO_RESERVE_INFORMATION 44
1458 #define FILE_SFIO_VOLUME_INFORMATION 45
1459 #define FILE_HARD_LINK_INFORMATION 46
1460 #define FILE_NORMALIZED_NAME_INFORMATION 48
1461 #define FILEID_GLOBAL_TX_DIRECTORY_INFORMATION 50
1462 #define FILE_STANDARD_LINK_INFORMATION 54
1463 #define FILE_ID_INFORMATION 59
1464 #define FILE_ID_EXTD_DIRECTORY_INFORMATION 60
1465
1466 #define SMB_FIND_FILE_POSIX_INFO 0x064
1467
1468
1469 #define OWNER_SECINFO 0x00000001
1470 #define GROUP_SECINFO 0x00000002
1471 #define DACL_SECINFO 0x00000004
1472 #define SACL_SECINFO 0x00000008
1473 #define LABEL_SECINFO 0x00000010
1474 #define ATTRIBUTE_SECINFO 0x00000020
1475 #define SCOPE_SECINFO 0x00000040
1476 #define BACKUP_SECINFO 0x00010000
1477 #define UNPROTECTED_SACL_SECINFO 0x10000000
1478 #define UNPROTECTED_DACL_SECINFO 0x20000000
1479 #define PROTECTED_SACL_SECINFO 0x40000000
1480 #define PROTECTED_DACL_SECINFO 0x80000000
1481
1482
1483 #define SL_RESTART_SCAN 0x00000001
1484 #define SL_RETURN_SINGLE_ENTRY 0x00000002
1485 #define SL_INDEX_SPECIFIED 0x00000004
1486
1487 struct smb2_query_info_req {
1488 struct smb2_hdr hdr;
1489 __le16 StructureSize;
1490 __u8 InfoType;
1491 __u8 FileInfoClass;
1492 __le32 OutputBufferLength;
1493 __le16 InputBufferOffset;
1494 __u16 Reserved;
1495 __le32 InputBufferLength;
1496 __le32 AdditionalInformation;
1497 __le32 Flags;
1498 __u64 PersistentFileId;
1499 __u64 VolatileFileId;
1500 __u8 Buffer[1];
1501 } __packed;
1502
1503 struct smb2_query_info_rsp {
1504 struct smb2_hdr hdr;
1505 __le16 StructureSize;
1506 __le16 OutputBufferOffset;
1507 __le32 OutputBufferLength;
1508 __u8 Buffer[1];
1509 } __packed;
1510
1511
1512
1513
1514
1515
1516 struct file_allocated_range_buffer {
1517 __le64 file_offset;
1518 __le64 length;
1519 } __packed;
1520
1521 struct smb2_file_internal_info {
1522 __le64 IndexNumber;
1523 } __packed;
1524
1525 struct smb2_file_rename_info {
1526 __u8 ReplaceIfExists;
1527
1528 __u8 Reserved[7];
1529 __u64 RootDirectory;
1530 __le32 FileNameLength;
1531 char FileName[];
1532
1533 } __packed;
1534
1535 struct smb2_file_link_info {
1536 __u8 ReplaceIfExists;
1537
1538 __u8 Reserved[7];
1539 __u64 RootDirectory;
1540 __le32 FileNameLength;
1541 char FileName[];
1542 } __packed;
1543
1544
1545
1546
1547
1548
1549 struct smb2_file_all_info {
1550 __le64 CreationTime;
1551 __le64 LastAccessTime;
1552 __le64 LastWriteTime;
1553 __le64 ChangeTime;
1554 __le32 Attributes;
1555 __u32 Pad1;
1556 __le64 AllocationSize;
1557 __le64 EndOfFile;
1558 __le32 NumberOfLinks;
1559 __u8 DeletePending;
1560 __u8 Directory;
1561 __u16 Pad2;
1562 __le64 IndexNumber;
1563 __le32 EASize;
1564 __le32 AccessFlags;
1565 __le64 CurrentByteOffset;
1566 __le32 Mode;
1567 __le32 AlignmentRequirement;
1568 __le32 FileNameLength;
1569 char FileName[1];
1570 } __packed;
1571
1572 struct smb2_file_eof_info {
1573 __le64 EndOfFile;
1574 } __packed;
1575
1576
1577 struct smb311_posix_qinfo {
1578 __le64 CreationTime;
1579 __le64 LastAccessTime;
1580 __le64 LastWriteTime;
1581 __le64 ChangeTime;
1582 __le64 EndOfFile;
1583 __le64 AllocationSize;
1584 __le32 DosAttributes;
1585 __le64 Inode;
1586 __le32 DeviceId;
1587 __le32 Zero;
1588
1589 __le32 HardLinks;
1590 __le32 ReparseTag;
1591 __le32 Mode;
1592 u8 Sids[];
1593
1594
1595
1596
1597
1598
1599 } __packed;
1600
1601
1602 #define FS_VOLUME_INFORMATION 1
1603 #define FS_LABEL_INFORMATION 2
1604 #define FS_SIZE_INFORMATION 3
1605 #define FS_DEVICE_INFORMATION 4
1606 #define FS_ATTRIBUTE_INFORMATION 5
1607 #define FS_CONTROL_INFORMATION 6
1608 #define FS_FULL_SIZE_INFORMATION 7
1609 #define FS_OBJECT_ID_INFORMATION 8
1610 #define FS_DRIVER_PATH_INFORMATION 9
1611 #define FS_SECTOR_SIZE_INFORMATION 11
1612 #define FS_POSIX_INFORMATION 100
1613
1614 struct smb2_fs_full_size_info {
1615 __le64 TotalAllocationUnits;
1616 __le64 CallerAvailableAllocationUnits;
1617 __le64 ActualAvailableAllocationUnits;
1618 __le32 SectorsPerAllocationUnit;
1619 __le32 BytesPerSector;
1620 } __packed;
1621
1622 #define SSINFO_FLAGS_ALIGNED_DEVICE 0x00000001
1623 #define SSINFO_FLAGS_PARTITION_ALIGNED_ON_DEVICE 0x00000002
1624 #define SSINFO_FLAGS_NO_SEEK_PENALTY 0x00000004
1625 #define SSINFO_FLAGS_TRIM_ENABLED 0x00000008
1626
1627
1628 struct smb3_fs_ss_info {
1629 __le32 LogicalBytesPerSector;
1630 __le32 PhysicalBytesPerSectorForAtomicity;
1631 __le32 PhysicalBytesPerSectorForPerf;
1632 __le32 FSEffPhysicalBytesPerSectorForAtomicity;
1633 __le32 Flags;
1634 __le32 ByteOffsetForSectorAlignment;
1635 __le32 ByteOffsetForPartitionAlignment;
1636 } __packed;
1637
1638
1639 struct smb2_fs_control_info {
1640 __le64 FreeSpaceStartFiltering;
1641 __le64 FreeSpaceThreshold;
1642 __le64 FreeSpaceStopFiltering;
1643 __le64 DefaultQuotaThreshold;
1644 __le64 DefaultQuotaLimit;
1645 __le32 FileSystemControlFlags;
1646 __le32 Padding;
1647 } __packed;
1648
1649
1650 #define MAX_VOL_LABEL_LEN 32
1651 struct smb3_fs_vol_info {
1652 __le64 VolumeCreationTime;
1653 __u32 VolumeSerialNumber;
1654 __le32 VolumeLabelLength;
1655 __u8 SupportsObjects;
1656 __u8 Reserved;
1657 __u8 VolumeLabel[];
1658 } __packed;
1659
1660
1661 struct smb2_oplock_break {
1662 struct smb2_hdr hdr;
1663 __le16 StructureSize;
1664 __u8 OplockLevel;
1665 __u8 Reserved;
1666 __le32 Reserved2;
1667 __u64 PersistentFid;
1668 __u64 VolatileFid;
1669 } __packed;
1670
1671 #define SMB2_NOTIFY_BREAK_LEASE_FLAG_ACK_REQUIRED cpu_to_le32(0x01)
1672
1673 struct smb2_lease_break {
1674 struct smb2_hdr hdr;
1675 __le16 StructureSize;
1676 __le16 Epoch;
1677 __le32 Flags;
1678 __u8 LeaseKey[16];
1679 __le32 CurrentLeaseState;
1680 __le32 NewLeaseState;
1681 __le32 BreakReason;
1682 __le32 AccessMaskHint;
1683 __le32 ShareMaskHint;
1684 } __packed;
1685
1686 struct smb2_lease_ack {
1687 struct smb2_hdr hdr;
1688 __le16 StructureSize;
1689 __le16 Reserved;
1690 __le32 Flags;
1691 __u8 LeaseKey[16];
1692 __le32 LeaseState;
1693 __le64 LeaseDuration;
1694 } __packed;
1695
1696 #define OP_BREAK_STRUCT_SIZE_20 24
1697 #define OP_BREAK_STRUCT_SIZE_21 36
1698 #endif