162306a36Sopenharmony_ci/* SPDX-License-Identifier: LGPL-2.1 */ 262306a36Sopenharmony_ci#ifndef _COMMON_SMB2PDU_H 362306a36Sopenharmony_ci#define _COMMON_SMB2PDU_H 462306a36Sopenharmony_ci 562306a36Sopenharmony_ci/* 662306a36Sopenharmony_ci * Note that, due to trying to use names similar to the protocol specifications, 762306a36Sopenharmony_ci * there are many mixed case field names in the structures below. Although 862306a36Sopenharmony_ci * this does not match typical Linux kernel style, it is necessary to be 962306a36Sopenharmony_ci * able to match against the protocol specfication. 1062306a36Sopenharmony_ci * 1162306a36Sopenharmony_ci * SMB2 commands 1262306a36Sopenharmony_ci * Some commands have minimal (wct=0,bcc=0), or uninteresting, responses 1362306a36Sopenharmony_ci * (ie no useful data other than the SMB error code itself) and are marked such. 1462306a36Sopenharmony_ci * Knowing this helps avoid response buffer allocations and copy in some cases. 1562306a36Sopenharmony_ci */ 1662306a36Sopenharmony_ci 1762306a36Sopenharmony_ci/* List of commands in host endian */ 1862306a36Sopenharmony_ci#define SMB2_NEGOTIATE_HE 0x0000 1962306a36Sopenharmony_ci#define SMB2_SESSION_SETUP_HE 0x0001 2062306a36Sopenharmony_ci#define SMB2_LOGOFF_HE 0x0002 /* trivial request/resp */ 2162306a36Sopenharmony_ci#define SMB2_TREE_CONNECT_HE 0x0003 2262306a36Sopenharmony_ci#define SMB2_TREE_DISCONNECT_HE 0x0004 /* trivial req/resp */ 2362306a36Sopenharmony_ci#define SMB2_CREATE_HE 0x0005 2462306a36Sopenharmony_ci#define SMB2_CLOSE_HE 0x0006 2562306a36Sopenharmony_ci#define SMB2_FLUSH_HE 0x0007 /* trivial resp */ 2662306a36Sopenharmony_ci#define SMB2_READ_HE 0x0008 2762306a36Sopenharmony_ci#define SMB2_WRITE_HE 0x0009 2862306a36Sopenharmony_ci#define SMB2_LOCK_HE 0x000A 2962306a36Sopenharmony_ci#define SMB2_IOCTL_HE 0x000B 3062306a36Sopenharmony_ci#define SMB2_CANCEL_HE 0x000C 3162306a36Sopenharmony_ci#define SMB2_ECHO_HE 0x000D 3262306a36Sopenharmony_ci#define SMB2_QUERY_DIRECTORY_HE 0x000E 3362306a36Sopenharmony_ci#define SMB2_CHANGE_NOTIFY_HE 0x000F 3462306a36Sopenharmony_ci#define SMB2_QUERY_INFO_HE 0x0010 3562306a36Sopenharmony_ci#define SMB2_SET_INFO_HE 0x0011 3662306a36Sopenharmony_ci#define SMB2_OPLOCK_BREAK_HE 0x0012 3762306a36Sopenharmony_ci 3862306a36Sopenharmony_ci/* The same list in little endian */ 3962306a36Sopenharmony_ci#define SMB2_NEGOTIATE cpu_to_le16(SMB2_NEGOTIATE_HE) 4062306a36Sopenharmony_ci#define SMB2_SESSION_SETUP cpu_to_le16(SMB2_SESSION_SETUP_HE) 4162306a36Sopenharmony_ci#define SMB2_LOGOFF cpu_to_le16(SMB2_LOGOFF_HE) 4262306a36Sopenharmony_ci#define SMB2_TREE_CONNECT cpu_to_le16(SMB2_TREE_CONNECT_HE) 4362306a36Sopenharmony_ci#define SMB2_TREE_DISCONNECT cpu_to_le16(SMB2_TREE_DISCONNECT_HE) 4462306a36Sopenharmony_ci#define SMB2_CREATE cpu_to_le16(SMB2_CREATE_HE) 4562306a36Sopenharmony_ci#define SMB2_CLOSE cpu_to_le16(SMB2_CLOSE_HE) 4662306a36Sopenharmony_ci#define SMB2_FLUSH cpu_to_le16(SMB2_FLUSH_HE) 4762306a36Sopenharmony_ci#define SMB2_READ cpu_to_le16(SMB2_READ_HE) 4862306a36Sopenharmony_ci#define SMB2_WRITE cpu_to_le16(SMB2_WRITE_HE) 4962306a36Sopenharmony_ci#define SMB2_LOCK cpu_to_le16(SMB2_LOCK_HE) 5062306a36Sopenharmony_ci#define SMB2_IOCTL cpu_to_le16(SMB2_IOCTL_HE) 5162306a36Sopenharmony_ci#define SMB2_CANCEL cpu_to_le16(SMB2_CANCEL_HE) 5262306a36Sopenharmony_ci#define SMB2_ECHO cpu_to_le16(SMB2_ECHO_HE) 5362306a36Sopenharmony_ci#define SMB2_QUERY_DIRECTORY cpu_to_le16(SMB2_QUERY_DIRECTORY_HE) 5462306a36Sopenharmony_ci#define SMB2_CHANGE_NOTIFY cpu_to_le16(SMB2_CHANGE_NOTIFY_HE) 5562306a36Sopenharmony_ci#define SMB2_QUERY_INFO cpu_to_le16(SMB2_QUERY_INFO_HE) 5662306a36Sopenharmony_ci#define SMB2_SET_INFO cpu_to_le16(SMB2_SET_INFO_HE) 5762306a36Sopenharmony_ci#define SMB2_OPLOCK_BREAK cpu_to_le16(SMB2_OPLOCK_BREAK_HE) 5862306a36Sopenharmony_ci 5962306a36Sopenharmony_ci#define SMB2_INTERNAL_CMD cpu_to_le16(0xFFFF) 6062306a36Sopenharmony_ci 6162306a36Sopenharmony_ci#define NUMBER_OF_SMB2_COMMANDS 0x0013 6262306a36Sopenharmony_ci 6362306a36Sopenharmony_ci/* 6462306a36Sopenharmony_ci * Size of the session key (crypto key encrypted with the password 6562306a36Sopenharmony_ci */ 6662306a36Sopenharmony_ci#define SMB2_NTLMV2_SESSKEY_SIZE 16 6762306a36Sopenharmony_ci#define SMB2_SIGNATURE_SIZE 16 6862306a36Sopenharmony_ci#define SMB2_HMACSHA256_SIZE 32 6962306a36Sopenharmony_ci#define SMB2_CMACAES_SIZE 16 7062306a36Sopenharmony_ci#define SMB3_GCM128_CRYPTKEY_SIZE 16 7162306a36Sopenharmony_ci#define SMB3_GCM256_CRYPTKEY_SIZE 32 7262306a36Sopenharmony_ci 7362306a36Sopenharmony_ci/* 7462306a36Sopenharmony_ci * Size of the smb3 encryption/decryption keys 7562306a36Sopenharmony_ci * This size is big enough to store any cipher key types. 7662306a36Sopenharmony_ci */ 7762306a36Sopenharmony_ci#define SMB3_ENC_DEC_KEY_SIZE 32 7862306a36Sopenharmony_ci 7962306a36Sopenharmony_ci/* 8062306a36Sopenharmony_ci * Size of the smb3 signing key 8162306a36Sopenharmony_ci */ 8262306a36Sopenharmony_ci#define SMB3_SIGN_KEY_SIZE 16 8362306a36Sopenharmony_ci 8462306a36Sopenharmony_ci#define CIFS_CLIENT_CHALLENGE_SIZE 8 8562306a36Sopenharmony_ci 8662306a36Sopenharmony_ci/* Maximum buffer size value we can send with 1 credit */ 8762306a36Sopenharmony_ci#define SMB2_MAX_BUFFER_SIZE 65536 8862306a36Sopenharmony_ci 8962306a36Sopenharmony_ci/* 9062306a36Sopenharmony_ci * The default wsize is 1M for SMB2 (and for some CIFS cases). 9162306a36Sopenharmony_ci * find_get_pages seems to return a maximum of 256 9262306a36Sopenharmony_ci * pages in a single call. With PAGE_SIZE == 4k, this means we can 9362306a36Sopenharmony_ci * fill a single wsize request with a single call. 9462306a36Sopenharmony_ci */ 9562306a36Sopenharmony_ci#define SMB3_DEFAULT_IOSIZE (4 * 1024 * 1024) 9662306a36Sopenharmony_ci 9762306a36Sopenharmony_ci/* 9862306a36Sopenharmony_ci * SMB2 Header Definition 9962306a36Sopenharmony_ci * 10062306a36Sopenharmony_ci * "MBZ" : Must be Zero 10162306a36Sopenharmony_ci * "BB" : BugBug, Something to check/review/analyze later 10262306a36Sopenharmony_ci * "PDU" : "Protocol Data Unit" (ie a network "frame") 10362306a36Sopenharmony_ci * 10462306a36Sopenharmony_ci */ 10562306a36Sopenharmony_ci 10662306a36Sopenharmony_ci#define __SMB2_HEADER_STRUCTURE_SIZE 64 10762306a36Sopenharmony_ci#define SMB2_HEADER_STRUCTURE_SIZE \ 10862306a36Sopenharmony_ci cpu_to_le16(__SMB2_HEADER_STRUCTURE_SIZE) 10962306a36Sopenharmony_ci 11062306a36Sopenharmony_ci#define SMB2_PROTO_NUMBER cpu_to_le32(0x424d53fe) 11162306a36Sopenharmony_ci#define SMB2_TRANSFORM_PROTO_NUM cpu_to_le32(0x424d53fd) 11262306a36Sopenharmony_ci#define SMB2_COMPRESSION_TRANSFORM_ID cpu_to_le32(0x424d53fc) 11362306a36Sopenharmony_ci 11462306a36Sopenharmony_ci/* 11562306a36Sopenharmony_ci * SMB2 flag definitions 11662306a36Sopenharmony_ci */ 11762306a36Sopenharmony_ci#define SMB2_FLAGS_SERVER_TO_REDIR cpu_to_le32(0x00000001) 11862306a36Sopenharmony_ci#define SMB2_FLAGS_ASYNC_COMMAND cpu_to_le32(0x00000002) 11962306a36Sopenharmony_ci#define SMB2_FLAGS_RELATED_OPERATIONS cpu_to_le32(0x00000004) 12062306a36Sopenharmony_ci#define SMB2_FLAGS_SIGNED cpu_to_le32(0x00000008) 12162306a36Sopenharmony_ci#define SMB2_FLAGS_PRIORITY_MASK cpu_to_le32(0x00000070) /* SMB3.1.1 */ 12262306a36Sopenharmony_ci#define SMB2_FLAGS_DFS_OPERATIONS cpu_to_le32(0x10000000) 12362306a36Sopenharmony_ci#define SMB2_FLAGS_REPLAY_OPERATION cpu_to_le32(0x20000000) /* SMB3 & up */ 12462306a36Sopenharmony_ci 12562306a36Sopenharmony_ci/* 12662306a36Sopenharmony_ci * Definitions for SMB2 Protocol Data Units (network frames) 12762306a36Sopenharmony_ci * 12862306a36Sopenharmony_ci * See MS-SMB2.PDF specification for protocol details. 12962306a36Sopenharmony_ci * The Naming convention is the lower case version of the SMB2 13062306a36Sopenharmony_ci * command code name for the struct. Note that structures must be packed. 13162306a36Sopenharmony_ci * 13262306a36Sopenharmony_ci */ 13362306a36Sopenharmony_ci 13462306a36Sopenharmony_ci/* See MS-SMB2 section 2.2.1 */ 13562306a36Sopenharmony_cistruct smb2_hdr { 13662306a36Sopenharmony_ci __le32 ProtocolId; /* 0xFE 'S' 'M' 'B' */ 13762306a36Sopenharmony_ci __le16 StructureSize; /* 64 */ 13862306a36Sopenharmony_ci __le16 CreditCharge; /* MBZ */ 13962306a36Sopenharmony_ci __le32 Status; /* Error from server */ 14062306a36Sopenharmony_ci __le16 Command; 14162306a36Sopenharmony_ci __le16 CreditRequest; /* CreditResponse */ 14262306a36Sopenharmony_ci __le32 Flags; 14362306a36Sopenharmony_ci __le32 NextCommand; 14462306a36Sopenharmony_ci __le64 MessageId; 14562306a36Sopenharmony_ci union { 14662306a36Sopenharmony_ci struct { 14762306a36Sopenharmony_ci __le32 ProcessId; 14862306a36Sopenharmony_ci __le32 TreeId; 14962306a36Sopenharmony_ci } __packed SyncId; 15062306a36Sopenharmony_ci __le64 AsyncId; 15162306a36Sopenharmony_ci } __packed Id; 15262306a36Sopenharmony_ci __le64 SessionId; 15362306a36Sopenharmony_ci __u8 Signature[16]; 15462306a36Sopenharmony_ci} __packed; 15562306a36Sopenharmony_ci 15662306a36Sopenharmony_cistruct smb3_hdr_req { 15762306a36Sopenharmony_ci __le32 ProtocolId; /* 0xFE 'S' 'M' 'B' */ 15862306a36Sopenharmony_ci __le16 StructureSize; /* 64 */ 15962306a36Sopenharmony_ci __le16 CreditCharge; /* MBZ */ 16062306a36Sopenharmony_ci __le16 ChannelSequence; /* See MS-SMB2 3.2.4.1 and 3.2.7.1 */ 16162306a36Sopenharmony_ci __le16 Reserved; 16262306a36Sopenharmony_ci __le16 Command; 16362306a36Sopenharmony_ci __le16 CreditRequest; /* CreditResponse */ 16462306a36Sopenharmony_ci __le32 Flags; 16562306a36Sopenharmony_ci __le32 NextCommand; 16662306a36Sopenharmony_ci __le64 MessageId; 16762306a36Sopenharmony_ci union { 16862306a36Sopenharmony_ci struct { 16962306a36Sopenharmony_ci __le32 ProcessId; 17062306a36Sopenharmony_ci __le32 TreeId; 17162306a36Sopenharmony_ci } __packed SyncId; 17262306a36Sopenharmony_ci __le64 AsyncId; 17362306a36Sopenharmony_ci } __packed Id; 17462306a36Sopenharmony_ci __le64 SessionId; 17562306a36Sopenharmony_ci __u8 Signature[16]; 17662306a36Sopenharmony_ci} __packed; 17762306a36Sopenharmony_ci 17862306a36Sopenharmony_cistruct smb2_pdu { 17962306a36Sopenharmony_ci struct smb2_hdr hdr; 18062306a36Sopenharmony_ci __le16 StructureSize2; /* size of wct area (varies, request specific) */ 18162306a36Sopenharmony_ci} __packed; 18262306a36Sopenharmony_ci 18362306a36Sopenharmony_ci#define SMB2_ERROR_STRUCTURE_SIZE2 9 18462306a36Sopenharmony_ci#define SMB2_ERROR_STRUCTURE_SIZE2_LE cpu_to_le16(SMB2_ERROR_STRUCTURE_SIZE2) 18562306a36Sopenharmony_ci 18662306a36Sopenharmony_cistruct smb2_err_rsp { 18762306a36Sopenharmony_ci struct smb2_hdr hdr; 18862306a36Sopenharmony_ci __le16 StructureSize; 18962306a36Sopenharmony_ci __u8 ErrorContextCount; 19062306a36Sopenharmony_ci __u8 Reserved; 19162306a36Sopenharmony_ci __le32 ByteCount; /* even if zero, at least one byte follows */ 19262306a36Sopenharmony_ci __u8 ErrorData[]; /* variable length */ 19362306a36Sopenharmony_ci} __packed; 19462306a36Sopenharmony_ci 19562306a36Sopenharmony_ci#define SMB3_AES_CCM_NONCE 11 19662306a36Sopenharmony_ci#define SMB3_AES_GCM_NONCE 12 19762306a36Sopenharmony_ci 19862306a36Sopenharmony_ci/* Transform flags (for 3.0 dialect this flag indicates CCM */ 19962306a36Sopenharmony_ci#define TRANSFORM_FLAG_ENCRYPTED 0x0001 20062306a36Sopenharmony_cistruct smb2_transform_hdr { 20162306a36Sopenharmony_ci __le32 ProtocolId; /* 0xFD 'S' 'M' 'B' */ 20262306a36Sopenharmony_ci __u8 Signature[16]; 20362306a36Sopenharmony_ci __u8 Nonce[16]; 20462306a36Sopenharmony_ci __le32 OriginalMessageSize; 20562306a36Sopenharmony_ci __u16 Reserved1; 20662306a36Sopenharmony_ci __le16 Flags; /* EncryptionAlgorithm for 3.0, enc enabled for 3.1.1 */ 20762306a36Sopenharmony_ci __le64 SessionId; 20862306a36Sopenharmony_ci} __packed; 20962306a36Sopenharmony_ci 21062306a36Sopenharmony_ci 21162306a36Sopenharmony_ci/* See MS-SMB2 2.2.42 */ 21262306a36Sopenharmony_cistruct smb2_compression_transform_hdr_unchained { 21362306a36Sopenharmony_ci __le32 ProtocolId; /* 0xFC 'S' 'M' 'B' */ 21462306a36Sopenharmony_ci __le32 OriginalCompressedSegmentSize; 21562306a36Sopenharmony_ci __le16 CompressionAlgorithm; 21662306a36Sopenharmony_ci __le16 Flags; 21762306a36Sopenharmony_ci __le16 Length; /* if chained it is length, else offset */ 21862306a36Sopenharmony_ci} __packed; 21962306a36Sopenharmony_ci 22062306a36Sopenharmony_ci/* See MS-SMB2 2.2.42.1 */ 22162306a36Sopenharmony_ci#define SMB2_COMPRESSION_FLAG_NONE 0x0000 22262306a36Sopenharmony_ci#define SMB2_COMPRESSION_FLAG_CHAINED 0x0001 22362306a36Sopenharmony_ci 22462306a36Sopenharmony_cistruct compression_payload_header { 22562306a36Sopenharmony_ci __le16 CompressionAlgorithm; 22662306a36Sopenharmony_ci __le16 Flags; 22762306a36Sopenharmony_ci __le32 Length; /* length of compressed playload including field below if present */ 22862306a36Sopenharmony_ci /* __le32 OriginalPayloadSize; */ /* optional, present when LZNT1, LZ77, LZ77+Huffman */ 22962306a36Sopenharmony_ci} __packed; 23062306a36Sopenharmony_ci 23162306a36Sopenharmony_ci/* See MS-SMB2 2.2.42.2 */ 23262306a36Sopenharmony_cistruct smb2_compression_transform_hdr_chained { 23362306a36Sopenharmony_ci __le32 ProtocolId; /* 0xFC 'S' 'M' 'B' */ 23462306a36Sopenharmony_ci __le32 OriginalCompressedSegmentSize; 23562306a36Sopenharmony_ci /* struct compression_payload_header[] */ 23662306a36Sopenharmony_ci} __packed; 23762306a36Sopenharmony_ci 23862306a36Sopenharmony_ci/* See MS-SMB2 2.2.42.2.2 */ 23962306a36Sopenharmony_cistruct compression_pattern_payload_v1 { 24062306a36Sopenharmony_ci __le16 Pattern; 24162306a36Sopenharmony_ci __le16 Reserved1; 24262306a36Sopenharmony_ci __le16 Reserved2; 24362306a36Sopenharmony_ci __le32 Repetitions; 24462306a36Sopenharmony_ci} __packed; 24562306a36Sopenharmony_ci 24662306a36Sopenharmony_ci/* See MS-SMB2 section 2.2.9.2 */ 24762306a36Sopenharmony_ci/* Context Types */ 24862306a36Sopenharmony_ci#define SMB2_RESERVED_TREE_CONNECT_CONTEXT_ID 0x0000 24962306a36Sopenharmony_ci#define SMB2_REMOTED_IDENTITY_TREE_CONNECT_CONTEXT_ID cpu_to_le16(0x0001) 25062306a36Sopenharmony_ci 25162306a36Sopenharmony_cistruct tree_connect_contexts { 25262306a36Sopenharmony_ci __le16 ContextType; 25362306a36Sopenharmony_ci __le16 DataLength; 25462306a36Sopenharmony_ci __le32 Reserved; 25562306a36Sopenharmony_ci __u8 Data[]; 25662306a36Sopenharmony_ci} __packed; 25762306a36Sopenharmony_ci 25862306a36Sopenharmony_ci/* Remoted identity tree connect context structures - see MS-SMB2 2.2.9.2.1 */ 25962306a36Sopenharmony_cistruct smb3_blob_data { 26062306a36Sopenharmony_ci __le16 BlobSize; 26162306a36Sopenharmony_ci __u8 BlobData[]; 26262306a36Sopenharmony_ci} __packed; 26362306a36Sopenharmony_ci 26462306a36Sopenharmony_ci/* Valid values for Attr */ 26562306a36Sopenharmony_ci#define SE_GROUP_MANDATORY 0x00000001 26662306a36Sopenharmony_ci#define SE_GROUP_ENABLED_BY_DEFAULT 0x00000002 26762306a36Sopenharmony_ci#define SE_GROUP_ENABLED 0x00000004 26862306a36Sopenharmony_ci#define SE_GROUP_OWNER 0x00000008 26962306a36Sopenharmony_ci#define SE_GROUP_USE_FOR_DENY_ONLY 0x00000010 27062306a36Sopenharmony_ci#define SE_GROUP_INTEGRITY 0x00000020 27162306a36Sopenharmony_ci#define SE_GROUP_INTEGRITY_ENABLED 0x00000040 27262306a36Sopenharmony_ci#define SE_GROUP_RESOURCE 0x20000000 27362306a36Sopenharmony_ci#define SE_GROUP_LOGON_ID 0xC0000000 27462306a36Sopenharmony_ci 27562306a36Sopenharmony_ci/* struct sid_attr_data is SidData array in BlobData format then le32 Attr */ 27662306a36Sopenharmony_ci 27762306a36Sopenharmony_cistruct sid_array_data { 27862306a36Sopenharmony_ci __le16 SidAttrCount; 27962306a36Sopenharmony_ci /* SidAttrList - array of sid_attr_data structs */ 28062306a36Sopenharmony_ci} __packed; 28162306a36Sopenharmony_ci 28262306a36Sopenharmony_cistruct luid_attr_data { 28362306a36Sopenharmony_ci 28462306a36Sopenharmony_ci} __packed; 28562306a36Sopenharmony_ci 28662306a36Sopenharmony_ci/* 28762306a36Sopenharmony_ci * struct privilege_data is the same as BLOB_DATA - see MS-SMB2 2.2.9.2.1.5 28862306a36Sopenharmony_ci * but with size of LUID_ATTR_DATA struct and BlobData set to LUID_ATTR DATA 28962306a36Sopenharmony_ci */ 29062306a36Sopenharmony_ci 29162306a36Sopenharmony_cistruct privilege_array_data { 29262306a36Sopenharmony_ci __le16 PrivilegeCount; 29362306a36Sopenharmony_ci /* array of privilege_data structs */ 29462306a36Sopenharmony_ci} __packed; 29562306a36Sopenharmony_ci 29662306a36Sopenharmony_cistruct remoted_identity_tcon_context { 29762306a36Sopenharmony_ci __le16 TicketType; /* must be 0x0001 */ 29862306a36Sopenharmony_ci __le16 TicketSize; /* total size of this struct */ 29962306a36Sopenharmony_ci __le16 User; /* offset to SID_ATTR_DATA struct with user info */ 30062306a36Sopenharmony_ci __le16 UserName; /* offset to null terminated Unicode username string */ 30162306a36Sopenharmony_ci __le16 Domain; /* offset to null terminated Unicode domain name */ 30262306a36Sopenharmony_ci __le16 Groups; /* offset to SID_ARRAY_DATA struct with group info */ 30362306a36Sopenharmony_ci __le16 RestrictedGroups; /* similar to above */ 30462306a36Sopenharmony_ci __le16 Privileges; /* offset to PRIVILEGE_ARRAY_DATA struct */ 30562306a36Sopenharmony_ci __le16 PrimaryGroup; /* offset to SID_ARRAY_DATA struct */ 30662306a36Sopenharmony_ci __le16 Owner; /* offset to BLOB_DATA struct */ 30762306a36Sopenharmony_ci __le16 DefaultDacl; /* offset to BLOB_DATA struct */ 30862306a36Sopenharmony_ci __le16 DeviceGroups; /* offset to SID_ARRAY_DATA struct */ 30962306a36Sopenharmony_ci __le16 UserClaims; /* offset to BLOB_DATA struct */ 31062306a36Sopenharmony_ci __le16 DeviceClaims; /* offset to BLOB_DATA struct */ 31162306a36Sopenharmony_ci __u8 TicketInfo[]; /* variable length buf - remoted identity data */ 31262306a36Sopenharmony_ci} __packed; 31362306a36Sopenharmony_ci 31462306a36Sopenharmony_cistruct smb2_tree_connect_req_extension { 31562306a36Sopenharmony_ci __le32 TreeConnectContextOffset; 31662306a36Sopenharmony_ci __le16 TreeConnectContextCount; 31762306a36Sopenharmony_ci __u8 Reserved[10]; 31862306a36Sopenharmony_ci __u8 PathName[]; /* variable sized array */ 31962306a36Sopenharmony_ci /* followed by array of TreeConnectContexts */ 32062306a36Sopenharmony_ci} __packed; 32162306a36Sopenharmony_ci 32262306a36Sopenharmony_ci/* Flags/Reserved for SMB3.1.1 */ 32362306a36Sopenharmony_ci#define SMB2_TREE_CONNECT_FLAG_CLUSTER_RECONNECT cpu_to_le16(0x0001) 32462306a36Sopenharmony_ci#define SMB2_TREE_CONNECT_FLAG_REDIRECT_TO_OWNER cpu_to_le16(0x0002) 32562306a36Sopenharmony_ci#define SMB2_TREE_CONNECT_FLAG_EXTENSION_PRESENT cpu_to_le16(0x0004) 32662306a36Sopenharmony_ci 32762306a36Sopenharmony_cistruct smb2_tree_connect_req { 32862306a36Sopenharmony_ci struct smb2_hdr hdr; 32962306a36Sopenharmony_ci __le16 StructureSize; /* Must be 9 */ 33062306a36Sopenharmony_ci __le16 Flags; /* Flags in SMB3.1.1 */ 33162306a36Sopenharmony_ci __le16 PathOffset; 33262306a36Sopenharmony_ci __le16 PathLength; 33362306a36Sopenharmony_ci __u8 Buffer[]; /* variable length */ 33462306a36Sopenharmony_ci} __packed; 33562306a36Sopenharmony_ci 33662306a36Sopenharmony_ci/* Possible ShareType values */ 33762306a36Sopenharmony_ci#define SMB2_SHARE_TYPE_DISK 0x01 33862306a36Sopenharmony_ci#define SMB2_SHARE_TYPE_PIPE 0x02 33962306a36Sopenharmony_ci#define SMB2_SHARE_TYPE_PRINT 0x03 34062306a36Sopenharmony_ci 34162306a36Sopenharmony_ci/* 34262306a36Sopenharmony_ci * Possible ShareFlags - exactly one and only one of the first 4 caching flags 34362306a36Sopenharmony_ci * must be set (any of the remaining, SHI1005, flags may be set individually 34462306a36Sopenharmony_ci * or in combination. 34562306a36Sopenharmony_ci */ 34662306a36Sopenharmony_ci#define SMB2_SHAREFLAG_MANUAL_CACHING 0x00000000 34762306a36Sopenharmony_ci#define SMB2_SHAREFLAG_AUTO_CACHING 0x00000010 34862306a36Sopenharmony_ci#define SMB2_SHAREFLAG_VDO_CACHING 0x00000020 34962306a36Sopenharmony_ci#define SMB2_SHAREFLAG_NO_CACHING 0x00000030 35062306a36Sopenharmony_ci#define SHI1005_FLAGS_DFS 0x00000001 35162306a36Sopenharmony_ci#define SHI1005_FLAGS_DFS_ROOT 0x00000002 35262306a36Sopenharmony_ci#define SMB2_SHAREFLAG_RESTRICT_EXCLUSIVE_OPENS 0x00000100 35362306a36Sopenharmony_ci#define SMB2_SHAREFLAG_FORCE_SHARED_DELETE 0x00000200 35462306a36Sopenharmony_ci#define SMB2_SHAREFLAG_ALLOW_NAMESPACE_CACHING 0x00000400 35562306a36Sopenharmony_ci#define SMB2_SHAREFLAG_ACCESS_BASED_DIRECTORY_ENUM 0x00000800 35662306a36Sopenharmony_ci#define SMB2_SHAREFLAG_FORCE_LEVELII_OPLOCK 0x00001000 35762306a36Sopenharmony_ci#define SMB2_SHAREFLAG_ENABLE_HASH_V1 0x00002000 35862306a36Sopenharmony_ci#define SMB2_SHAREFLAG_ENABLE_HASH_V2 0x00004000 35962306a36Sopenharmony_ci#define SHI1005_FLAGS_ENCRYPT_DATA 0x00008000 36062306a36Sopenharmony_ci#define SMB2_SHAREFLAG_IDENTITY_REMOTING 0x00040000 /* 3.1.1 */ 36162306a36Sopenharmony_ci#define SMB2_SHAREFLAG_COMPRESS_DATA 0x00100000 /* 3.1.1 */ 36262306a36Sopenharmony_ci#define SMB2_SHAREFLAG_ISOLATED_TRANSPORT 0x00200000 36362306a36Sopenharmony_ci#define SHI1005_FLAGS_ALL 0x0034FF33 36462306a36Sopenharmony_ci 36562306a36Sopenharmony_ci/* Possible share capabilities */ 36662306a36Sopenharmony_ci#define SMB2_SHARE_CAP_DFS cpu_to_le32(0x00000008) /* all dialects */ 36762306a36Sopenharmony_ci#define SMB2_SHARE_CAP_CONTINUOUS_AVAILABILITY cpu_to_le32(0x00000010) /* 3.0 */ 36862306a36Sopenharmony_ci#define SMB2_SHARE_CAP_SCALEOUT cpu_to_le32(0x00000020) /* 3.0 */ 36962306a36Sopenharmony_ci#define SMB2_SHARE_CAP_CLUSTER cpu_to_le32(0x00000040) /* 3.0 */ 37062306a36Sopenharmony_ci#define SMB2_SHARE_CAP_ASYMMETRIC cpu_to_le32(0x00000080) /* 3.02 */ 37162306a36Sopenharmony_ci#define SMB2_SHARE_CAP_REDIRECT_TO_OWNER cpu_to_le32(0x00000100) /* 3.1.1 */ 37262306a36Sopenharmony_ci 37362306a36Sopenharmony_cistruct smb2_tree_connect_rsp { 37462306a36Sopenharmony_ci struct smb2_hdr hdr; 37562306a36Sopenharmony_ci __le16 StructureSize; /* Must be 16 */ 37662306a36Sopenharmony_ci __u8 ShareType; /* see below */ 37762306a36Sopenharmony_ci __u8 Reserved; 37862306a36Sopenharmony_ci __le32 ShareFlags; /* see below */ 37962306a36Sopenharmony_ci __le32 Capabilities; /* see below */ 38062306a36Sopenharmony_ci __le32 MaximalAccess; 38162306a36Sopenharmony_ci} __packed; 38262306a36Sopenharmony_ci 38362306a36Sopenharmony_cistruct smb2_tree_disconnect_req { 38462306a36Sopenharmony_ci struct smb2_hdr hdr; 38562306a36Sopenharmony_ci __le16 StructureSize; /* Must be 4 */ 38662306a36Sopenharmony_ci __le16 Reserved; 38762306a36Sopenharmony_ci} __packed; 38862306a36Sopenharmony_ci 38962306a36Sopenharmony_cistruct smb2_tree_disconnect_rsp { 39062306a36Sopenharmony_ci struct smb2_hdr hdr; 39162306a36Sopenharmony_ci __le16 StructureSize; /* Must be 4 */ 39262306a36Sopenharmony_ci __le16 Reserved; 39362306a36Sopenharmony_ci} __packed; 39462306a36Sopenharmony_ci 39562306a36Sopenharmony_ci 39662306a36Sopenharmony_ci/* 39762306a36Sopenharmony_ci * SMB2_NEGOTIATE_PROTOCOL See MS-SMB2 section 2.2.3 39862306a36Sopenharmony_ci */ 39962306a36Sopenharmony_ci/* SecurityMode flags */ 40062306a36Sopenharmony_ci#define SMB2_NEGOTIATE_SIGNING_ENABLED 0x0001 40162306a36Sopenharmony_ci#define SMB2_NEGOTIATE_SIGNING_ENABLED_LE cpu_to_le16(0x0001) 40262306a36Sopenharmony_ci#define SMB2_NEGOTIATE_SIGNING_REQUIRED 0x0002 40362306a36Sopenharmony_ci#define SMB2_NEGOTIATE_SIGNING_REQUIRED_LE cpu_to_le16(0x0002) 40462306a36Sopenharmony_ci#define SMB2_SEC_MODE_FLAGS_ALL 0x0003 40562306a36Sopenharmony_ci 40662306a36Sopenharmony_ci/* Capabilities flags */ 40762306a36Sopenharmony_ci#define SMB2_GLOBAL_CAP_DFS 0x00000001 40862306a36Sopenharmony_ci#define SMB2_GLOBAL_CAP_LEASING 0x00000002 /* Resp only New to SMB2.1 */ 40962306a36Sopenharmony_ci#define SMB2_GLOBAL_CAP_LARGE_MTU 0x00000004 /* Resp only New to SMB2.1 */ 41062306a36Sopenharmony_ci#define SMB2_GLOBAL_CAP_MULTI_CHANNEL 0x00000008 /* New to SMB3 */ 41162306a36Sopenharmony_ci#define SMB2_GLOBAL_CAP_PERSISTENT_HANDLES 0x00000010 /* New to SMB3 */ 41262306a36Sopenharmony_ci#define SMB2_GLOBAL_CAP_DIRECTORY_LEASING 0x00000020 /* New to SMB3 */ 41362306a36Sopenharmony_ci#define SMB2_GLOBAL_CAP_ENCRYPTION 0x00000040 /* New to SMB3 */ 41462306a36Sopenharmony_ci/* Internal types */ 41562306a36Sopenharmony_ci#define SMB2_NT_FIND 0x00100000 41662306a36Sopenharmony_ci#define SMB2_LARGE_FILES 0x00200000 41762306a36Sopenharmony_ci 41862306a36Sopenharmony_ci#define SMB2_CLIENT_GUID_SIZE 16 41962306a36Sopenharmony_ci#define SMB2_CREATE_GUID_SIZE 16 42062306a36Sopenharmony_ci 42162306a36Sopenharmony_ci/* Dialects */ 42262306a36Sopenharmony_ci#define SMB10_PROT_ID 0x0000 /* local only, not sent on wire w/CIFS negprot */ 42362306a36Sopenharmony_ci#define SMB20_PROT_ID 0x0202 42462306a36Sopenharmony_ci#define SMB21_PROT_ID 0x0210 42562306a36Sopenharmony_ci#define SMB2X_PROT_ID 0x02FF 42662306a36Sopenharmony_ci#define SMB30_PROT_ID 0x0300 42762306a36Sopenharmony_ci#define SMB302_PROT_ID 0x0302 42862306a36Sopenharmony_ci#define SMB311_PROT_ID 0x0311 42962306a36Sopenharmony_ci#define BAD_PROT_ID 0xFFFF 43062306a36Sopenharmony_ci 43162306a36Sopenharmony_ci#define SMB311_SALT_SIZE 32 43262306a36Sopenharmony_ci/* Hash Algorithm Types */ 43362306a36Sopenharmony_ci#define SMB2_PREAUTH_INTEGRITY_SHA512 cpu_to_le16(0x0001) 43462306a36Sopenharmony_ci#define SMB2_PREAUTH_HASH_SIZE 64 43562306a36Sopenharmony_ci 43662306a36Sopenharmony_ci/* Negotiate Contexts - ContextTypes. See MS-SMB2 section 2.2.3.1 for details */ 43762306a36Sopenharmony_ci#define SMB2_PREAUTH_INTEGRITY_CAPABILITIES cpu_to_le16(1) 43862306a36Sopenharmony_ci#define SMB2_ENCRYPTION_CAPABILITIES cpu_to_le16(2) 43962306a36Sopenharmony_ci#define SMB2_COMPRESSION_CAPABILITIES cpu_to_le16(3) 44062306a36Sopenharmony_ci#define SMB2_NETNAME_NEGOTIATE_CONTEXT_ID cpu_to_le16(5) 44162306a36Sopenharmony_ci#define SMB2_TRANSPORT_CAPABILITIES cpu_to_le16(6) 44262306a36Sopenharmony_ci#define SMB2_RDMA_TRANSFORM_CAPABILITIES cpu_to_le16(7) 44362306a36Sopenharmony_ci#define SMB2_SIGNING_CAPABILITIES cpu_to_le16(8) 44462306a36Sopenharmony_ci#define SMB2_POSIX_EXTENSIONS_AVAILABLE cpu_to_le16(0x100) 44562306a36Sopenharmony_ci 44662306a36Sopenharmony_cistruct smb2_neg_context { 44762306a36Sopenharmony_ci __le16 ContextType; 44862306a36Sopenharmony_ci __le16 DataLength; 44962306a36Sopenharmony_ci __le32 Reserved; 45062306a36Sopenharmony_ci /* Followed by array of data. NOTE: some servers require padding to 8 byte boundary */ 45162306a36Sopenharmony_ci} __packed; 45262306a36Sopenharmony_ci 45362306a36Sopenharmony_ci/* 45462306a36Sopenharmony_ci * SaltLength that the server send can be zero, so the only three required 45562306a36Sopenharmony_ci * fields (all __le16) end up six bytes total, so the minimum context data len 45662306a36Sopenharmony_ci * in the response is six bytes which accounts for 45762306a36Sopenharmony_ci * 45862306a36Sopenharmony_ci * HashAlgorithmCount, SaltLength, and 1 HashAlgorithm. 45962306a36Sopenharmony_ci */ 46062306a36Sopenharmony_ci#define MIN_PREAUTH_CTXT_DATA_LEN 6 46162306a36Sopenharmony_ci 46262306a36Sopenharmony_cistruct smb2_preauth_neg_context { 46362306a36Sopenharmony_ci __le16 ContextType; /* 1 */ 46462306a36Sopenharmony_ci __le16 DataLength; 46562306a36Sopenharmony_ci __le32 Reserved; 46662306a36Sopenharmony_ci __le16 HashAlgorithmCount; /* 1 */ 46762306a36Sopenharmony_ci __le16 SaltLength; 46862306a36Sopenharmony_ci __le16 HashAlgorithms; /* HashAlgorithms[0] since only one defined */ 46962306a36Sopenharmony_ci __u8 Salt[SMB311_SALT_SIZE]; 47062306a36Sopenharmony_ci} __packed; 47162306a36Sopenharmony_ci 47262306a36Sopenharmony_ci/* Encryption Algorithms Ciphers */ 47362306a36Sopenharmony_ci#define SMB2_ENCRYPTION_AES128_CCM cpu_to_le16(0x0001) 47462306a36Sopenharmony_ci#define SMB2_ENCRYPTION_AES128_GCM cpu_to_le16(0x0002) 47562306a36Sopenharmony_ci#define SMB2_ENCRYPTION_AES256_CCM cpu_to_le16(0x0003) 47662306a36Sopenharmony_ci#define SMB2_ENCRYPTION_AES256_GCM cpu_to_le16(0x0004) 47762306a36Sopenharmony_ci 47862306a36Sopenharmony_ci/* Min encrypt context data is one cipher so 2 bytes + 2 byte count field */ 47962306a36Sopenharmony_ci#define MIN_ENCRYPT_CTXT_DATA_LEN 4 48062306a36Sopenharmony_cistruct smb2_encryption_neg_context { 48162306a36Sopenharmony_ci __le16 ContextType; /* 2 */ 48262306a36Sopenharmony_ci __le16 DataLength; 48362306a36Sopenharmony_ci __le32 Reserved; 48462306a36Sopenharmony_ci /* CipherCount usally 2, but can be 3 when AES256-GCM enabled */ 48562306a36Sopenharmony_ci __le16 CipherCount; /* AES128-GCM and AES128-CCM by default */ 48662306a36Sopenharmony_ci __le16 Ciphers[]; 48762306a36Sopenharmony_ci} __packed; 48862306a36Sopenharmony_ci 48962306a36Sopenharmony_ci/* See MS-SMB2 2.2.3.1.3 */ 49062306a36Sopenharmony_ci#define SMB3_COMPRESS_NONE cpu_to_le16(0x0000) 49162306a36Sopenharmony_ci#define SMB3_COMPRESS_LZNT1 cpu_to_le16(0x0001) 49262306a36Sopenharmony_ci#define SMB3_COMPRESS_LZ77 cpu_to_le16(0x0002) 49362306a36Sopenharmony_ci#define SMB3_COMPRESS_LZ77_HUFF cpu_to_le16(0x0003) 49462306a36Sopenharmony_ci/* Pattern scanning algorithm See MS-SMB2 3.1.4.4.1 */ 49562306a36Sopenharmony_ci#define SMB3_COMPRESS_PATTERN cpu_to_le16(0x0004) /* Pattern_V1 */ 49662306a36Sopenharmony_ci 49762306a36Sopenharmony_ci/* Compression Flags */ 49862306a36Sopenharmony_ci#define SMB2_COMPRESSION_CAPABILITIES_FLAG_NONE cpu_to_le32(0x00000000) 49962306a36Sopenharmony_ci#define SMB2_COMPRESSION_CAPABILITIES_FLAG_CHAINED cpu_to_le32(0x00000001) 50062306a36Sopenharmony_ci 50162306a36Sopenharmony_cistruct smb2_compression_capabilities_context { 50262306a36Sopenharmony_ci __le16 ContextType; /* 3 */ 50362306a36Sopenharmony_ci __le16 DataLength; 50462306a36Sopenharmony_ci __le32 Reserved; 50562306a36Sopenharmony_ci __le16 CompressionAlgorithmCount; 50662306a36Sopenharmony_ci __le16 Padding; 50762306a36Sopenharmony_ci __le32 Flags; 50862306a36Sopenharmony_ci __le16 CompressionAlgorithms[3]; 50962306a36Sopenharmony_ci __u16 Pad; /* Some servers require pad to DataLen multiple of 8 */ 51062306a36Sopenharmony_ci /* Check if pad needed */ 51162306a36Sopenharmony_ci} __packed; 51262306a36Sopenharmony_ci 51362306a36Sopenharmony_ci/* 51462306a36Sopenharmony_ci * For smb2_netname_negotiate_context_id See MS-SMB2 2.2.3.1.4. 51562306a36Sopenharmony_ci * Its struct simply contains NetName, an array of Unicode characters 51662306a36Sopenharmony_ci */ 51762306a36Sopenharmony_cistruct smb2_netname_neg_context { 51862306a36Sopenharmony_ci __le16 ContextType; /* 5 */ 51962306a36Sopenharmony_ci __le16 DataLength; 52062306a36Sopenharmony_ci __le32 Reserved; 52162306a36Sopenharmony_ci __le16 NetName[]; /* hostname of target converted to UCS-2 */ 52262306a36Sopenharmony_ci} __packed; 52362306a36Sopenharmony_ci 52462306a36Sopenharmony_ci/* 52562306a36Sopenharmony_ci * For smb2_transport_capabilities context see MS-SMB2 2.2.3.1.5 52662306a36Sopenharmony_ci * and 2.2.4.1.5 52762306a36Sopenharmony_ci */ 52862306a36Sopenharmony_ci 52962306a36Sopenharmony_ci/* Flags */ 53062306a36Sopenharmony_ci#define SMB2_ACCEPT_TRANSPORT_LEVEL_SECURITY 0x00000001 53162306a36Sopenharmony_ci 53262306a36Sopenharmony_cistruct smb2_transport_capabilities_context { 53362306a36Sopenharmony_ci __le16 ContextType; /* 6 */ 53462306a36Sopenharmony_ci __le16 DataLength; 53562306a36Sopenharmony_ci __u32 Reserved; 53662306a36Sopenharmony_ci __le32 Flags; 53762306a36Sopenharmony_ci __u32 Pad; 53862306a36Sopenharmony_ci} __packed; 53962306a36Sopenharmony_ci 54062306a36Sopenharmony_ci/* 54162306a36Sopenharmony_ci * For rdma transform capabilities context see MS-SMB2 2.2.3.1.6 54262306a36Sopenharmony_ci * and 2.2.4.1.6 54362306a36Sopenharmony_ci */ 54462306a36Sopenharmony_ci 54562306a36Sopenharmony_ci/* RDMA Transform IDs */ 54662306a36Sopenharmony_ci#define SMB2_RDMA_TRANSFORM_NONE 0x0000 54762306a36Sopenharmony_ci#define SMB2_RDMA_TRANSFORM_ENCRYPTION 0x0001 54862306a36Sopenharmony_ci#define SMB2_RDMA_TRANSFORM_SIGNING 0x0002 54962306a36Sopenharmony_ci 55062306a36Sopenharmony_cistruct smb2_rdma_transform_capabilities_context { 55162306a36Sopenharmony_ci __le16 ContextType; /* 7 */ 55262306a36Sopenharmony_ci __le16 DataLength; 55362306a36Sopenharmony_ci __u32 Reserved; 55462306a36Sopenharmony_ci __le16 TransformCount; 55562306a36Sopenharmony_ci __u16 Reserved1; 55662306a36Sopenharmony_ci __u32 Reserved2; 55762306a36Sopenharmony_ci __le16 RDMATransformIds[]; 55862306a36Sopenharmony_ci} __packed; 55962306a36Sopenharmony_ci 56062306a36Sopenharmony_ci/* 56162306a36Sopenharmony_ci * For signing capabilities context see MS-SMB2 2.2.3.1.7 56262306a36Sopenharmony_ci * and 2.2.4.1.7 56362306a36Sopenharmony_ci */ 56462306a36Sopenharmony_ci 56562306a36Sopenharmony_ci/* Signing algorithms */ 56662306a36Sopenharmony_ci#define SIGNING_ALG_HMAC_SHA256 0 56762306a36Sopenharmony_ci#define SIGNING_ALG_HMAC_SHA256_LE cpu_to_le16(0) 56862306a36Sopenharmony_ci#define SIGNING_ALG_AES_CMAC 1 56962306a36Sopenharmony_ci#define SIGNING_ALG_AES_CMAC_LE cpu_to_le16(1) 57062306a36Sopenharmony_ci#define SIGNING_ALG_AES_GMAC 2 57162306a36Sopenharmony_ci#define SIGNING_ALG_AES_GMAC_LE cpu_to_le16(2) 57262306a36Sopenharmony_ci 57362306a36Sopenharmony_cistruct smb2_signing_capabilities { 57462306a36Sopenharmony_ci __le16 ContextType; /* 8 */ 57562306a36Sopenharmony_ci __le16 DataLength; 57662306a36Sopenharmony_ci __le32 Reserved; 57762306a36Sopenharmony_ci __le16 SigningAlgorithmCount; 57862306a36Sopenharmony_ci __le16 SigningAlgorithms[]; 57962306a36Sopenharmony_ci /* Followed by padding to 8 byte boundary (required by some servers) */ 58062306a36Sopenharmony_ci} __packed; 58162306a36Sopenharmony_ci 58262306a36Sopenharmony_ci#define POSIX_CTXT_DATA_LEN 16 58362306a36Sopenharmony_cistruct smb2_posix_neg_context { 58462306a36Sopenharmony_ci __le16 ContextType; /* 0x100 */ 58562306a36Sopenharmony_ci __le16 DataLength; 58662306a36Sopenharmony_ci __le32 Reserved; 58762306a36Sopenharmony_ci __u8 Name[16]; /* POSIX ctxt GUID 93AD25509CB411E7B42383DE968BCD7C */ 58862306a36Sopenharmony_ci} __packed; 58962306a36Sopenharmony_ci 59062306a36Sopenharmony_cistruct smb2_negotiate_req { 59162306a36Sopenharmony_ci struct smb2_hdr hdr; 59262306a36Sopenharmony_ci __le16 StructureSize; /* Must be 36 */ 59362306a36Sopenharmony_ci __le16 DialectCount; 59462306a36Sopenharmony_ci __le16 SecurityMode; 59562306a36Sopenharmony_ci __le16 Reserved; /* MBZ */ 59662306a36Sopenharmony_ci __le32 Capabilities; 59762306a36Sopenharmony_ci __u8 ClientGUID[SMB2_CLIENT_GUID_SIZE]; 59862306a36Sopenharmony_ci /* In SMB3.02 and earlier next three were MBZ le64 ClientStartTime */ 59962306a36Sopenharmony_ci __le32 NegotiateContextOffset; /* SMB3.1.1 only. MBZ earlier */ 60062306a36Sopenharmony_ci __le16 NegotiateContextCount; /* SMB3.1.1 only. MBZ earlier */ 60162306a36Sopenharmony_ci __le16 Reserved2; 60262306a36Sopenharmony_ci __le16 Dialects[]; 60362306a36Sopenharmony_ci} __packed; 60462306a36Sopenharmony_ci 60562306a36Sopenharmony_cistruct smb2_negotiate_rsp { 60662306a36Sopenharmony_ci struct smb2_hdr hdr; 60762306a36Sopenharmony_ci __le16 StructureSize; /* Must be 65 */ 60862306a36Sopenharmony_ci __le16 SecurityMode; 60962306a36Sopenharmony_ci __le16 DialectRevision; 61062306a36Sopenharmony_ci __le16 NegotiateContextCount; /* Prior to SMB3.1.1 was Reserved & MBZ */ 61162306a36Sopenharmony_ci __u8 ServerGUID[16]; 61262306a36Sopenharmony_ci __le32 Capabilities; 61362306a36Sopenharmony_ci __le32 MaxTransactSize; 61462306a36Sopenharmony_ci __le32 MaxReadSize; 61562306a36Sopenharmony_ci __le32 MaxWriteSize; 61662306a36Sopenharmony_ci __le64 SystemTime; /* MBZ */ 61762306a36Sopenharmony_ci __le64 ServerStartTime; 61862306a36Sopenharmony_ci __le16 SecurityBufferOffset; 61962306a36Sopenharmony_ci __le16 SecurityBufferLength; 62062306a36Sopenharmony_ci __le32 NegotiateContextOffset; /* Pre:SMB3.1.1 was reserved/ignored */ 62162306a36Sopenharmony_ci __u8 Buffer[]; /* variable length GSS security buffer */ 62262306a36Sopenharmony_ci} __packed; 62362306a36Sopenharmony_ci 62462306a36Sopenharmony_ci 62562306a36Sopenharmony_ci/* 62662306a36Sopenharmony_ci * SMB2_SESSION_SETUP See MS-SMB2 section 2.2.5 62762306a36Sopenharmony_ci */ 62862306a36Sopenharmony_ci/* Flags */ 62962306a36Sopenharmony_ci#define SMB2_SESSION_REQ_FLAG_BINDING 0x01 63062306a36Sopenharmony_ci#define SMB2_SESSION_REQ_FLAG_ENCRYPT_DATA 0x04 63162306a36Sopenharmony_ci 63262306a36Sopenharmony_cistruct smb2_sess_setup_req { 63362306a36Sopenharmony_ci struct smb2_hdr hdr; 63462306a36Sopenharmony_ci __le16 StructureSize; /* Must be 25 */ 63562306a36Sopenharmony_ci __u8 Flags; 63662306a36Sopenharmony_ci __u8 SecurityMode; 63762306a36Sopenharmony_ci __le32 Capabilities; 63862306a36Sopenharmony_ci __le32 Channel; 63962306a36Sopenharmony_ci __le16 SecurityBufferOffset; 64062306a36Sopenharmony_ci __le16 SecurityBufferLength; 64162306a36Sopenharmony_ci __le64 PreviousSessionId; 64262306a36Sopenharmony_ci __u8 Buffer[]; /* variable length GSS security buffer */ 64362306a36Sopenharmony_ci} __packed; 64462306a36Sopenharmony_ci 64562306a36Sopenharmony_ci/* Currently defined SessionFlags */ 64662306a36Sopenharmony_ci#define SMB2_SESSION_FLAG_IS_GUEST 0x0001 64762306a36Sopenharmony_ci#define SMB2_SESSION_FLAG_IS_GUEST_LE cpu_to_le16(0x0001) 64862306a36Sopenharmony_ci#define SMB2_SESSION_FLAG_IS_NULL 0x0002 64962306a36Sopenharmony_ci#define SMB2_SESSION_FLAG_IS_NULL_LE cpu_to_le16(0x0002) 65062306a36Sopenharmony_ci#define SMB2_SESSION_FLAG_ENCRYPT_DATA 0x0004 65162306a36Sopenharmony_ci#define SMB2_SESSION_FLAG_ENCRYPT_DATA_LE cpu_to_le16(0x0004) 65262306a36Sopenharmony_ci 65362306a36Sopenharmony_cistruct smb2_sess_setup_rsp { 65462306a36Sopenharmony_ci struct smb2_hdr hdr; 65562306a36Sopenharmony_ci __le16 StructureSize; /* Must be 9 */ 65662306a36Sopenharmony_ci __le16 SessionFlags; 65762306a36Sopenharmony_ci __le16 SecurityBufferOffset; 65862306a36Sopenharmony_ci __le16 SecurityBufferLength; 65962306a36Sopenharmony_ci __u8 Buffer[]; /* variable length GSS security buffer */ 66062306a36Sopenharmony_ci} __packed; 66162306a36Sopenharmony_ci 66262306a36Sopenharmony_ci 66362306a36Sopenharmony_ci/* 66462306a36Sopenharmony_ci * SMB2_LOGOFF See MS-SMB2 section 2.2.7 66562306a36Sopenharmony_ci */ 66662306a36Sopenharmony_cistruct smb2_logoff_req { 66762306a36Sopenharmony_ci struct smb2_hdr hdr; 66862306a36Sopenharmony_ci __le16 StructureSize; /* Must be 4 */ 66962306a36Sopenharmony_ci __le16 Reserved; 67062306a36Sopenharmony_ci} __packed; 67162306a36Sopenharmony_ci 67262306a36Sopenharmony_cistruct smb2_logoff_rsp { 67362306a36Sopenharmony_ci struct smb2_hdr hdr; 67462306a36Sopenharmony_ci __le16 StructureSize; /* Must be 4 */ 67562306a36Sopenharmony_ci __le16 Reserved; 67662306a36Sopenharmony_ci} __packed; 67762306a36Sopenharmony_ci 67862306a36Sopenharmony_ci 67962306a36Sopenharmony_ci/* 68062306a36Sopenharmony_ci * SMB2_CLOSE See MS-SMB2 section 2.2.15 68162306a36Sopenharmony_ci */ 68262306a36Sopenharmony_ci/* Currently defined values for close flags */ 68362306a36Sopenharmony_ci#define SMB2_CLOSE_FLAG_POSTQUERY_ATTRIB cpu_to_le16(0x0001) 68462306a36Sopenharmony_cistruct smb2_close_req { 68562306a36Sopenharmony_ci struct smb2_hdr hdr; 68662306a36Sopenharmony_ci __le16 StructureSize; /* Must be 24 */ 68762306a36Sopenharmony_ci __le16 Flags; 68862306a36Sopenharmony_ci __le32 Reserved; 68962306a36Sopenharmony_ci __u64 PersistentFileId; /* opaque endianness */ 69062306a36Sopenharmony_ci __u64 VolatileFileId; /* opaque endianness */ 69162306a36Sopenharmony_ci} __packed; 69262306a36Sopenharmony_ci 69362306a36Sopenharmony_ci/* 69462306a36Sopenharmony_ci * Maximum size of a SMB2_CLOSE response is 64 (smb2 header) + 60 (data) 69562306a36Sopenharmony_ci */ 69662306a36Sopenharmony_ci#define MAX_SMB2_CLOSE_RESPONSE_SIZE 124 69762306a36Sopenharmony_ci 69862306a36Sopenharmony_cistruct smb2_close_rsp { 69962306a36Sopenharmony_ci struct smb2_hdr hdr; 70062306a36Sopenharmony_ci __le16 StructureSize; /* 60 */ 70162306a36Sopenharmony_ci __le16 Flags; 70262306a36Sopenharmony_ci __le32 Reserved; 70362306a36Sopenharmony_ci struct_group(network_open_info, 70462306a36Sopenharmony_ci __le64 CreationTime; 70562306a36Sopenharmony_ci __le64 LastAccessTime; 70662306a36Sopenharmony_ci __le64 LastWriteTime; 70762306a36Sopenharmony_ci __le64 ChangeTime; 70862306a36Sopenharmony_ci /* Beginning of FILE_STANDARD_INFO equivalent */ 70962306a36Sopenharmony_ci __le64 AllocationSize; 71062306a36Sopenharmony_ci __le64 EndOfFile; 71162306a36Sopenharmony_ci __le32 Attributes; 71262306a36Sopenharmony_ci ); 71362306a36Sopenharmony_ci} __packed; 71462306a36Sopenharmony_ci 71562306a36Sopenharmony_ci 71662306a36Sopenharmony_ci/* 71762306a36Sopenharmony_ci * SMB2_READ See MS-SMB2 section 2.2.19 71862306a36Sopenharmony_ci */ 71962306a36Sopenharmony_ci/* For read request Flags field below, following flag is defined for SMB3.02 */ 72062306a36Sopenharmony_ci#define SMB2_READFLAG_READ_UNBUFFERED 0x01 72162306a36Sopenharmony_ci#define SMB2_READFLAG_REQUEST_COMPRESSED 0x02 /* See MS-SMB2 2.2.19 */ 72262306a36Sopenharmony_ci 72362306a36Sopenharmony_ci/* Channel field for read and write: exactly one of following flags can be set*/ 72462306a36Sopenharmony_ci#define SMB2_CHANNEL_NONE cpu_to_le32(0x00000000) 72562306a36Sopenharmony_ci#define SMB2_CHANNEL_RDMA_V1 cpu_to_le32(0x00000001) 72662306a36Sopenharmony_ci#define SMB2_CHANNEL_RDMA_V1_INVALIDATE cpu_to_le32(0x00000002) 72762306a36Sopenharmony_ci#define SMB2_CHANNEL_RDMA_TRANSFORM cpu_to_le32(0x00000003) 72862306a36Sopenharmony_ci 72962306a36Sopenharmony_ci/* SMB2 read request without RFC1001 length at the beginning */ 73062306a36Sopenharmony_cistruct smb2_read_req { 73162306a36Sopenharmony_ci struct smb2_hdr hdr; 73262306a36Sopenharmony_ci __le16 StructureSize; /* Must be 49 */ 73362306a36Sopenharmony_ci __u8 Padding; /* offset from start of SMB2 header to place read */ 73462306a36Sopenharmony_ci __u8 Flags; /* MBZ unless SMB3.02 or later */ 73562306a36Sopenharmony_ci __le32 Length; 73662306a36Sopenharmony_ci __le64 Offset; 73762306a36Sopenharmony_ci __u64 PersistentFileId; 73862306a36Sopenharmony_ci __u64 VolatileFileId; 73962306a36Sopenharmony_ci __le32 MinimumCount; 74062306a36Sopenharmony_ci __le32 Channel; /* MBZ except for SMB3 or later */ 74162306a36Sopenharmony_ci __le32 RemainingBytes; 74262306a36Sopenharmony_ci __le16 ReadChannelInfoOffset; 74362306a36Sopenharmony_ci __le16 ReadChannelInfoLength; 74462306a36Sopenharmony_ci __u8 Buffer[]; 74562306a36Sopenharmony_ci} __packed; 74662306a36Sopenharmony_ci 74762306a36Sopenharmony_ci/* Read flags */ 74862306a36Sopenharmony_ci#define SMB2_READFLAG_RESPONSE_NONE cpu_to_le32(0x00000000) 74962306a36Sopenharmony_ci#define SMB2_READFLAG_RESPONSE_RDMA_TRANSFORM cpu_to_le32(0x00000001) 75062306a36Sopenharmony_ci 75162306a36Sopenharmony_cistruct smb2_read_rsp { 75262306a36Sopenharmony_ci struct smb2_hdr hdr; 75362306a36Sopenharmony_ci __le16 StructureSize; /* Must be 17 */ 75462306a36Sopenharmony_ci __u8 DataOffset; 75562306a36Sopenharmony_ci __u8 Reserved; 75662306a36Sopenharmony_ci __le32 DataLength; 75762306a36Sopenharmony_ci __le32 DataRemaining; 75862306a36Sopenharmony_ci __le32 Flags; 75962306a36Sopenharmony_ci __u8 Buffer[]; 76062306a36Sopenharmony_ci} __packed; 76162306a36Sopenharmony_ci 76262306a36Sopenharmony_ci 76362306a36Sopenharmony_ci/* 76462306a36Sopenharmony_ci * SMB2_WRITE See MS-SMB2 section 2.2.21 76562306a36Sopenharmony_ci */ 76662306a36Sopenharmony_ci/* For write request Flags field below the following flags are defined: */ 76762306a36Sopenharmony_ci#define SMB2_WRITEFLAG_WRITE_THROUGH 0x00000001 /* SMB2.1 or later */ 76862306a36Sopenharmony_ci#define SMB2_WRITEFLAG_WRITE_UNBUFFERED 0x00000002 /* SMB3.02 or later */ 76962306a36Sopenharmony_ci 77062306a36Sopenharmony_cistruct smb2_write_req { 77162306a36Sopenharmony_ci struct smb2_hdr hdr; 77262306a36Sopenharmony_ci __le16 StructureSize; /* Must be 49 */ 77362306a36Sopenharmony_ci __le16 DataOffset; /* offset from start of SMB2 header to write data */ 77462306a36Sopenharmony_ci __le32 Length; 77562306a36Sopenharmony_ci __le64 Offset; 77662306a36Sopenharmony_ci __u64 PersistentFileId; /* opaque endianness */ 77762306a36Sopenharmony_ci __u64 VolatileFileId; /* opaque endianness */ 77862306a36Sopenharmony_ci __le32 Channel; /* MBZ unless SMB3.02 or later */ 77962306a36Sopenharmony_ci __le32 RemainingBytes; 78062306a36Sopenharmony_ci __le16 WriteChannelInfoOffset; 78162306a36Sopenharmony_ci __le16 WriteChannelInfoLength; 78262306a36Sopenharmony_ci __le32 Flags; 78362306a36Sopenharmony_ci __u8 Buffer[]; 78462306a36Sopenharmony_ci} __packed; 78562306a36Sopenharmony_ci 78662306a36Sopenharmony_cistruct smb2_write_rsp { 78762306a36Sopenharmony_ci struct smb2_hdr hdr; 78862306a36Sopenharmony_ci __le16 StructureSize; /* Must be 17 */ 78962306a36Sopenharmony_ci __u8 DataOffset; 79062306a36Sopenharmony_ci __u8 Reserved; 79162306a36Sopenharmony_ci __le32 DataLength; 79262306a36Sopenharmony_ci __le32 DataRemaining; 79362306a36Sopenharmony_ci __u32 Reserved2; 79462306a36Sopenharmony_ci __u8 Buffer[]; 79562306a36Sopenharmony_ci} __packed; 79662306a36Sopenharmony_ci 79762306a36Sopenharmony_ci 79862306a36Sopenharmony_ci/* 79962306a36Sopenharmony_ci * SMB2_FLUSH See MS-SMB2 section 2.2.17 80062306a36Sopenharmony_ci */ 80162306a36Sopenharmony_cistruct smb2_flush_req { 80262306a36Sopenharmony_ci struct smb2_hdr hdr; 80362306a36Sopenharmony_ci __le16 StructureSize; /* Must be 24 */ 80462306a36Sopenharmony_ci __le16 Reserved1; 80562306a36Sopenharmony_ci __le32 Reserved2; 80662306a36Sopenharmony_ci __u64 PersistentFileId; 80762306a36Sopenharmony_ci __u64 VolatileFileId; 80862306a36Sopenharmony_ci} __packed; 80962306a36Sopenharmony_ci 81062306a36Sopenharmony_cistruct smb2_flush_rsp { 81162306a36Sopenharmony_ci struct smb2_hdr hdr; 81262306a36Sopenharmony_ci __le16 StructureSize; 81362306a36Sopenharmony_ci __le16 Reserved; 81462306a36Sopenharmony_ci} __packed; 81562306a36Sopenharmony_ci 81662306a36Sopenharmony_ci#define SMB2_LOCKFLAG_SHARED 0x0001 81762306a36Sopenharmony_ci#define SMB2_LOCKFLAG_EXCLUSIVE 0x0002 81862306a36Sopenharmony_ci#define SMB2_LOCKFLAG_UNLOCK 0x0004 81962306a36Sopenharmony_ci#define SMB2_LOCKFLAG_FAIL_IMMEDIATELY 0x0010 82062306a36Sopenharmony_ci#define SMB2_LOCKFLAG_MASK 0x0007 82162306a36Sopenharmony_ci 82262306a36Sopenharmony_cistruct smb2_lock_element { 82362306a36Sopenharmony_ci __le64 Offset; 82462306a36Sopenharmony_ci __le64 Length; 82562306a36Sopenharmony_ci __le32 Flags; 82662306a36Sopenharmony_ci __le32 Reserved; 82762306a36Sopenharmony_ci} __packed; 82862306a36Sopenharmony_ci 82962306a36Sopenharmony_cistruct smb2_lock_req { 83062306a36Sopenharmony_ci struct smb2_hdr hdr; 83162306a36Sopenharmony_ci __le16 StructureSize; /* Must be 48 */ 83262306a36Sopenharmony_ci __le16 LockCount; 83362306a36Sopenharmony_ci /* 83462306a36Sopenharmony_ci * The least significant four bits are the index, the other 28 bits are 83562306a36Sopenharmony_ci * the lock sequence number (0 to 64). See MS-SMB2 2.2.26 83662306a36Sopenharmony_ci */ 83762306a36Sopenharmony_ci __le32 LockSequenceNumber; 83862306a36Sopenharmony_ci __u64 PersistentFileId; 83962306a36Sopenharmony_ci __u64 VolatileFileId; 84062306a36Sopenharmony_ci /* Followed by at least one */ 84162306a36Sopenharmony_ci union { 84262306a36Sopenharmony_ci struct smb2_lock_element lock; 84362306a36Sopenharmony_ci DECLARE_FLEX_ARRAY(struct smb2_lock_element, locks); 84462306a36Sopenharmony_ci }; 84562306a36Sopenharmony_ci} __packed; 84662306a36Sopenharmony_ci 84762306a36Sopenharmony_cistruct smb2_lock_rsp { 84862306a36Sopenharmony_ci struct smb2_hdr hdr; 84962306a36Sopenharmony_ci __le16 StructureSize; /* Must be 4 */ 85062306a36Sopenharmony_ci __le16 Reserved; 85162306a36Sopenharmony_ci} __packed; 85262306a36Sopenharmony_ci 85362306a36Sopenharmony_cistruct smb2_echo_req { 85462306a36Sopenharmony_ci struct smb2_hdr hdr; 85562306a36Sopenharmony_ci __le16 StructureSize; /* Must be 4 */ 85662306a36Sopenharmony_ci __u16 Reserved; 85762306a36Sopenharmony_ci} __packed; 85862306a36Sopenharmony_ci 85962306a36Sopenharmony_cistruct smb2_echo_rsp { 86062306a36Sopenharmony_ci struct smb2_hdr hdr; 86162306a36Sopenharmony_ci __le16 StructureSize; /* Must be 4 */ 86262306a36Sopenharmony_ci __u16 Reserved; 86362306a36Sopenharmony_ci} __packed; 86462306a36Sopenharmony_ci 86562306a36Sopenharmony_ci/* 86662306a36Sopenharmony_ci * Valid FileInformation classes for query directory 86762306a36Sopenharmony_ci * 86862306a36Sopenharmony_ci * Note that these are a subset of the (file) QUERY_INFO levels defined 86962306a36Sopenharmony_ci * later in this file (but since QUERY_DIRECTORY uses equivalent numbers 87062306a36Sopenharmony_ci * we do not redefine them here) 87162306a36Sopenharmony_ci * 87262306a36Sopenharmony_ci * FileDirectoryInfomation 0x01 87362306a36Sopenharmony_ci * FileFullDirectoryInformation 0x02 87462306a36Sopenharmony_ci * FileIdFullDirectoryInformation 0x26 87562306a36Sopenharmony_ci * FileBothDirectoryInformation 0x03 87662306a36Sopenharmony_ci * FileIdBothDirectoryInformation 0x25 87762306a36Sopenharmony_ci * FileNamesInformation 0x0C 87862306a36Sopenharmony_ci * FileIdExtdDirectoryInformation 0x3C 87962306a36Sopenharmony_ci */ 88062306a36Sopenharmony_ci 88162306a36Sopenharmony_ci/* search (query_directory) Flags field */ 88262306a36Sopenharmony_ci#define SMB2_RESTART_SCANS 0x01 88362306a36Sopenharmony_ci#define SMB2_RETURN_SINGLE_ENTRY 0x02 88462306a36Sopenharmony_ci#define SMB2_INDEX_SPECIFIED 0x04 88562306a36Sopenharmony_ci#define SMB2_REOPEN 0x10 88662306a36Sopenharmony_ci 88762306a36Sopenharmony_cistruct smb2_query_directory_req { 88862306a36Sopenharmony_ci struct smb2_hdr hdr; 88962306a36Sopenharmony_ci __le16 StructureSize; /* Must be 33 */ 89062306a36Sopenharmony_ci __u8 FileInformationClass; 89162306a36Sopenharmony_ci __u8 Flags; 89262306a36Sopenharmony_ci __le32 FileIndex; 89362306a36Sopenharmony_ci __u64 PersistentFileId; 89462306a36Sopenharmony_ci __u64 VolatileFileId; 89562306a36Sopenharmony_ci __le16 FileNameOffset; 89662306a36Sopenharmony_ci __le16 FileNameLength; 89762306a36Sopenharmony_ci __le32 OutputBufferLength; 89862306a36Sopenharmony_ci __u8 Buffer[]; 89962306a36Sopenharmony_ci} __packed; 90062306a36Sopenharmony_ci 90162306a36Sopenharmony_cistruct smb2_query_directory_rsp { 90262306a36Sopenharmony_ci struct smb2_hdr hdr; 90362306a36Sopenharmony_ci __le16 StructureSize; /* Must be 9 */ 90462306a36Sopenharmony_ci __le16 OutputBufferOffset; 90562306a36Sopenharmony_ci __le32 OutputBufferLength; 90662306a36Sopenharmony_ci __u8 Buffer[]; 90762306a36Sopenharmony_ci} __packed; 90862306a36Sopenharmony_ci 90962306a36Sopenharmony_ci/* 91062306a36Sopenharmony_ci * Maximum number of iovs we need for a set-info request. 91162306a36Sopenharmony_ci * The largest one is rename/hardlink 91262306a36Sopenharmony_ci * [0] : struct smb2_set_info_req + smb2_file_[rename|link]_info 91362306a36Sopenharmony_ci * [1] : path 91462306a36Sopenharmony_ci * [2] : compound padding 91562306a36Sopenharmony_ci */ 91662306a36Sopenharmony_ci#define SMB2_SET_INFO_IOV_SIZE 3 91762306a36Sopenharmony_ci 91862306a36Sopenharmony_cistruct smb2_set_info_req { 91962306a36Sopenharmony_ci struct smb2_hdr hdr; 92062306a36Sopenharmony_ci __le16 StructureSize; /* Must be 33 */ 92162306a36Sopenharmony_ci __u8 InfoType; 92262306a36Sopenharmony_ci __u8 FileInfoClass; 92362306a36Sopenharmony_ci __le32 BufferLength; 92462306a36Sopenharmony_ci __le16 BufferOffset; 92562306a36Sopenharmony_ci __u16 Reserved; 92662306a36Sopenharmony_ci __le32 AdditionalInformation; 92762306a36Sopenharmony_ci __u64 PersistentFileId; 92862306a36Sopenharmony_ci __u64 VolatileFileId; 92962306a36Sopenharmony_ci __u8 Buffer[]; 93062306a36Sopenharmony_ci} __packed; 93162306a36Sopenharmony_ci 93262306a36Sopenharmony_cistruct smb2_set_info_rsp { 93362306a36Sopenharmony_ci struct smb2_hdr hdr; 93462306a36Sopenharmony_ci __le16 StructureSize; /* Must be 2 */ 93562306a36Sopenharmony_ci} __packed; 93662306a36Sopenharmony_ci 93762306a36Sopenharmony_ci/* 93862306a36Sopenharmony_ci * SMB2_NOTIFY See MS-SMB2 section 2.2.35 93962306a36Sopenharmony_ci */ 94062306a36Sopenharmony_ci/* notify flags */ 94162306a36Sopenharmony_ci#define SMB2_WATCH_TREE 0x0001 94262306a36Sopenharmony_ci 94362306a36Sopenharmony_ci/* notify completion filter flags. See MS-FSCC 2.6 and MS-SMB2 2.2.35 */ 94462306a36Sopenharmony_ci#define FILE_NOTIFY_CHANGE_FILE_NAME 0x00000001 94562306a36Sopenharmony_ci#define FILE_NOTIFY_CHANGE_DIR_NAME 0x00000002 94662306a36Sopenharmony_ci#define FILE_NOTIFY_CHANGE_ATTRIBUTES 0x00000004 94762306a36Sopenharmony_ci#define FILE_NOTIFY_CHANGE_SIZE 0x00000008 94862306a36Sopenharmony_ci#define FILE_NOTIFY_CHANGE_LAST_WRITE 0x00000010 94962306a36Sopenharmony_ci#define FILE_NOTIFY_CHANGE_LAST_ACCESS 0x00000020 95062306a36Sopenharmony_ci#define FILE_NOTIFY_CHANGE_CREATION 0x00000040 95162306a36Sopenharmony_ci#define FILE_NOTIFY_CHANGE_EA 0x00000080 95262306a36Sopenharmony_ci#define FILE_NOTIFY_CHANGE_SECURITY 0x00000100 95362306a36Sopenharmony_ci#define FILE_NOTIFY_CHANGE_STREAM_NAME 0x00000200 95462306a36Sopenharmony_ci#define FILE_NOTIFY_CHANGE_STREAM_SIZE 0x00000400 95562306a36Sopenharmony_ci#define FILE_NOTIFY_CHANGE_STREAM_WRITE 0x00000800 95662306a36Sopenharmony_ci 95762306a36Sopenharmony_ci/* SMB2 Notify Action Flags */ 95862306a36Sopenharmony_ci#define FILE_ACTION_ADDED 0x00000001 95962306a36Sopenharmony_ci#define FILE_ACTION_REMOVED 0x00000002 96062306a36Sopenharmony_ci#define FILE_ACTION_MODIFIED 0x00000003 96162306a36Sopenharmony_ci#define FILE_ACTION_RENAMED_OLD_NAME 0x00000004 96262306a36Sopenharmony_ci#define FILE_ACTION_RENAMED_NEW_NAME 0x00000005 96362306a36Sopenharmony_ci#define FILE_ACTION_ADDED_STREAM 0x00000006 96462306a36Sopenharmony_ci#define FILE_ACTION_REMOVED_STREAM 0x00000007 96562306a36Sopenharmony_ci#define FILE_ACTION_MODIFIED_STREAM 0x00000008 96662306a36Sopenharmony_ci#define FILE_ACTION_REMOVED_BY_DELETE 0x00000009 96762306a36Sopenharmony_ci 96862306a36Sopenharmony_cistruct smb2_change_notify_req { 96962306a36Sopenharmony_ci struct smb2_hdr hdr; 97062306a36Sopenharmony_ci __le16 StructureSize; 97162306a36Sopenharmony_ci __le16 Flags; 97262306a36Sopenharmony_ci __le32 OutputBufferLength; 97362306a36Sopenharmony_ci __u64 PersistentFileId; /* opaque endianness */ 97462306a36Sopenharmony_ci __u64 VolatileFileId; /* opaque endianness */ 97562306a36Sopenharmony_ci __le32 CompletionFilter; 97662306a36Sopenharmony_ci __u32 Reserved; 97762306a36Sopenharmony_ci} __packed; 97862306a36Sopenharmony_ci 97962306a36Sopenharmony_cistruct smb2_change_notify_rsp { 98062306a36Sopenharmony_ci struct smb2_hdr hdr; 98162306a36Sopenharmony_ci __le16 StructureSize; /* Must be 9 */ 98262306a36Sopenharmony_ci __le16 OutputBufferOffset; 98362306a36Sopenharmony_ci __le32 OutputBufferLength; 98462306a36Sopenharmony_ci __u8 Buffer[]; /* array of file notify structs */ 98562306a36Sopenharmony_ci} __packed; 98662306a36Sopenharmony_ci 98762306a36Sopenharmony_ci 98862306a36Sopenharmony_ci/* 98962306a36Sopenharmony_ci * SMB2_CREATE See MS-SMB2 section 2.2.13 99062306a36Sopenharmony_ci */ 99162306a36Sopenharmony_ci/* Oplock levels */ 99262306a36Sopenharmony_ci#define SMB2_OPLOCK_LEVEL_NONE 0x00 99362306a36Sopenharmony_ci#define SMB2_OPLOCK_LEVEL_II 0x01 99462306a36Sopenharmony_ci#define SMB2_OPLOCK_LEVEL_EXCLUSIVE 0x08 99562306a36Sopenharmony_ci#define SMB2_OPLOCK_LEVEL_BATCH 0x09 99662306a36Sopenharmony_ci#define SMB2_OPLOCK_LEVEL_LEASE 0xFF 99762306a36Sopenharmony_ci/* Non-spec internal type */ 99862306a36Sopenharmony_ci#define SMB2_OPLOCK_LEVEL_NOCHANGE 0x99 99962306a36Sopenharmony_ci 100062306a36Sopenharmony_ci/* Impersonation Levels. See MS-WPO section 9.7 and MSDN-IMPERS */ 100162306a36Sopenharmony_ci#define IL_ANONYMOUS cpu_to_le32(0x00000000) 100262306a36Sopenharmony_ci#define IL_IDENTIFICATION cpu_to_le32(0x00000001) 100362306a36Sopenharmony_ci#define IL_IMPERSONATION cpu_to_le32(0x00000002) 100462306a36Sopenharmony_ci#define IL_DELEGATE cpu_to_le32(0x00000003) 100562306a36Sopenharmony_ci 100662306a36Sopenharmony_ci/* File Attrubutes */ 100762306a36Sopenharmony_ci#define FILE_ATTRIBUTE_READONLY 0x00000001 100862306a36Sopenharmony_ci#define FILE_ATTRIBUTE_HIDDEN 0x00000002 100962306a36Sopenharmony_ci#define FILE_ATTRIBUTE_SYSTEM 0x00000004 101062306a36Sopenharmony_ci#define FILE_ATTRIBUTE_DIRECTORY 0x00000010 101162306a36Sopenharmony_ci#define FILE_ATTRIBUTE_ARCHIVE 0x00000020 101262306a36Sopenharmony_ci#define FILE_ATTRIBUTE_NORMAL 0x00000080 101362306a36Sopenharmony_ci#define FILE_ATTRIBUTE_TEMPORARY 0x00000100 101462306a36Sopenharmony_ci#define FILE_ATTRIBUTE_SPARSE_FILE 0x00000200 101562306a36Sopenharmony_ci#define FILE_ATTRIBUTE_REPARSE_POINT 0x00000400 101662306a36Sopenharmony_ci#define FILE_ATTRIBUTE_COMPRESSED 0x00000800 101762306a36Sopenharmony_ci#define FILE_ATTRIBUTE_OFFLINE 0x00001000 101862306a36Sopenharmony_ci#define FILE_ATTRIBUTE_NOT_CONTENT_INDEXED 0x00002000 101962306a36Sopenharmony_ci#define FILE_ATTRIBUTE_ENCRYPTED 0x00004000 102062306a36Sopenharmony_ci#define FILE_ATTRIBUTE_INTEGRITY_STREAM 0x00008000 102162306a36Sopenharmony_ci#define FILE_ATTRIBUTE_NO_SCRUB_DATA 0x00020000 102262306a36Sopenharmony_ci#define FILE_ATTRIBUTE__MASK 0x00007FB7 102362306a36Sopenharmony_ci 102462306a36Sopenharmony_ci#define FILE_ATTRIBUTE_READONLY_LE cpu_to_le32(0x00000001) 102562306a36Sopenharmony_ci#define FILE_ATTRIBUTE_HIDDEN_LE cpu_to_le32(0x00000002) 102662306a36Sopenharmony_ci#define FILE_ATTRIBUTE_SYSTEM_LE cpu_to_le32(0x00000004) 102762306a36Sopenharmony_ci#define FILE_ATTRIBUTE_DIRECTORY_LE cpu_to_le32(0x00000010) 102862306a36Sopenharmony_ci#define FILE_ATTRIBUTE_ARCHIVE_LE cpu_to_le32(0x00000020) 102962306a36Sopenharmony_ci#define FILE_ATTRIBUTE_NORMAL_LE cpu_to_le32(0x00000080) 103062306a36Sopenharmony_ci#define FILE_ATTRIBUTE_TEMPORARY_LE cpu_to_le32(0x00000100) 103162306a36Sopenharmony_ci#define FILE_ATTRIBUTE_SPARSE_FILE_LE cpu_to_le32(0x00000200) 103262306a36Sopenharmony_ci#define FILE_ATTRIBUTE_REPARSE_POINT_LE cpu_to_le32(0x00000400) 103362306a36Sopenharmony_ci#define FILE_ATTRIBUTE_COMPRESSED_LE cpu_to_le32(0x00000800) 103462306a36Sopenharmony_ci#define FILE_ATTRIBUTE_OFFLINE_LE cpu_to_le32(0x00001000) 103562306a36Sopenharmony_ci#define FILE_ATTRIBUTE_NOT_CONTENT_INDEXED_LE cpu_to_le32(0x00002000) 103662306a36Sopenharmony_ci#define FILE_ATTRIBUTE_ENCRYPTED_LE cpu_to_le32(0x00004000) 103762306a36Sopenharmony_ci#define FILE_ATTRIBUTE_INTEGRITY_STREAM_LE cpu_to_le32(0x00008000) 103862306a36Sopenharmony_ci#define FILE_ATTRIBUTE_NO_SCRUB_DATA_LE cpu_to_le32(0x00020000) 103962306a36Sopenharmony_ci#define FILE_ATTRIBUTE_MASK_LE cpu_to_le32(0x00007FB7) 104062306a36Sopenharmony_ci 104162306a36Sopenharmony_ci/* Desired Access Flags */ 104262306a36Sopenharmony_ci#define FILE_READ_DATA_LE cpu_to_le32(0x00000001) 104362306a36Sopenharmony_ci#define FILE_LIST_DIRECTORY_LE cpu_to_le32(0x00000001) 104462306a36Sopenharmony_ci#define FILE_WRITE_DATA_LE cpu_to_le32(0x00000002) 104562306a36Sopenharmony_ci#define FILE_APPEND_DATA_LE cpu_to_le32(0x00000004) 104662306a36Sopenharmony_ci#define FILE_ADD_SUBDIRECTORY_LE cpu_to_le32(0x00000004) 104762306a36Sopenharmony_ci#define FILE_READ_EA_LE cpu_to_le32(0x00000008) 104862306a36Sopenharmony_ci#define FILE_WRITE_EA_LE cpu_to_le32(0x00000010) 104962306a36Sopenharmony_ci#define FILE_EXECUTE_LE cpu_to_le32(0x00000020) 105062306a36Sopenharmony_ci#define FILE_DELETE_CHILD_LE cpu_to_le32(0x00000040) 105162306a36Sopenharmony_ci#define FILE_READ_ATTRIBUTES_LE cpu_to_le32(0x00000080) 105262306a36Sopenharmony_ci#define FILE_WRITE_ATTRIBUTES_LE cpu_to_le32(0x00000100) 105362306a36Sopenharmony_ci#define FILE_DELETE_LE cpu_to_le32(0x00010000) 105462306a36Sopenharmony_ci#define FILE_READ_CONTROL_LE cpu_to_le32(0x00020000) 105562306a36Sopenharmony_ci#define FILE_WRITE_DAC_LE cpu_to_le32(0x00040000) 105662306a36Sopenharmony_ci#define FILE_WRITE_OWNER_LE cpu_to_le32(0x00080000) 105762306a36Sopenharmony_ci#define FILE_SYNCHRONIZE_LE cpu_to_le32(0x00100000) 105862306a36Sopenharmony_ci#define FILE_ACCESS_SYSTEM_SECURITY_LE cpu_to_le32(0x01000000) 105962306a36Sopenharmony_ci#define FILE_MAXIMAL_ACCESS_LE cpu_to_le32(0x02000000) 106062306a36Sopenharmony_ci#define FILE_GENERIC_ALL_LE cpu_to_le32(0x10000000) 106162306a36Sopenharmony_ci#define FILE_GENERIC_EXECUTE_LE cpu_to_le32(0x20000000) 106262306a36Sopenharmony_ci#define FILE_GENERIC_WRITE_LE cpu_to_le32(0x40000000) 106362306a36Sopenharmony_ci#define FILE_GENERIC_READ_LE cpu_to_le32(0x80000000) 106462306a36Sopenharmony_ci#define DESIRED_ACCESS_MASK cpu_to_le32(0xF21F01FF) 106562306a36Sopenharmony_ci 106662306a36Sopenharmony_ci 106762306a36Sopenharmony_ci#define FILE_READ_DESIRED_ACCESS_LE (FILE_READ_DATA_LE | \ 106862306a36Sopenharmony_ci FILE_READ_EA_LE | \ 106962306a36Sopenharmony_ci FILE_GENERIC_READ_LE) 107062306a36Sopenharmony_ci#define FILE_WRITE_DESIRE_ACCESS_LE (FILE_WRITE_DATA_LE | \ 107162306a36Sopenharmony_ci FILE_APPEND_DATA_LE | \ 107262306a36Sopenharmony_ci FILE_WRITE_EA_LE | \ 107362306a36Sopenharmony_ci FILE_WRITE_ATTRIBUTES_LE | \ 107462306a36Sopenharmony_ci FILE_GENERIC_WRITE_LE) 107562306a36Sopenharmony_ci 107662306a36Sopenharmony_ci/* ShareAccess Flags */ 107762306a36Sopenharmony_ci#define FILE_SHARE_READ_LE cpu_to_le32(0x00000001) 107862306a36Sopenharmony_ci#define FILE_SHARE_WRITE_LE cpu_to_le32(0x00000002) 107962306a36Sopenharmony_ci#define FILE_SHARE_DELETE_LE cpu_to_le32(0x00000004) 108062306a36Sopenharmony_ci#define FILE_SHARE_ALL_LE cpu_to_le32(0x00000007) 108162306a36Sopenharmony_ci 108262306a36Sopenharmony_ci/* CreateDisposition Flags */ 108362306a36Sopenharmony_ci#define FILE_SUPERSEDE_LE cpu_to_le32(0x00000000) 108462306a36Sopenharmony_ci#define FILE_OPEN_LE cpu_to_le32(0x00000001) 108562306a36Sopenharmony_ci#define FILE_CREATE_LE cpu_to_le32(0x00000002) 108662306a36Sopenharmony_ci#define FILE_OPEN_IF_LE cpu_to_le32(0x00000003) 108762306a36Sopenharmony_ci#define FILE_OVERWRITE_LE cpu_to_le32(0x00000004) 108862306a36Sopenharmony_ci#define FILE_OVERWRITE_IF_LE cpu_to_le32(0x00000005) 108962306a36Sopenharmony_ci#define FILE_CREATE_MASK_LE cpu_to_le32(0x00000007) 109062306a36Sopenharmony_ci 109162306a36Sopenharmony_ci#define FILE_READ_RIGHTS (FILE_READ_DATA | FILE_READ_EA \ 109262306a36Sopenharmony_ci | FILE_READ_ATTRIBUTES) 109362306a36Sopenharmony_ci#define FILE_WRITE_RIGHTS (FILE_WRITE_DATA | FILE_APPEND_DATA \ 109462306a36Sopenharmony_ci | FILE_WRITE_EA | FILE_WRITE_ATTRIBUTES) 109562306a36Sopenharmony_ci#define FILE_EXEC_RIGHTS (FILE_EXECUTE) 109662306a36Sopenharmony_ci 109762306a36Sopenharmony_ci/* CreateOptions Flags */ 109862306a36Sopenharmony_ci#define FILE_DIRECTORY_FILE_LE cpu_to_le32(0x00000001) 109962306a36Sopenharmony_ci/* same as #define CREATE_NOT_FILE_LE cpu_to_le32(0x00000001) */ 110062306a36Sopenharmony_ci#define FILE_WRITE_THROUGH_LE cpu_to_le32(0x00000002) 110162306a36Sopenharmony_ci#define FILE_SEQUENTIAL_ONLY_LE cpu_to_le32(0x00000004) 110262306a36Sopenharmony_ci#define FILE_NO_INTERMEDIATE_BUFFERING_LE cpu_to_le32(0x00000008) 110362306a36Sopenharmony_ci#define FILE_NON_DIRECTORY_FILE_LE cpu_to_le32(0x00000040) 110462306a36Sopenharmony_ci#define FILE_COMPLETE_IF_OPLOCKED_LE cpu_to_le32(0x00000100) 110562306a36Sopenharmony_ci#define FILE_NO_EA_KNOWLEDGE_LE cpu_to_le32(0x00000200) 110662306a36Sopenharmony_ci#define FILE_RANDOM_ACCESS_LE cpu_to_le32(0x00000800) 110762306a36Sopenharmony_ci#define FILE_DELETE_ON_CLOSE_LE cpu_to_le32(0x00001000) 110862306a36Sopenharmony_ci#define FILE_OPEN_BY_FILE_ID_LE cpu_to_le32(0x00002000) 110962306a36Sopenharmony_ci#define FILE_OPEN_FOR_BACKUP_INTENT_LE cpu_to_le32(0x00004000) 111062306a36Sopenharmony_ci#define FILE_NO_COMPRESSION_LE cpu_to_le32(0x00008000) 111162306a36Sopenharmony_ci#define FILE_OPEN_REPARSE_POINT_LE cpu_to_le32(0x00200000) 111262306a36Sopenharmony_ci#define FILE_OPEN_NO_RECALL_LE cpu_to_le32(0x00400000) 111362306a36Sopenharmony_ci#define CREATE_OPTIONS_MASK_LE cpu_to_le32(0x00FFFFFF) 111462306a36Sopenharmony_ci 111562306a36Sopenharmony_ci#define FILE_READ_RIGHTS_LE (FILE_READ_DATA_LE | FILE_READ_EA_LE \ 111662306a36Sopenharmony_ci | FILE_READ_ATTRIBUTES_LE) 111762306a36Sopenharmony_ci#define FILE_WRITE_RIGHTS_LE (FILE_WRITE_DATA_LE | FILE_APPEND_DATA_LE \ 111862306a36Sopenharmony_ci | FILE_WRITE_EA_LE | FILE_WRITE_ATTRIBUTES_LE) 111962306a36Sopenharmony_ci#define FILE_EXEC_RIGHTS_LE (FILE_EXECUTE_LE) 112062306a36Sopenharmony_ci 112162306a36Sopenharmony_ci/* Create Context Values */ 112262306a36Sopenharmony_ci#define SMB2_CREATE_EA_BUFFER "ExtA" /* extended attributes */ 112362306a36Sopenharmony_ci#define SMB2_CREATE_SD_BUFFER "SecD" /* security descriptor */ 112462306a36Sopenharmony_ci#define SMB2_CREATE_DURABLE_HANDLE_REQUEST "DHnQ" 112562306a36Sopenharmony_ci#define SMB2_CREATE_DURABLE_HANDLE_RECONNECT "DHnC" 112662306a36Sopenharmony_ci#define SMB2_CREATE_ALLOCATION_SIZE "AlSi" 112762306a36Sopenharmony_ci#define SMB2_CREATE_QUERY_MAXIMAL_ACCESS_REQUEST "MxAc" 112862306a36Sopenharmony_ci#define SMB2_CREATE_TIMEWARP_REQUEST "TWrp" 112962306a36Sopenharmony_ci#define SMB2_CREATE_QUERY_ON_DISK_ID "QFid" 113062306a36Sopenharmony_ci#define SMB2_CREATE_REQUEST_LEASE "RqLs" 113162306a36Sopenharmony_ci#define SMB2_CREATE_DURABLE_HANDLE_REQUEST_V2 "DH2Q" 113262306a36Sopenharmony_ci#define SMB2_CREATE_DURABLE_HANDLE_RECONNECT_V2 "DH2C" 113362306a36Sopenharmony_ci#define SMB2_CREATE_TAG_POSIX "\x93\xAD\x25\x50\x9C\xB4\x11\xE7\xB4\x23\x83\xDE\x96\x8B\xCD\x7C" 113462306a36Sopenharmony_ci#define SMB2_CREATE_APP_INSTANCE_ID "\x45\xBC\xA6\x6A\xEF\xA7\xF7\x4A\x90\x08\xFA\x46\x2E\x14\x4D\x74" 113562306a36Sopenharmony_ci#define SMB2_CREATE_APP_INSTANCE_VERSION "\xB9\x82\xD0\xB7\x3B\x56\x07\x4F\xA0\x7B\x52\x4A\x81\x16\xA0\x10" 113662306a36Sopenharmony_ci#define SVHDX_OPEN_DEVICE_CONTEXT "\x9C\xCB\xCF\x9E\x04\xC1\xE6\x43\x98\x0E\x15\x8D\xA1\xF6\xEC\x83" 113762306a36Sopenharmony_ci#define SMB2_CREATE_TAG_AAPL "AAPL" 113862306a36Sopenharmony_ci 113962306a36Sopenharmony_ci/* Flag (SMB3 open response) values */ 114062306a36Sopenharmony_ci#define SMB2_CREATE_FLAG_REPARSEPOINT 0x01 114162306a36Sopenharmony_ci 114262306a36Sopenharmony_cistruct create_context { 114362306a36Sopenharmony_ci __le32 Next; 114462306a36Sopenharmony_ci __le16 NameOffset; 114562306a36Sopenharmony_ci __le16 NameLength; 114662306a36Sopenharmony_ci __le16 Reserved; 114762306a36Sopenharmony_ci __le16 DataOffset; 114862306a36Sopenharmony_ci __le32 DataLength; 114962306a36Sopenharmony_ci __u8 Buffer[]; 115062306a36Sopenharmony_ci} __packed; 115162306a36Sopenharmony_ci 115262306a36Sopenharmony_cistruct smb2_create_req { 115362306a36Sopenharmony_ci struct smb2_hdr hdr; 115462306a36Sopenharmony_ci __le16 StructureSize; /* Must be 57 */ 115562306a36Sopenharmony_ci __u8 SecurityFlags; 115662306a36Sopenharmony_ci __u8 RequestedOplockLevel; 115762306a36Sopenharmony_ci __le32 ImpersonationLevel; 115862306a36Sopenharmony_ci __le64 SmbCreateFlags; 115962306a36Sopenharmony_ci __le64 Reserved; 116062306a36Sopenharmony_ci __le32 DesiredAccess; 116162306a36Sopenharmony_ci __le32 FileAttributes; 116262306a36Sopenharmony_ci __le32 ShareAccess; 116362306a36Sopenharmony_ci __le32 CreateDisposition; 116462306a36Sopenharmony_ci __le32 CreateOptions; 116562306a36Sopenharmony_ci __le16 NameOffset; 116662306a36Sopenharmony_ci __le16 NameLength; 116762306a36Sopenharmony_ci __le32 CreateContextsOffset; 116862306a36Sopenharmony_ci __le32 CreateContextsLength; 116962306a36Sopenharmony_ci __u8 Buffer[]; 117062306a36Sopenharmony_ci} __packed; 117162306a36Sopenharmony_ci 117262306a36Sopenharmony_cistruct smb2_create_rsp { 117362306a36Sopenharmony_ci struct smb2_hdr hdr; 117462306a36Sopenharmony_ci __le16 StructureSize; /* Must be 89 */ 117562306a36Sopenharmony_ci __u8 OplockLevel; 117662306a36Sopenharmony_ci __u8 Flags; /* 0x01 if reparse point */ 117762306a36Sopenharmony_ci __le32 CreateAction; 117862306a36Sopenharmony_ci __le64 CreationTime; 117962306a36Sopenharmony_ci __le64 LastAccessTime; 118062306a36Sopenharmony_ci __le64 LastWriteTime; 118162306a36Sopenharmony_ci __le64 ChangeTime; 118262306a36Sopenharmony_ci __le64 AllocationSize; 118362306a36Sopenharmony_ci __le64 EndofFile; 118462306a36Sopenharmony_ci __le32 FileAttributes; 118562306a36Sopenharmony_ci __le32 Reserved2; 118662306a36Sopenharmony_ci __u64 PersistentFileId; 118762306a36Sopenharmony_ci __u64 VolatileFileId; 118862306a36Sopenharmony_ci __le32 CreateContextsOffset; 118962306a36Sopenharmony_ci __le32 CreateContextsLength; 119062306a36Sopenharmony_ci __u8 Buffer[]; 119162306a36Sopenharmony_ci} __packed; 119262306a36Sopenharmony_ci 119362306a36Sopenharmony_cistruct create_posix { 119462306a36Sopenharmony_ci struct create_context ccontext; 119562306a36Sopenharmony_ci __u8 Name[16]; 119662306a36Sopenharmony_ci __le32 Mode; 119762306a36Sopenharmony_ci __u32 Reserved; 119862306a36Sopenharmony_ci} __packed; 119962306a36Sopenharmony_ci 120062306a36Sopenharmony_ci/* See MS-SMB2 2.2.13.2.3 and MS-SMB2 2.2.13.2.4 */ 120162306a36Sopenharmony_cistruct create_durable { 120262306a36Sopenharmony_ci struct create_context ccontext; 120362306a36Sopenharmony_ci __u8 Name[8]; 120462306a36Sopenharmony_ci union { 120562306a36Sopenharmony_ci __u8 Reserved[16]; 120662306a36Sopenharmony_ci struct { 120762306a36Sopenharmony_ci __u64 PersistentFileId; 120862306a36Sopenharmony_ci __u64 VolatileFileId; 120962306a36Sopenharmony_ci } Fid; 121062306a36Sopenharmony_ci } Data; 121162306a36Sopenharmony_ci} __packed; 121262306a36Sopenharmony_ci 121362306a36Sopenharmony_ci/* See MS-SMB2 2.2.13.2.5 */ 121462306a36Sopenharmony_cistruct create_mxac_req { 121562306a36Sopenharmony_ci struct create_context ccontext; 121662306a36Sopenharmony_ci __u8 Name[8]; 121762306a36Sopenharmony_ci __le64 Timestamp; 121862306a36Sopenharmony_ci} __packed; 121962306a36Sopenharmony_ci 122062306a36Sopenharmony_ci/* See MS-SMB2 2.2.14.2.5 */ 122162306a36Sopenharmony_cistruct create_mxac_rsp { 122262306a36Sopenharmony_ci struct create_context ccontext; 122362306a36Sopenharmony_ci __u8 Name[8]; 122462306a36Sopenharmony_ci __le32 QueryStatus; 122562306a36Sopenharmony_ci __le32 MaximalAccess; 122662306a36Sopenharmony_ci} __packed; 122762306a36Sopenharmony_ci 122862306a36Sopenharmony_ci#define SMB2_LEASE_NONE_LE cpu_to_le32(0x00) 122962306a36Sopenharmony_ci#define SMB2_LEASE_READ_CACHING_LE cpu_to_le32(0x01) 123062306a36Sopenharmony_ci#define SMB2_LEASE_HANDLE_CACHING_LE cpu_to_le32(0x02) 123162306a36Sopenharmony_ci#define SMB2_LEASE_WRITE_CACHING_LE cpu_to_le32(0x04) 123262306a36Sopenharmony_ci 123362306a36Sopenharmony_ci#define SMB2_LEASE_FLAG_BREAK_IN_PROGRESS_LE cpu_to_le32(0x02) 123462306a36Sopenharmony_ci#define SMB2_LEASE_FLAG_PARENT_LEASE_KEY_SET_LE cpu_to_le32(0x04) 123562306a36Sopenharmony_ci 123662306a36Sopenharmony_ci#define SMB2_LEASE_KEY_SIZE 16 123762306a36Sopenharmony_ci 123862306a36Sopenharmony_ci/* See MS-SMB2 2.2.13.2.8 */ 123962306a36Sopenharmony_cistruct lease_context { 124062306a36Sopenharmony_ci __u8 LeaseKey[SMB2_LEASE_KEY_SIZE]; 124162306a36Sopenharmony_ci __le32 LeaseState; 124262306a36Sopenharmony_ci __le32 LeaseFlags; 124362306a36Sopenharmony_ci __le64 LeaseDuration; 124462306a36Sopenharmony_ci} __packed; 124562306a36Sopenharmony_ci 124662306a36Sopenharmony_ci/* See MS-SMB2 2.2.13.2.10 */ 124762306a36Sopenharmony_cistruct lease_context_v2 { 124862306a36Sopenharmony_ci __u8 LeaseKey[SMB2_LEASE_KEY_SIZE]; 124962306a36Sopenharmony_ci __le32 LeaseState; 125062306a36Sopenharmony_ci __le32 LeaseFlags; 125162306a36Sopenharmony_ci __le64 LeaseDuration; 125262306a36Sopenharmony_ci __u8 ParentLeaseKey[SMB2_LEASE_KEY_SIZE]; 125362306a36Sopenharmony_ci __le16 Epoch; 125462306a36Sopenharmony_ci __le16 Reserved; 125562306a36Sopenharmony_ci} __packed; 125662306a36Sopenharmony_ci 125762306a36Sopenharmony_cistruct create_lease { 125862306a36Sopenharmony_ci struct create_context ccontext; 125962306a36Sopenharmony_ci __u8 Name[8]; 126062306a36Sopenharmony_ci struct lease_context lcontext; 126162306a36Sopenharmony_ci} __packed; 126262306a36Sopenharmony_ci 126362306a36Sopenharmony_cistruct create_lease_v2 { 126462306a36Sopenharmony_ci struct create_context ccontext; 126562306a36Sopenharmony_ci __u8 Name[8]; 126662306a36Sopenharmony_ci struct lease_context_v2 lcontext; 126762306a36Sopenharmony_ci __u8 Pad[4]; 126862306a36Sopenharmony_ci} __packed; 126962306a36Sopenharmony_ci 127062306a36Sopenharmony_ci/* See MS-SMB2 2.2.14.2.9 */ 127162306a36Sopenharmony_cistruct create_disk_id_rsp { 127262306a36Sopenharmony_ci struct create_context ccontext; 127362306a36Sopenharmony_ci __u8 Name[8]; 127462306a36Sopenharmony_ci __le64 DiskFileId; 127562306a36Sopenharmony_ci __le64 VolumeId; 127662306a36Sopenharmony_ci __u8 Reserved[16]; 127762306a36Sopenharmony_ci} __packed; 127862306a36Sopenharmony_ci 127962306a36Sopenharmony_ci/* See MS-SMB2 2.2.13.2.13 */ 128062306a36Sopenharmony_cistruct create_app_inst_id { 128162306a36Sopenharmony_ci struct create_context ccontext; 128262306a36Sopenharmony_ci __u8 Name[16]; 128362306a36Sopenharmony_ci __le32 StructureSize; /* Must be 20 */ 128462306a36Sopenharmony_ci __u16 Reserved; 128562306a36Sopenharmony_ci __u8 AppInstanceId[16]; 128662306a36Sopenharmony_ci} __packed; 128762306a36Sopenharmony_ci 128862306a36Sopenharmony_ci/* See MS-SMB2 2.2.13.2.15 */ 128962306a36Sopenharmony_cistruct create_app_inst_id_vers { 129062306a36Sopenharmony_ci struct create_context ccontext; 129162306a36Sopenharmony_ci __u8 Name[16]; 129262306a36Sopenharmony_ci __le32 StructureSize; /* Must be 24 */ 129362306a36Sopenharmony_ci __u16 Reserved; 129462306a36Sopenharmony_ci __u32 Padding; 129562306a36Sopenharmony_ci __le64 AppInstanceVersionHigh; 129662306a36Sopenharmony_ci __le64 AppInstanceVersionLow; 129762306a36Sopenharmony_ci} __packed; 129862306a36Sopenharmony_ci 129962306a36Sopenharmony_ci/* See MS-SMB2 2.2.31 and 2.2.32 */ 130062306a36Sopenharmony_cistruct smb2_ioctl_req { 130162306a36Sopenharmony_ci struct smb2_hdr hdr; 130262306a36Sopenharmony_ci __le16 StructureSize; /* Must be 57 */ 130362306a36Sopenharmony_ci __le16 Reserved; /* offset from start of SMB2 header to write data */ 130462306a36Sopenharmony_ci __le32 CtlCode; 130562306a36Sopenharmony_ci __u64 PersistentFileId; 130662306a36Sopenharmony_ci __u64 VolatileFileId; 130762306a36Sopenharmony_ci __le32 InputOffset; /* Reserved MBZ */ 130862306a36Sopenharmony_ci __le32 InputCount; 130962306a36Sopenharmony_ci __le32 MaxInputResponse; 131062306a36Sopenharmony_ci __le32 OutputOffset; 131162306a36Sopenharmony_ci __le32 OutputCount; 131262306a36Sopenharmony_ci __le32 MaxOutputResponse; 131362306a36Sopenharmony_ci __le32 Flags; 131462306a36Sopenharmony_ci __le32 Reserved2; 131562306a36Sopenharmony_ci __u8 Buffer[]; 131662306a36Sopenharmony_ci} __packed; 131762306a36Sopenharmony_ci 131862306a36Sopenharmony_cistruct smb2_ioctl_rsp { 131962306a36Sopenharmony_ci struct smb2_hdr hdr; 132062306a36Sopenharmony_ci __le16 StructureSize; /* Must be 49 */ 132162306a36Sopenharmony_ci __le16 Reserved; 132262306a36Sopenharmony_ci __le32 CtlCode; 132362306a36Sopenharmony_ci __u64 PersistentFileId; 132462306a36Sopenharmony_ci __u64 VolatileFileId; 132562306a36Sopenharmony_ci __le32 InputOffset; /* Reserved MBZ */ 132662306a36Sopenharmony_ci __le32 InputCount; 132762306a36Sopenharmony_ci __le32 OutputOffset; 132862306a36Sopenharmony_ci __le32 OutputCount; 132962306a36Sopenharmony_ci __le32 Flags; 133062306a36Sopenharmony_ci __le32 Reserved2; 133162306a36Sopenharmony_ci __u8 Buffer[]; 133262306a36Sopenharmony_ci} __packed; 133362306a36Sopenharmony_ci 133462306a36Sopenharmony_ci/* this goes in the ioctl buffer when doing FSCTL_SET_ZERO_DATA */ 133562306a36Sopenharmony_cistruct file_zero_data_information { 133662306a36Sopenharmony_ci __le64 FileOffset; 133762306a36Sopenharmony_ci __le64 BeyondFinalZero; 133862306a36Sopenharmony_ci} __packed; 133962306a36Sopenharmony_ci 134062306a36Sopenharmony_ci/* See MS-FSCC 2.3.7 */ 134162306a36Sopenharmony_cistruct duplicate_extents_to_file { 134262306a36Sopenharmony_ci __u64 PersistentFileHandle; /* source file handle, opaque endianness */ 134362306a36Sopenharmony_ci __u64 VolatileFileHandle; 134462306a36Sopenharmony_ci __le64 SourceFileOffset; 134562306a36Sopenharmony_ci __le64 TargetFileOffset; 134662306a36Sopenharmony_ci __le64 ByteCount; /* Bytes to be copied */ 134762306a36Sopenharmony_ci} __packed; 134862306a36Sopenharmony_ci 134962306a36Sopenharmony_ci/* See MS-FSCC 2.3.8 */ 135062306a36Sopenharmony_ci#define DUPLICATE_EXTENTS_DATA_EX_SOURCE_ATOMIC 0x00000001 135162306a36Sopenharmony_cistruct duplicate_extents_to_file_ex { 135262306a36Sopenharmony_ci __u64 PersistentFileHandle; /* source file handle, opaque endianness */ 135362306a36Sopenharmony_ci __u64 VolatileFileHandle; 135462306a36Sopenharmony_ci __le64 SourceFileOffset; 135562306a36Sopenharmony_ci __le64 TargetFileOffset; 135662306a36Sopenharmony_ci __le64 ByteCount; /* Bytes to be copied */ 135762306a36Sopenharmony_ci __le32 Flags; 135862306a36Sopenharmony_ci __le32 Reserved; 135962306a36Sopenharmony_ci} __packed; 136062306a36Sopenharmony_ci 136162306a36Sopenharmony_ci 136262306a36Sopenharmony_ci/* See MS-FSCC 2.3.20 */ 136362306a36Sopenharmony_cistruct fsctl_get_integrity_information_rsp { 136462306a36Sopenharmony_ci __le16 ChecksumAlgorithm; 136562306a36Sopenharmony_ci __le16 Reserved; 136662306a36Sopenharmony_ci __le32 Flags; 136762306a36Sopenharmony_ci __le32 ChecksumChunkSizeInBytes; 136862306a36Sopenharmony_ci __le32 ClusterSizeInBytes; 136962306a36Sopenharmony_ci} __packed; 137062306a36Sopenharmony_ci 137162306a36Sopenharmony_ci/* See MS-FSCC 2.3.55 */ 137262306a36Sopenharmony_cistruct fsctl_query_file_regions_req { 137362306a36Sopenharmony_ci __le64 FileOffset; 137462306a36Sopenharmony_ci __le64 Length; 137562306a36Sopenharmony_ci __le32 DesiredUsage; 137662306a36Sopenharmony_ci __le32 Reserved; 137762306a36Sopenharmony_ci} __packed; 137862306a36Sopenharmony_ci 137962306a36Sopenharmony_ci/* DesiredUsage flags see MS-FSCC 2.3.56.1 */ 138062306a36Sopenharmony_ci#define FILE_USAGE_INVALID_RANGE 0x00000000 138162306a36Sopenharmony_ci#define FILE_USAGE_VALID_CACHED_DATA 0x00000001 138262306a36Sopenharmony_ci#define FILE_USAGE_NONCACHED_DATA 0x00000002 138362306a36Sopenharmony_ci 138462306a36Sopenharmony_cistruct file_region_info { 138562306a36Sopenharmony_ci __le64 FileOffset; 138662306a36Sopenharmony_ci __le64 Length; 138762306a36Sopenharmony_ci __le32 DesiredUsage; 138862306a36Sopenharmony_ci __le32 Reserved; 138962306a36Sopenharmony_ci} __packed; 139062306a36Sopenharmony_ci 139162306a36Sopenharmony_ci/* See MS-FSCC 2.3.56 */ 139262306a36Sopenharmony_cistruct fsctl_query_file_region_rsp { 139362306a36Sopenharmony_ci __le32 Flags; 139462306a36Sopenharmony_ci __le32 TotalRegionEntryCount; 139562306a36Sopenharmony_ci __le32 RegionEntryCount; 139662306a36Sopenharmony_ci __u32 Reserved; 139762306a36Sopenharmony_ci struct file_region_info Regions[]; 139862306a36Sopenharmony_ci} __packed; 139962306a36Sopenharmony_ci 140062306a36Sopenharmony_ci/* See MS-FSCC 2.3.58 */ 140162306a36Sopenharmony_cistruct fsctl_query_on_disk_vol_info_rsp { 140262306a36Sopenharmony_ci __le64 DirectoryCount; 140362306a36Sopenharmony_ci __le64 FileCount; 140462306a36Sopenharmony_ci __le16 FsFormatMajVersion; 140562306a36Sopenharmony_ci __le16 FsFormatMinVersion; 140662306a36Sopenharmony_ci __u8 FsFormatName[24]; 140762306a36Sopenharmony_ci __le64 FormatTime; 140862306a36Sopenharmony_ci __le64 LastUpdateTime; 140962306a36Sopenharmony_ci __u8 CopyrightInfo[68]; 141062306a36Sopenharmony_ci __u8 AbstractInfo[68]; 141162306a36Sopenharmony_ci __u8 FormatImplInfo[68]; 141262306a36Sopenharmony_ci __u8 LastModifyImplInfo[68]; 141362306a36Sopenharmony_ci} __packed; 141462306a36Sopenharmony_ci 141562306a36Sopenharmony_ci/* See MS-FSCC 2.3.73 */ 141662306a36Sopenharmony_cistruct fsctl_set_integrity_information_req { 141762306a36Sopenharmony_ci __le16 ChecksumAlgorithm; 141862306a36Sopenharmony_ci __le16 Reserved; 141962306a36Sopenharmony_ci __le32 Flags; 142062306a36Sopenharmony_ci} __packed; 142162306a36Sopenharmony_ci 142262306a36Sopenharmony_ci/* See MS-FSCC 2.3.75 */ 142362306a36Sopenharmony_cistruct fsctl_set_integrity_info_ex_req { 142462306a36Sopenharmony_ci __u8 EnableIntegrity; 142562306a36Sopenharmony_ci __u8 KeepState; 142662306a36Sopenharmony_ci __u16 Reserved; 142762306a36Sopenharmony_ci __le32 Flags; 142862306a36Sopenharmony_ci __u8 Version; 142962306a36Sopenharmony_ci __u8 Reserved2[7]; 143062306a36Sopenharmony_ci} __packed; 143162306a36Sopenharmony_ci 143262306a36Sopenharmony_ci/* Integrity ChecksumAlgorithm choices for above */ 143362306a36Sopenharmony_ci#define CHECKSUM_TYPE_NONE 0x0000 143462306a36Sopenharmony_ci#define CHECKSUM_TYPE_CRC64 0x0002 143562306a36Sopenharmony_ci#define CHECKSUM_TYPE_UNCHANGED 0xFFFF /* set only */ 143662306a36Sopenharmony_ci 143762306a36Sopenharmony_ci/* Integrity flags for above */ 143862306a36Sopenharmony_ci#define FSCTL_INTEGRITY_FLAG_CHECKSUM_ENFORCEMENT_OFF 0x00000001 143962306a36Sopenharmony_ci 144062306a36Sopenharmony_ci/* Reparse structures - see MS-FSCC 2.1.2 */ 144162306a36Sopenharmony_ci 144262306a36Sopenharmony_ci/* struct fsctl_reparse_info_req is empty, only response structs (see below) */ 144362306a36Sopenharmony_cistruct reparse_data_buffer { 144462306a36Sopenharmony_ci __le32 ReparseTag; 144562306a36Sopenharmony_ci __le16 ReparseDataLength; 144662306a36Sopenharmony_ci __u16 Reserved; 144762306a36Sopenharmony_ci __u8 DataBuffer[]; /* Variable Length */ 144862306a36Sopenharmony_ci} __packed; 144962306a36Sopenharmony_ci 145062306a36Sopenharmony_cistruct reparse_guid_data_buffer { 145162306a36Sopenharmony_ci __le32 ReparseTag; 145262306a36Sopenharmony_ci __le16 ReparseDataLength; 145362306a36Sopenharmony_ci __u16 Reserved; 145462306a36Sopenharmony_ci __u8 ReparseGuid[16]; 145562306a36Sopenharmony_ci __u8 DataBuffer[]; /* Variable Length */ 145662306a36Sopenharmony_ci} __packed; 145762306a36Sopenharmony_ci 145862306a36Sopenharmony_cistruct reparse_mount_point_data_buffer { 145962306a36Sopenharmony_ci __le32 ReparseTag; 146062306a36Sopenharmony_ci __le16 ReparseDataLength; 146162306a36Sopenharmony_ci __u16 Reserved; 146262306a36Sopenharmony_ci __le16 SubstituteNameOffset; 146362306a36Sopenharmony_ci __le16 SubstituteNameLength; 146462306a36Sopenharmony_ci __le16 PrintNameOffset; 146562306a36Sopenharmony_ci __le16 PrintNameLength; 146662306a36Sopenharmony_ci __u8 PathBuffer[]; /* Variable Length */ 146762306a36Sopenharmony_ci} __packed; 146862306a36Sopenharmony_ci 146962306a36Sopenharmony_ci#define SYMLINK_FLAG_RELATIVE 0x00000001 147062306a36Sopenharmony_ci 147162306a36Sopenharmony_cistruct reparse_symlink_data_buffer { 147262306a36Sopenharmony_ci __le32 ReparseTag; 147362306a36Sopenharmony_ci __le16 ReparseDataLength; 147462306a36Sopenharmony_ci __u16 Reserved; 147562306a36Sopenharmony_ci __le16 SubstituteNameOffset; 147662306a36Sopenharmony_ci __le16 SubstituteNameLength; 147762306a36Sopenharmony_ci __le16 PrintNameOffset; 147862306a36Sopenharmony_ci __le16 PrintNameLength; 147962306a36Sopenharmony_ci __le32 Flags; 148062306a36Sopenharmony_ci __u8 PathBuffer[]; /* Variable Length */ 148162306a36Sopenharmony_ci} __packed; 148262306a36Sopenharmony_ci 148362306a36Sopenharmony_ci/* See MS-FSCC 2.1.2.6 and cifspdu.h for struct reparse_posix_data */ 148462306a36Sopenharmony_ci 148562306a36Sopenharmony_cistruct validate_negotiate_info_req { 148662306a36Sopenharmony_ci __le32 Capabilities; 148762306a36Sopenharmony_ci __u8 Guid[SMB2_CLIENT_GUID_SIZE]; 148862306a36Sopenharmony_ci __le16 SecurityMode; 148962306a36Sopenharmony_ci __le16 DialectCount; 149062306a36Sopenharmony_ci __le16 Dialects[4]; /* BB expand this if autonegotiate > 4 dialects */ 149162306a36Sopenharmony_ci} __packed; 149262306a36Sopenharmony_ci 149362306a36Sopenharmony_cistruct validate_negotiate_info_rsp { 149462306a36Sopenharmony_ci __le32 Capabilities; 149562306a36Sopenharmony_ci __u8 Guid[SMB2_CLIENT_GUID_SIZE]; 149662306a36Sopenharmony_ci __le16 SecurityMode; 149762306a36Sopenharmony_ci __le16 Dialect; /* Dialect in use for the connection */ 149862306a36Sopenharmony_ci} __packed; 149962306a36Sopenharmony_ci 150062306a36Sopenharmony_ci 150162306a36Sopenharmony_ci/* Possible InfoType values */ 150262306a36Sopenharmony_ci#define SMB2_O_INFO_FILE 0x01 150362306a36Sopenharmony_ci#define SMB2_O_INFO_FILESYSTEM 0x02 150462306a36Sopenharmony_ci#define SMB2_O_INFO_SECURITY 0x03 150562306a36Sopenharmony_ci#define SMB2_O_INFO_QUOTA 0x04 150662306a36Sopenharmony_ci 150762306a36Sopenharmony_ci/* SMB2 Query Info see MS-SMB2 (2.2.37) or MS-DTYP */ 150862306a36Sopenharmony_ci 150962306a36Sopenharmony_ci/* List of QUERY INFO levels (those also valid for QUERY_DIR are noted below */ 151062306a36Sopenharmony_ci#define FILE_DIRECTORY_INFORMATION 1 /* also for QUERY_DIR */ 151162306a36Sopenharmony_ci#define FILE_FULL_DIRECTORY_INFORMATION 2 /* also for QUERY_DIR */ 151262306a36Sopenharmony_ci#define FILE_BOTH_DIRECTORY_INFORMATION 3 /* also for QUERY_DIR */ 151362306a36Sopenharmony_ci#define FILE_BASIC_INFORMATION 4 151462306a36Sopenharmony_ci#define FILE_STANDARD_INFORMATION 5 151562306a36Sopenharmony_ci#define FILE_INTERNAL_INFORMATION 6 151662306a36Sopenharmony_ci#define FILE_EA_INFORMATION 7 151762306a36Sopenharmony_ci#define FILE_ACCESS_INFORMATION 8 151862306a36Sopenharmony_ci#define FILE_NAME_INFORMATION 9 151962306a36Sopenharmony_ci#define FILE_RENAME_INFORMATION 10 152062306a36Sopenharmony_ci#define FILE_LINK_INFORMATION 11 152162306a36Sopenharmony_ci#define FILE_NAMES_INFORMATION 12 /* also for QUERY_DIR */ 152262306a36Sopenharmony_ci#define FILE_DISPOSITION_INFORMATION 13 152362306a36Sopenharmony_ci#define FILE_POSITION_INFORMATION 14 152462306a36Sopenharmony_ci#define FILE_FULL_EA_INFORMATION 15 152562306a36Sopenharmony_ci#define FILE_MODE_INFORMATION 16 152662306a36Sopenharmony_ci#define FILE_ALIGNMENT_INFORMATION 17 152762306a36Sopenharmony_ci#define FILE_ALL_INFORMATION 18 152862306a36Sopenharmony_ci#define FILE_ALLOCATION_INFORMATION 19 152962306a36Sopenharmony_ci#define FILE_END_OF_FILE_INFORMATION 20 153062306a36Sopenharmony_ci#define FILE_ALTERNATE_NAME_INFORMATION 21 153162306a36Sopenharmony_ci#define FILE_STREAM_INFORMATION 22 153262306a36Sopenharmony_ci#define FILE_PIPE_INFORMATION 23 153362306a36Sopenharmony_ci#define FILE_PIPE_LOCAL_INFORMATION 24 153462306a36Sopenharmony_ci#define FILE_PIPE_REMOTE_INFORMATION 25 153562306a36Sopenharmony_ci#define FILE_MAILSLOT_QUERY_INFORMATION 26 153662306a36Sopenharmony_ci#define FILE_MAILSLOT_SET_INFORMATION 27 153762306a36Sopenharmony_ci#define FILE_COMPRESSION_INFORMATION 28 153862306a36Sopenharmony_ci#define FILE_OBJECT_ID_INFORMATION 29 153962306a36Sopenharmony_ci/* Number 30 not defined in documents */ 154062306a36Sopenharmony_ci#define FILE_MOVE_CLUSTER_INFORMATION 31 154162306a36Sopenharmony_ci#define FILE_QUOTA_INFORMATION 32 154262306a36Sopenharmony_ci#define FILE_REPARSE_POINT_INFORMATION 33 154362306a36Sopenharmony_ci#define FILE_NETWORK_OPEN_INFORMATION 34 154462306a36Sopenharmony_ci#define FILE_ATTRIBUTE_TAG_INFORMATION 35 154562306a36Sopenharmony_ci#define FILE_TRACKING_INFORMATION 36 154662306a36Sopenharmony_ci#define FILEID_BOTH_DIRECTORY_INFORMATION 37 /* also for QUERY_DIR */ 154762306a36Sopenharmony_ci#define FILEID_FULL_DIRECTORY_INFORMATION 38 /* also for QUERY_DIR */ 154862306a36Sopenharmony_ci#define FILE_VALID_DATA_LENGTH_INFORMATION 39 154962306a36Sopenharmony_ci#define FILE_SHORT_NAME_INFORMATION 40 155062306a36Sopenharmony_ci#define FILE_SFIO_RESERVE_INFORMATION 44 155162306a36Sopenharmony_ci#define FILE_SFIO_VOLUME_INFORMATION 45 155262306a36Sopenharmony_ci#define FILE_HARD_LINK_INFORMATION 46 155362306a36Sopenharmony_ci#define FILE_NORMALIZED_NAME_INFORMATION 48 155462306a36Sopenharmony_ci#define FILEID_GLOBAL_TX_DIRECTORY_INFORMATION 50 155562306a36Sopenharmony_ci#define FILE_STANDARD_LINK_INFORMATION 54 155662306a36Sopenharmony_ci#define FILE_ID_INFORMATION 59 155762306a36Sopenharmony_ci#define FILE_ID_EXTD_DIRECTORY_INFORMATION 60 /* also for QUERY_DIR */ 155862306a36Sopenharmony_ci/* Used for Query Info and Find File POSIX Info for SMB3.1.1 and SMB1 */ 155962306a36Sopenharmony_ci#define SMB_FIND_FILE_POSIX_INFO 0x064 156062306a36Sopenharmony_ci 156162306a36Sopenharmony_ci/* Security info type additionalinfo flags. */ 156262306a36Sopenharmony_ci#define OWNER_SECINFO 0x00000001 156362306a36Sopenharmony_ci#define GROUP_SECINFO 0x00000002 156462306a36Sopenharmony_ci#define DACL_SECINFO 0x00000004 156562306a36Sopenharmony_ci#define SACL_SECINFO 0x00000008 156662306a36Sopenharmony_ci#define LABEL_SECINFO 0x00000010 156762306a36Sopenharmony_ci#define ATTRIBUTE_SECINFO 0x00000020 156862306a36Sopenharmony_ci#define SCOPE_SECINFO 0x00000040 156962306a36Sopenharmony_ci#define BACKUP_SECINFO 0x00010000 157062306a36Sopenharmony_ci#define UNPROTECTED_SACL_SECINFO 0x10000000 157162306a36Sopenharmony_ci#define UNPROTECTED_DACL_SECINFO 0x20000000 157262306a36Sopenharmony_ci#define PROTECTED_SACL_SECINFO 0x40000000 157362306a36Sopenharmony_ci#define PROTECTED_DACL_SECINFO 0x80000000 157462306a36Sopenharmony_ci 157562306a36Sopenharmony_ci/* Flags used for FileFullEAinfo */ 157662306a36Sopenharmony_ci#define SL_RESTART_SCAN 0x00000001 157762306a36Sopenharmony_ci#define SL_RETURN_SINGLE_ENTRY 0x00000002 157862306a36Sopenharmony_ci#define SL_INDEX_SPECIFIED 0x00000004 157962306a36Sopenharmony_ci 158062306a36Sopenharmony_cistruct smb2_query_info_req { 158162306a36Sopenharmony_ci struct smb2_hdr hdr; 158262306a36Sopenharmony_ci __le16 StructureSize; /* Must be 41 */ 158362306a36Sopenharmony_ci __u8 InfoType; 158462306a36Sopenharmony_ci __u8 FileInfoClass; 158562306a36Sopenharmony_ci __le32 OutputBufferLength; 158662306a36Sopenharmony_ci __le16 InputBufferOffset; 158762306a36Sopenharmony_ci __u16 Reserved; 158862306a36Sopenharmony_ci __le32 InputBufferLength; 158962306a36Sopenharmony_ci __le32 AdditionalInformation; 159062306a36Sopenharmony_ci __le32 Flags; 159162306a36Sopenharmony_ci __u64 PersistentFileId; 159262306a36Sopenharmony_ci __u64 VolatileFileId; 159362306a36Sopenharmony_ci __u8 Buffer[]; 159462306a36Sopenharmony_ci} __packed; 159562306a36Sopenharmony_ci 159662306a36Sopenharmony_cistruct smb2_query_info_rsp { 159762306a36Sopenharmony_ci struct smb2_hdr hdr; 159862306a36Sopenharmony_ci __le16 StructureSize; /* Must be 9 */ 159962306a36Sopenharmony_ci __le16 OutputBufferOffset; 160062306a36Sopenharmony_ci __le32 OutputBufferLength; 160162306a36Sopenharmony_ci __u8 Buffer[]; 160262306a36Sopenharmony_ci} __packed; 160362306a36Sopenharmony_ci 160462306a36Sopenharmony_ci/* 160562306a36Sopenharmony_ci * PDU query infolevel structure definitions 160662306a36Sopenharmony_ci */ 160762306a36Sopenharmony_ci 160862306a36Sopenharmony_ci/* See MS-FSCC 2.3.52 */ 160962306a36Sopenharmony_cistruct file_allocated_range_buffer { 161062306a36Sopenharmony_ci __le64 file_offset; 161162306a36Sopenharmony_ci __le64 length; 161262306a36Sopenharmony_ci} __packed; 161362306a36Sopenharmony_ci 161462306a36Sopenharmony_cistruct smb2_file_internal_info { 161562306a36Sopenharmony_ci __le64 IndexNumber; 161662306a36Sopenharmony_ci} __packed; /* level 6 Query */ 161762306a36Sopenharmony_ci 161862306a36Sopenharmony_cistruct smb2_file_rename_info { /* encoding of request for level 10 */ 161962306a36Sopenharmony_ci __u8 ReplaceIfExists; /* 1 = replace existing target with new */ 162062306a36Sopenharmony_ci /* 0 = fail if target already exists */ 162162306a36Sopenharmony_ci __u8 Reserved[7]; 162262306a36Sopenharmony_ci __u64 RootDirectory; /* MBZ for network operations (why says spec?) */ 162362306a36Sopenharmony_ci __le32 FileNameLength; 162462306a36Sopenharmony_ci char FileName[]; /* New name to be assigned */ 162562306a36Sopenharmony_ci /* padding - overall struct size must be >= 24 so filename + pad >= 6 */ 162662306a36Sopenharmony_ci} __packed; /* level 10 Set */ 162762306a36Sopenharmony_ci 162862306a36Sopenharmony_cistruct smb2_file_link_info { /* encoding of request for level 11 */ 162962306a36Sopenharmony_ci __u8 ReplaceIfExists; /* 1 = replace existing link with new */ 163062306a36Sopenharmony_ci /* 0 = fail if link already exists */ 163162306a36Sopenharmony_ci __u8 Reserved[7]; 163262306a36Sopenharmony_ci __u64 RootDirectory; /* MBZ for network operations (why says spec?) */ 163362306a36Sopenharmony_ci __le32 FileNameLength; 163462306a36Sopenharmony_ci char FileName[]; /* Name to be assigned to new link */ 163562306a36Sopenharmony_ci} __packed; /* level 11 Set */ 163662306a36Sopenharmony_ci 163762306a36Sopenharmony_ci/* 163862306a36Sopenharmony_ci * This level 18, although with struct with same name is different from cifs 163962306a36Sopenharmony_ci * level 0x107. Level 0x107 has an extra u64 between AccessFlags and 164062306a36Sopenharmony_ci * CurrentByteOffset. 164162306a36Sopenharmony_ci */ 164262306a36Sopenharmony_cistruct smb2_file_all_info { /* data block encoding of response to level 18 */ 164362306a36Sopenharmony_ci __le64 CreationTime; /* Beginning of FILE_BASIC_INFO equivalent */ 164462306a36Sopenharmony_ci __le64 LastAccessTime; 164562306a36Sopenharmony_ci __le64 LastWriteTime; 164662306a36Sopenharmony_ci __le64 ChangeTime; 164762306a36Sopenharmony_ci __le32 Attributes; 164862306a36Sopenharmony_ci __u32 Pad1; /* End of FILE_BASIC_INFO_INFO equivalent */ 164962306a36Sopenharmony_ci __le64 AllocationSize; /* Beginning of FILE_STANDARD_INFO equivalent */ 165062306a36Sopenharmony_ci __le64 EndOfFile; /* size ie offset to first free byte in file */ 165162306a36Sopenharmony_ci __le32 NumberOfLinks; /* hard links */ 165262306a36Sopenharmony_ci __u8 DeletePending; 165362306a36Sopenharmony_ci __u8 Directory; 165462306a36Sopenharmony_ci __u16 Pad2; /* End of FILE_STANDARD_INFO equivalent */ 165562306a36Sopenharmony_ci __le64 IndexNumber; 165662306a36Sopenharmony_ci __le32 EASize; 165762306a36Sopenharmony_ci __le32 AccessFlags; 165862306a36Sopenharmony_ci __le64 CurrentByteOffset; 165962306a36Sopenharmony_ci __le32 Mode; 166062306a36Sopenharmony_ci __le32 AlignmentRequirement; 166162306a36Sopenharmony_ci __le32 FileNameLength; 166262306a36Sopenharmony_ci union { 166362306a36Sopenharmony_ci char __pad; /* Legacy structure padding */ 166462306a36Sopenharmony_ci DECLARE_FLEX_ARRAY(char, FileName); 166562306a36Sopenharmony_ci }; 166662306a36Sopenharmony_ci} __packed; /* level 18 Query */ 166762306a36Sopenharmony_ci 166862306a36Sopenharmony_cistruct smb2_file_eof_info { /* encoding of request for level 10 */ 166962306a36Sopenharmony_ci __le64 EndOfFile; /* new end of file value */ 167062306a36Sopenharmony_ci} __packed; /* level 20 Set */ 167162306a36Sopenharmony_ci 167262306a36Sopenharmony_ci/* Level 100 query info */ 167362306a36Sopenharmony_cistruct smb311_posix_qinfo { 167462306a36Sopenharmony_ci __le64 CreationTime; 167562306a36Sopenharmony_ci __le64 LastAccessTime; 167662306a36Sopenharmony_ci __le64 LastWriteTime; 167762306a36Sopenharmony_ci __le64 ChangeTime; 167862306a36Sopenharmony_ci __le64 EndOfFile; 167962306a36Sopenharmony_ci __le64 AllocationSize; 168062306a36Sopenharmony_ci __le32 DosAttributes; 168162306a36Sopenharmony_ci __le64 Inode; 168262306a36Sopenharmony_ci __le32 DeviceId; 168362306a36Sopenharmony_ci __le32 Zero; 168462306a36Sopenharmony_ci /* beginning of POSIX Create Context Response */ 168562306a36Sopenharmony_ci __le32 HardLinks; 168662306a36Sopenharmony_ci __le32 ReparseTag; 168762306a36Sopenharmony_ci __le32 Mode; 168862306a36Sopenharmony_ci u8 Sids[]; 168962306a36Sopenharmony_ci /* 169062306a36Sopenharmony_ci * var sized owner SID 169162306a36Sopenharmony_ci * var sized group SID 169262306a36Sopenharmony_ci * le32 filenamelength 169362306a36Sopenharmony_ci * u8 filename[] 169462306a36Sopenharmony_ci */ 169562306a36Sopenharmony_ci} __packed; 169662306a36Sopenharmony_ci 169762306a36Sopenharmony_ci/* File System Information Classes */ 169862306a36Sopenharmony_ci#define FS_VOLUME_INFORMATION 1 /* Query */ 169962306a36Sopenharmony_ci#define FS_LABEL_INFORMATION 2 /* Set */ 170062306a36Sopenharmony_ci#define FS_SIZE_INFORMATION 3 /* Query */ 170162306a36Sopenharmony_ci#define FS_DEVICE_INFORMATION 4 /* Query */ 170262306a36Sopenharmony_ci#define FS_ATTRIBUTE_INFORMATION 5 /* Query */ 170362306a36Sopenharmony_ci#define FS_CONTROL_INFORMATION 6 /* Query, Set */ 170462306a36Sopenharmony_ci#define FS_FULL_SIZE_INFORMATION 7 /* Query */ 170562306a36Sopenharmony_ci#define FS_OBJECT_ID_INFORMATION 8 /* Query, Set */ 170662306a36Sopenharmony_ci#define FS_DRIVER_PATH_INFORMATION 9 /* Query */ 170762306a36Sopenharmony_ci#define FS_SECTOR_SIZE_INFORMATION 11 /* SMB3 or later. Query */ 170862306a36Sopenharmony_ci#define FS_POSIX_INFORMATION 100 /* SMB3.1.1 POSIX. Query */ 170962306a36Sopenharmony_ci 171062306a36Sopenharmony_cistruct smb2_fs_full_size_info { 171162306a36Sopenharmony_ci __le64 TotalAllocationUnits; 171262306a36Sopenharmony_ci __le64 CallerAvailableAllocationUnits; 171362306a36Sopenharmony_ci __le64 ActualAvailableAllocationUnits; 171462306a36Sopenharmony_ci __le32 SectorsPerAllocationUnit; 171562306a36Sopenharmony_ci __le32 BytesPerSector; 171662306a36Sopenharmony_ci} __packed; 171762306a36Sopenharmony_ci 171862306a36Sopenharmony_ci#define SSINFO_FLAGS_ALIGNED_DEVICE 0x00000001 171962306a36Sopenharmony_ci#define SSINFO_FLAGS_PARTITION_ALIGNED_ON_DEVICE 0x00000002 172062306a36Sopenharmony_ci#define SSINFO_FLAGS_NO_SEEK_PENALTY 0x00000004 172162306a36Sopenharmony_ci#define SSINFO_FLAGS_TRIM_ENABLED 0x00000008 172262306a36Sopenharmony_ci 172362306a36Sopenharmony_ci/* sector size info struct */ 172462306a36Sopenharmony_cistruct smb3_fs_ss_info { 172562306a36Sopenharmony_ci __le32 LogicalBytesPerSector; 172662306a36Sopenharmony_ci __le32 PhysicalBytesPerSectorForAtomicity; 172762306a36Sopenharmony_ci __le32 PhysicalBytesPerSectorForPerf; 172862306a36Sopenharmony_ci __le32 FSEffPhysicalBytesPerSectorForAtomicity; 172962306a36Sopenharmony_ci __le32 Flags; 173062306a36Sopenharmony_ci __le32 ByteOffsetForSectorAlignment; 173162306a36Sopenharmony_ci __le32 ByteOffsetForPartitionAlignment; 173262306a36Sopenharmony_ci} __packed; 173362306a36Sopenharmony_ci 173462306a36Sopenharmony_ci/* File System Control Information */ 173562306a36Sopenharmony_cistruct smb2_fs_control_info { 173662306a36Sopenharmony_ci __le64 FreeSpaceStartFiltering; 173762306a36Sopenharmony_ci __le64 FreeSpaceThreshold; 173862306a36Sopenharmony_ci __le64 FreeSpaceStopFiltering; 173962306a36Sopenharmony_ci __le64 DefaultQuotaThreshold; 174062306a36Sopenharmony_ci __le64 DefaultQuotaLimit; 174162306a36Sopenharmony_ci __le32 FileSystemControlFlags; 174262306a36Sopenharmony_ci __le32 Padding; 174362306a36Sopenharmony_ci} __packed; 174462306a36Sopenharmony_ci 174562306a36Sopenharmony_ci/* volume info struct - see MS-FSCC 2.5.9 */ 174662306a36Sopenharmony_ci#define MAX_VOL_LABEL_LEN 32 174762306a36Sopenharmony_cistruct smb3_fs_vol_info { 174862306a36Sopenharmony_ci __le64 VolumeCreationTime; 174962306a36Sopenharmony_ci __u32 VolumeSerialNumber; 175062306a36Sopenharmony_ci __le32 VolumeLabelLength; /* includes trailing null */ 175162306a36Sopenharmony_ci __u8 SupportsObjects; /* True if eg like NTFS, supports objects */ 175262306a36Sopenharmony_ci __u8 Reserved; 175362306a36Sopenharmony_ci __u8 VolumeLabel[]; /* variable len */ 175462306a36Sopenharmony_ci} __packed; 175562306a36Sopenharmony_ci 175662306a36Sopenharmony_ci/* See MS-SMB2 2.2.23 through 2.2.25 */ 175762306a36Sopenharmony_cistruct smb2_oplock_break { 175862306a36Sopenharmony_ci struct smb2_hdr hdr; 175962306a36Sopenharmony_ci __le16 StructureSize; /* Must be 24 */ 176062306a36Sopenharmony_ci __u8 OplockLevel; 176162306a36Sopenharmony_ci __u8 Reserved; 176262306a36Sopenharmony_ci __le32 Reserved2; 176362306a36Sopenharmony_ci __u64 PersistentFid; 176462306a36Sopenharmony_ci __u64 VolatileFid; 176562306a36Sopenharmony_ci} __packed; 176662306a36Sopenharmony_ci 176762306a36Sopenharmony_ci#define SMB2_NOTIFY_BREAK_LEASE_FLAG_ACK_REQUIRED cpu_to_le32(0x01) 176862306a36Sopenharmony_ci 176962306a36Sopenharmony_cistruct smb2_lease_break { 177062306a36Sopenharmony_ci struct smb2_hdr hdr; 177162306a36Sopenharmony_ci __le16 StructureSize; /* Must be 44 */ 177262306a36Sopenharmony_ci __le16 Epoch; 177362306a36Sopenharmony_ci __le32 Flags; 177462306a36Sopenharmony_ci __u8 LeaseKey[16]; 177562306a36Sopenharmony_ci __le32 CurrentLeaseState; 177662306a36Sopenharmony_ci __le32 NewLeaseState; 177762306a36Sopenharmony_ci __le32 BreakReason; 177862306a36Sopenharmony_ci __le32 AccessMaskHint; 177962306a36Sopenharmony_ci __le32 ShareMaskHint; 178062306a36Sopenharmony_ci} __packed; 178162306a36Sopenharmony_ci 178262306a36Sopenharmony_cistruct smb2_lease_ack { 178362306a36Sopenharmony_ci struct smb2_hdr hdr; 178462306a36Sopenharmony_ci __le16 StructureSize; /* Must be 36 */ 178562306a36Sopenharmony_ci __le16 Reserved; 178662306a36Sopenharmony_ci __le32 Flags; 178762306a36Sopenharmony_ci __u8 LeaseKey[16]; 178862306a36Sopenharmony_ci __le32 LeaseState; 178962306a36Sopenharmony_ci __le64 LeaseDuration; 179062306a36Sopenharmony_ci} __packed; 179162306a36Sopenharmony_ci 179262306a36Sopenharmony_ci#define OP_BREAK_STRUCT_SIZE_20 24 179362306a36Sopenharmony_ci#define OP_BREAK_STRUCT_SIZE_21 36 179462306a36Sopenharmony_ci#endif /* _COMMON_SMB2PDU_H */ 1795