^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) * fs/cifs/smb2pdu.h
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * Copyright (c) International Business Machines Corp., 2009, 2013
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Etersoft, 2012
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * Author(s): Steve French (sfrench@us.ibm.com)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * Pavel Shilovsky (pshilovsky@samba.org) 2012
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) * This library is free software; you can redistribute it and/or modify
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) * it under the terms of the GNU Lesser General Public License as published
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) * by the Free Software Foundation; either version 2.1 of the License, or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) * (at your option) any later version.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) * This library is distributed in the hope that it will be useful,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) * but WITHOUT ANY WARRANTY; without even the implied warranty of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) * the GNU Lesser General Public License for more details.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) * You should have received a copy of the GNU Lesser General Public License
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) * along with this library; if not, write to the Free Software
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) #ifndef _SMB2PDU_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) #define _SMB2PDU_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) #include <net/sock.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) #include <cifsacl.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) * Note that, due to trying to use names similar to the protocol specifications,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) * there are many mixed case field names in the structures below. Although
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) * this does not match typical Linux kernel style, it is necessary to be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) * able to match against the protocol specfication.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) * SMB2 commands
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) * Some commands have minimal (wct=0,bcc=0), or uninteresting, responses
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) * (ie no useful data other than the SMB error code itself) and are marked such.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) * Knowing this helps avoid response buffer allocations and copy in some cases.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) /* List of commands in host endian */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) #define SMB2_NEGOTIATE_HE 0x0000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) #define SMB2_SESSION_SETUP_HE 0x0001
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) #define SMB2_LOGOFF_HE 0x0002 /* trivial request/resp */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) #define SMB2_TREE_CONNECT_HE 0x0003
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) #define SMB2_TREE_DISCONNECT_HE 0x0004 /* trivial req/resp */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) #define SMB2_CREATE_HE 0x0005
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) #define SMB2_CLOSE_HE 0x0006
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) #define SMB2_FLUSH_HE 0x0007 /* trivial resp */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) #define SMB2_READ_HE 0x0008
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) #define SMB2_WRITE_HE 0x0009
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) #define SMB2_LOCK_HE 0x000A
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) #define SMB2_IOCTL_HE 0x000B
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) #define SMB2_CANCEL_HE 0x000C
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) #define SMB2_ECHO_HE 0x000D
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) #define SMB2_QUERY_DIRECTORY_HE 0x000E
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) #define SMB2_CHANGE_NOTIFY_HE 0x000F
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) #define SMB2_QUERY_INFO_HE 0x0010
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) #define SMB2_SET_INFO_HE 0x0011
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) #define SMB2_OPLOCK_BREAK_HE 0x0012
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) /* The same list in little endian */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) #define SMB2_NEGOTIATE cpu_to_le16(SMB2_NEGOTIATE_HE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) #define SMB2_SESSION_SETUP cpu_to_le16(SMB2_SESSION_SETUP_HE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) #define SMB2_LOGOFF cpu_to_le16(SMB2_LOGOFF_HE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) #define SMB2_TREE_CONNECT cpu_to_le16(SMB2_TREE_CONNECT_HE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) #define SMB2_TREE_DISCONNECT cpu_to_le16(SMB2_TREE_DISCONNECT_HE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) #define SMB2_CREATE cpu_to_le16(SMB2_CREATE_HE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) #define SMB2_CLOSE cpu_to_le16(SMB2_CLOSE_HE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) #define SMB2_FLUSH cpu_to_le16(SMB2_FLUSH_HE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) #define SMB2_READ cpu_to_le16(SMB2_READ_HE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) #define SMB2_WRITE cpu_to_le16(SMB2_WRITE_HE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) #define SMB2_LOCK cpu_to_le16(SMB2_LOCK_HE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) #define SMB2_IOCTL cpu_to_le16(SMB2_IOCTL_HE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) #define SMB2_CANCEL cpu_to_le16(SMB2_CANCEL_HE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) #define SMB2_ECHO cpu_to_le16(SMB2_ECHO_HE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) #define SMB2_QUERY_DIRECTORY cpu_to_le16(SMB2_QUERY_DIRECTORY_HE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) #define SMB2_CHANGE_NOTIFY cpu_to_le16(SMB2_CHANGE_NOTIFY_HE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) #define SMB2_QUERY_INFO cpu_to_le16(SMB2_QUERY_INFO_HE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) #define SMB2_SET_INFO cpu_to_le16(SMB2_SET_INFO_HE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) #define SMB2_OPLOCK_BREAK cpu_to_le16(SMB2_OPLOCK_BREAK_HE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) #define SMB2_INTERNAL_CMD cpu_to_le16(0xFFFF)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) #define NUMBER_OF_SMB2_COMMANDS 0x0013
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) /* 52 transform hdr + 64 hdr + 88 create rsp */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) #define SMB2_TRANSFORM_HEADER_SIZE 52
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) #define MAX_SMB2_HDR_SIZE 204
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) #define SMB2_PROTO_NUMBER cpu_to_le32(0x424d53fe)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) #define SMB2_TRANSFORM_PROTO_NUM cpu_to_le32(0x424d53fd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) #define SMB2_COMPRESSION_TRANSFORM_ID cpu_to_le32(0x424d53fc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) * SMB2 Header Definition
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) * "MBZ" : Must be Zero
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) * "BB" : BugBug, Something to check/review/analyze later
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) * "PDU" : "Protocol Data Unit" (ie a network "frame")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) #define SMB2_HEADER_STRUCTURE_SIZE cpu_to_le16(64)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) struct smb2_sync_hdr {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) __le32 ProtocolId; /* 0xFE 'S' 'M' 'B' */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) __le16 StructureSize; /* 64 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) __le16 CreditCharge; /* MBZ */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) __le32 Status; /* Error from server */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) __le16 Command;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) __le16 CreditRequest; /* CreditResponse */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) __le32 Flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) __le32 NextCommand;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) __le64 MessageId;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) __le32 ProcessId;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) __u32 TreeId; /* opaque - so do not make little endian */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) __u64 SessionId; /* opaque - so do not make little endian */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) __u8 Signature[16];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) /* The total header size for SMB2 read and write */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) #define SMB2_READWRITE_PDU_HEADER_SIZE (48 + sizeof(struct smb2_sync_hdr))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) struct smb2_sync_pdu {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) struct smb2_sync_hdr sync_hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) __le16 StructureSize2; /* size of wct area (varies, request specific) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) #define SMB3_AES_CCM_NONCE 11
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) #define SMB3_AES_GCM_NONCE 12
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) /* Transform flags (for 3.0 dialect this flag indicates CCM */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) #define TRANSFORM_FLAG_ENCRYPTED 0x0001
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) struct smb2_transform_hdr {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) __le32 ProtocolId; /* 0xFD 'S' 'M' 'B' */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) __u8 Signature[16];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) __u8 Nonce[16];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) __le32 OriginalMessageSize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) __u16 Reserved1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) __le16 Flags; /* EncryptionAlgorithm for 3.0, enc enabled for 3.1.1 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) __u64 SessionId;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) /* See MS-SMB2 2.2.42 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) struct smb2_compression_transform_hdr {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) __le32 ProtocolId; /* 0xFC 'S' 'M' 'B' */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) __le32 OriginalCompressedSegmentSize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) __le16 CompressionAlgorithm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) __le16 Flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) __le16 Length; /* if chained it is length, else offset */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) /* See MS-SMB2 2.2.42.1 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) #define SMB2_COMPRESSION_FLAG_NONE 0x0000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) #define SMB2_COMPRESSION_FLAG_CHAINED 0x0001
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) struct compression_payload_header {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) __le16 CompressionAlgorithm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) __le16 Flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) __le32 Length; /* length of compressed playload including field below if present */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) /* __le32 OriginalPayloadSize; */ /* optional */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) /* See MS-SMB2 2.2.42.2 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) struct compression_pattern_payload_v1 {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) __le16 Pattern;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) __le16 Reserved1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) __le16 Reserved2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) __le32 Repetitions;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) /* See MS-SMB2 2.2.43 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) struct smb2_rdma_transform {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) __le16 RdmaDescriptorOffset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) __le16 RdmaDescriptorLength;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) __le32 Channel; /* for values see channel description in smb2 read above */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) __le16 TransformCount;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) __le16 Reserved1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) __le32 Reserved2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) struct smb2_rdma_encryption_transform {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) __le16 TransformType;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) __le16 SignatureLength;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) __le16 NonceLength;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) __u16 Reserved;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) __u8 Signature[]; /* variable length */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) /* u8 Nonce[] */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) /* followed by padding */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) * SMB2 flag definitions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) #define SMB2_FLAGS_SERVER_TO_REDIR cpu_to_le32(0x00000001)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) #define SMB2_FLAGS_ASYNC_COMMAND cpu_to_le32(0x00000002)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) #define SMB2_FLAGS_RELATED_OPERATIONS cpu_to_le32(0x00000004)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) #define SMB2_FLAGS_SIGNED cpu_to_le32(0x00000008)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) #define SMB2_FLAGS_PRIORITY_MASK cpu_to_le32(0x00000070) /* SMB3.1.1 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) #define SMB2_FLAGS_DFS_OPERATIONS cpu_to_le32(0x10000000)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) #define SMB2_FLAGS_REPLAY_OPERATION cpu_to_le32(0x20000000) /* SMB3 & up */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) * Definitions for SMB2 Protocol Data Units (network frames)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) * See MS-SMB2.PDF specification for protocol details.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) * The Naming convention is the lower case version of the SMB2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) * command code name for the struct. Note that structures must be packed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) #define COMPOUND_FID 0xFFFFFFFFFFFFFFFFULL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) #define SMB2_ERROR_STRUCTURE_SIZE2 cpu_to_le16(9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) struct smb2_err_rsp {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) struct smb2_sync_hdr sync_hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) __le16 StructureSize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) __le16 Reserved; /* MBZ */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) __le32 ByteCount; /* even if zero, at least one byte follows */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) __u8 ErrorData[1]; /* variable length */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) #define SYMLINK_ERROR_TAG 0x4c4d5953
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) struct smb2_symlink_err_rsp {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) __le32 SymLinkLength;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) __le32 SymLinkErrorTag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) __le32 ReparseTag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) __le16 ReparseDataLength;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) __le16 UnparsedPathLength;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) __le16 SubstituteNameOffset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) __le16 SubstituteNameLength;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) __le16 PrintNameOffset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) __le16 PrintNameLength;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) __le32 Flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) __u8 PathBuffer[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) /* SMB 3.1.1 and later dialects. See MS-SMB2 section 2.2.2.1 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) struct smb2_error_context_rsp {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) __le32 ErrorDataLength;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) __le32 ErrorId;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) __u8 ErrorContextData; /* ErrorDataLength long array */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) /* ErrorId values */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) #define SMB2_ERROR_ID_DEFAULT 0x00000000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) #define SMB2_ERROR_ID_SHARE_REDIRECT cpu_to_le32(0x72645253) /* "rdRS" */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) /* Defines for Type field below (see MS-SMB2 2.2.2.2.2.1) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) #define MOVE_DST_IPADDR_V4 cpu_to_le32(0x00000001)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) #define MOVE_DST_IPADDR_V6 cpu_to_le32(0x00000002)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) struct move_dst_ipaddr {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) __le32 Type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) __u32 Reserved;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) __u8 address[16]; /* IPv4 followed by 12 bytes rsvd or IPv6 address */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) struct share_redirect_error_context_rsp {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) __le32 StructureSize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) __le32 NotificationType;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) __le32 ResourceNameOffset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) __le32 ResourceNameLength;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) __le16 Flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) __le16 TargetType;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) __le32 IPAddrCount;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) struct move_dst_ipaddr IpAddrMoveList[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) /* __u8 ResourceName[] */ /* Name of share as counted Unicode string */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) #define SMB2_CLIENT_GUID_SIZE 16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) struct smb2_negotiate_req {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) struct smb2_sync_hdr sync_hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) __le16 StructureSize; /* Must be 36 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) __le16 DialectCount;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) __le16 SecurityMode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) __le16 Reserved; /* MBZ */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) __le32 Capabilities;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) __u8 ClientGUID[SMB2_CLIENT_GUID_SIZE];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) /* In SMB3.02 and earlier next three were MBZ le64 ClientStartTime */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) __le32 NegotiateContextOffset; /* SMB3.1.1 only. MBZ earlier */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) __le16 NegotiateContextCount; /* SMB3.1.1 only. MBZ earlier */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) __le16 Reserved2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) __le16 Dialects[4]; /* BB expand this if autonegotiate > 4 dialects */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) /* Dialects */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) #define SMB10_PROT_ID 0x0000 /* local only, not sent on wire w/CIFS negprot */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) #define SMB20_PROT_ID 0x0202
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) #define SMB21_PROT_ID 0x0210
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) #define SMB30_PROT_ID 0x0300
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) #define SMB302_PROT_ID 0x0302
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) #define SMB311_PROT_ID 0x0311
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) #define BAD_PROT_ID 0xFFFF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) /* SecurityMode flags */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) #define SMB2_NEGOTIATE_SIGNING_ENABLED 0x0001
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) #define SMB2_NEGOTIATE_SIGNING_REQUIRED 0x0002
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) #define SMB2_SEC_MODE_FLAGS_ALL 0x0003
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) /* Capabilities flags */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) #define SMB2_GLOBAL_CAP_DFS 0x00000001
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) #define SMB2_GLOBAL_CAP_LEASING 0x00000002 /* Resp only New to SMB2.1 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) #define SMB2_GLOBAL_CAP_LARGE_MTU 0X00000004 /* Resp only New to SMB2.1 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) #define SMB2_GLOBAL_CAP_MULTI_CHANNEL 0x00000008 /* New to SMB3 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) #define SMB2_GLOBAL_CAP_PERSISTENT_HANDLES 0x00000010 /* New to SMB3 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) #define SMB2_GLOBAL_CAP_DIRECTORY_LEASING 0x00000020 /* New to SMB3 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) #define SMB2_GLOBAL_CAP_ENCRYPTION 0x00000040 /* New to SMB3 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) /* Internal types */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) #define SMB2_NT_FIND 0x00100000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) #define SMB2_LARGE_FILES 0x00200000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) /* Negotiate Contexts - ContextTypes. See MS-SMB2 section 2.2.3.1 for details */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) #define SMB2_PREAUTH_INTEGRITY_CAPABILITIES cpu_to_le16(1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) #define SMB2_ENCRYPTION_CAPABILITIES cpu_to_le16(2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) #define SMB2_COMPRESSION_CAPABILITIES cpu_to_le16(3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) #define SMB2_NETNAME_NEGOTIATE_CONTEXT_ID cpu_to_le16(5)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) #define SMB2_TRANSPORT_CAPABILITIES cpu_to_le16(6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) #define SMB2_RDMA_TRANSFORM_CAPABILITIES cpu_to_le16(7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) #define SMB2_SIGNING_CAPABILITIES cpu_to_le16(8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) #define SMB2_POSIX_EXTENSIONS_AVAILABLE cpu_to_le16(0x100)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) struct smb2_neg_context {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) __le16 ContextType;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) __le16 DataLength;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) __le32 Reserved;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) /* Followed by array of data */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) #define SMB311_LINUX_CLIENT_SALT_SIZE 32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) /* Hash Algorithm Types */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) #define SMB2_PREAUTH_INTEGRITY_SHA512 cpu_to_le16(0x0001)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) #define SMB2_PREAUTH_HASH_SIZE 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) * SaltLength that the server send can be zero, so the only three required
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) * fields (all __le16) end up six bytes total, so the minimum context data len
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) * in the response is six bytes which accounts for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) * HashAlgorithmCount, SaltLength, and 1 HashAlgorithm.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) #define MIN_PREAUTH_CTXT_DATA_LEN 6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) struct smb2_preauth_neg_context {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) __le16 ContextType; /* 1 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) __le16 DataLength;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) __le32 Reserved;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) __le16 HashAlgorithmCount; /* 1 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) __le16 SaltLength;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) __le16 HashAlgorithms; /* HashAlgorithms[0] since only one defined */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) __u8 Salt[SMB311_LINUX_CLIENT_SALT_SIZE];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) /* Encryption Algorithms Ciphers */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) #define SMB2_ENCRYPTION_AES128_CCM cpu_to_le16(0x0001)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) #define SMB2_ENCRYPTION_AES128_GCM cpu_to_le16(0x0002)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) /* we currently do not request AES256_CCM since presumably GCM faster */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) #define SMB2_ENCRYPTION_AES256_CCM cpu_to_le16(0x0003)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) #define SMB2_ENCRYPTION_AES256_GCM cpu_to_le16(0x0004)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) /* Min encrypt context data is one cipher so 2 bytes + 2 byte count field */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) #define MIN_ENCRYPT_CTXT_DATA_LEN 4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) struct smb2_encryption_neg_context {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) __le16 ContextType; /* 2 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) __le16 DataLength;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) __le32 Reserved;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) /* CipherCount usally 2, but can be 3 when AES256-GCM enabled */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) __le16 CipherCount; /* AES128-GCM and AES128-CCM by default */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) __le16 Ciphers[3];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) /* See MS-SMB2 2.2.3.1.3 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) #define SMB3_COMPRESS_NONE cpu_to_le16(0x0000)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) #define SMB3_COMPRESS_LZNT1 cpu_to_le16(0x0001)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) #define SMB3_COMPRESS_LZ77 cpu_to_le16(0x0002)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) #define SMB3_COMPRESS_LZ77_HUFF cpu_to_le16(0x0003)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) /* Pattern scanning algorithm See MS-SMB2 3.1.4.4.1 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) #define SMB3_COMPRESS_PATTERN cpu_to_le16(0x0004) /* Pattern_V1 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) /* Compression Flags */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) #define SMB2_COMPRESSION_CAPABILITIES_FLAG_NONE cpu_to_le32(0x00000000)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) #define SMB2_COMPRESSION_CAPABILITIES_FLAG_CHAINED cpu_to_le32(0x00000001)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) struct smb2_compression_capabilities_context {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) __le16 ContextType; /* 3 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) __le16 DataLength;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) __u32 Reserved;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) __le16 CompressionAlgorithmCount;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) __u16 Padding;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) __u32 Flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) __le16 CompressionAlgorithms[3];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) * For smb2_netname_negotiate_context_id See MS-SMB2 2.2.3.1.4.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) * Its struct simply contains NetName, an array of Unicode characters
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) struct smb2_netname_neg_context {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) __le16 ContextType; /* 5 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) __le16 DataLength;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) __le32 Reserved;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) __le16 NetName[]; /* hostname of target converted to UCS-2 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) * For rdma transform capabilities context see MS-SMB2 2.2.3.1.6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) * and 2.2.4.1.5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) /* RDMA Transform IDs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) #define SMB2_RDMA_TRANSFORM_NONE 0x0000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) #define SMB2_RDMA_TRANSFORM_ENCRYPTION 0x0001
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) struct smb2_rdma_transform_capabilities_context {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) __le16 ContextType; /* 7 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) __le16 DataLength;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) __u32 Reserved;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) __le16 TransformCount;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) __u16 Reserved1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) __u32 Reserved2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) __le16 RDMATransformIds[1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) /* Signing algorithms */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) #define SIGNING_ALG_HMAC_SHA256 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) #define SIGNING_ALG_AES_CMAC 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) #define SIGNING_ALG_AES_GMAC 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) struct smb2_signing_capabilities {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) __le16 ContextType; /* 8 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) __le16 DataLength;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) __u32 Reserved;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) __le16 SigningAlgorithmCount;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) __le16 SigningAlgorithms[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) #define POSIX_CTXT_DATA_LEN 16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) struct smb2_posix_neg_context {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) __le16 ContextType; /* 0x100 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) __le16 DataLength;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) __le32 Reserved;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) __u8 Name[16]; /* POSIX ctxt GUID 93AD25509CB411E7B42383DE968BCD7C */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) struct smb2_negotiate_rsp {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) struct smb2_sync_hdr sync_hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) __le16 StructureSize; /* Must be 65 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) __le16 SecurityMode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) __le16 DialectRevision;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) __le16 NegotiateContextCount; /* Prior to SMB3.1.1 was Reserved & MBZ */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) __u8 ServerGUID[16];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) __le32 Capabilities;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) __le32 MaxTransactSize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) __le32 MaxReadSize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) __le32 MaxWriteSize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) __le64 SystemTime; /* MBZ */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) __le64 ServerStartTime;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) __le16 SecurityBufferOffset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) __le16 SecurityBufferLength;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) __le32 NegotiateContextOffset; /* Pre:SMB3.1.1 was reserved/ignored */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) __u8 Buffer[1]; /* variable length GSS security buffer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) /* Flags */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) #define SMB2_SESSION_REQ_FLAG_BINDING 0x01
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) #define SMB2_SESSION_REQ_FLAG_ENCRYPT_DATA 0x04
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) struct smb2_sess_setup_req {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) struct smb2_sync_hdr sync_hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) __le16 StructureSize; /* Must be 25 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) __u8 Flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) __u8 SecurityMode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) __le32 Capabilities;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) __le32 Channel;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) __le16 SecurityBufferOffset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) __le16 SecurityBufferLength;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) __u64 PreviousSessionId;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) __u8 Buffer[1]; /* variable length GSS security buffer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) /* Currently defined SessionFlags */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) #define SMB2_SESSION_FLAG_IS_GUEST 0x0001
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) #define SMB2_SESSION_FLAG_IS_NULL 0x0002
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) #define SMB2_SESSION_FLAG_ENCRYPT_DATA 0x0004
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) struct smb2_sess_setup_rsp {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) struct smb2_sync_hdr sync_hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) __le16 StructureSize; /* Must be 9 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) __le16 SessionFlags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) __le16 SecurityBufferOffset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) __le16 SecurityBufferLength;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) __u8 Buffer[1]; /* variable length GSS security buffer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) struct smb2_logoff_req {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) struct smb2_sync_hdr sync_hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) __le16 StructureSize; /* Must be 4 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) __le16 Reserved;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) struct smb2_logoff_rsp {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) struct smb2_sync_hdr sync_hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) __le16 StructureSize; /* Must be 4 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) __le16 Reserved;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) /* Flags/Reserved for SMB3.1.1 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) #define SMB2_TREE_CONNECT_FLAG_CLUSTER_RECONNECT cpu_to_le16(0x0001)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) #define SMB2_TREE_CONNECT_FLAG_REDIRECT_TO_OWNER cpu_to_le16(0x0002)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) #define SMB2_TREE_CONNECT_FLAG_EXTENSION_PRESENT cpu_to_le16(0x0004)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) struct smb2_tree_connect_req {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) struct smb2_sync_hdr sync_hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) __le16 StructureSize; /* Must be 9 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) __le16 Flags; /* Reserved MBZ for dialects prior to SMB3.1.1 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) __le16 PathOffset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) __le16 PathLength;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) __u8 Buffer[1]; /* variable length */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) /* See MS-SMB2 section 2.2.9.2 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) /* Context Types */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) #define SMB2_RESERVED_TREE_CONNECT_CONTEXT_ID 0x0000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) #define SMB2_REMOTED_IDENTITY_TREE_CONNECT_CONTEXT_ID cpu_to_le16(0x0001)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) struct tree_connect_contexts {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) __le16 ContextType;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) __le16 DataLength;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) __le32 Reserved;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) __u8 Data[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) /* Remoted identity tree connect context structures - see MS-SMB2 2.2.9.2.1 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) struct smb3_blob_data {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) __le16 BlobSize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) __u8 BlobData[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) /* Valid values for Attr */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) #define SE_GROUP_MANDATORY 0x00000001
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) #define SE_GROUP_ENABLED_BY_DEFAULT 0x00000002
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) #define SE_GROUP_ENABLED 0x00000004
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) #define SE_GROUP_OWNER 0x00000008
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) #define SE_GROUP_USE_FOR_DENY_ONLY 0x00000010
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550) #define SE_GROUP_INTEGRITY 0x00000020
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) #define SE_GROUP_INTEGRITY_ENABLED 0x00000040
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) #define SE_GROUP_RESOURCE 0x20000000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) #define SE_GROUP_LOGON_ID 0xC0000000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) /* struct sid_attr_data is SidData array in BlobData format then le32 Attr */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) struct sid_array_data {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) __le16 SidAttrCount;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) /* SidAttrList - array of sid_attr_data structs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) struct luid_attr_data {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567) * struct privilege_data is the same as BLOB_DATA - see MS-SMB2 2.2.9.2.1.5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) * but with size of LUID_ATTR_DATA struct and BlobData set to LUID_ATTR DATA
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571) struct privilege_array_data {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572) __le16 PrivilegeCount;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573) /* array of privilege_data structs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576) struct remoted_identity_tcon_context {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577) __le16 TicketType; /* must be 0x0001 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578) __le16 TicketSize; /* total size of this struct */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579) __le16 User; /* offset to SID_ATTR_DATA struct with user info */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580) __le16 UserName; /* offset to null terminated Unicode username string */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) __le16 Domain; /* offset to null terminated Unicode domain name */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582) __le16 Groups; /* offset to SID_ARRAY_DATA struct with group info */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583) __le16 RestrictedGroups; /* similar to above */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584) __le16 Privileges; /* offset to PRIVILEGE_ARRAY_DATA struct */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585) __le16 PrimaryGroup; /* offset to SID_ARRAY_DATA struct */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586) __le16 Owner; /* offset to BLOB_DATA struct */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587) __le16 DefaultDacl; /* offset to BLOB_DATA struct */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588) __le16 DeviceGroups; /* offset to SID_ARRAY_DATA struct */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589) __le16 UserClaims; /* offset to BLOB_DATA struct */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590) __le16 DeviceClaims; /* offset to BLOB_DATA struct */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591) __u8 TicketInfo[]; /* variable length buf - remoted identity data */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594) struct smb2_tree_connect_req_extension {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595) __le32 TreeConnectContextOffset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596) __le16 TreeConnectContextCount;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597) __u8 Reserved[10];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598) __u8 PathName[]; /* variable sized array */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599) /* followed by array of TreeConnectContexts */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602) struct smb2_tree_connect_rsp {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603) struct smb2_sync_hdr sync_hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604) __le16 StructureSize; /* Must be 16 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605) __u8 ShareType; /* see below */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606) __u8 Reserved;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607) __le32 ShareFlags; /* see below */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608) __le32 Capabilities; /* see below */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609) __le32 MaximalAccess;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612) /* Possible ShareType values */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613) #define SMB2_SHARE_TYPE_DISK 0x01
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614) #define SMB2_SHARE_TYPE_PIPE 0x02
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615) #define SMB2_SHARE_TYPE_PRINT 0x03
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618) * Possible ShareFlags - exactly one and only one of the first 4 caching flags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619) * must be set (any of the remaining, SHI1005, flags may be set individually
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620) * or in combination.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622) #define SMB2_SHAREFLAG_MANUAL_CACHING 0x00000000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623) #define SMB2_SHAREFLAG_AUTO_CACHING 0x00000010
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624) #define SMB2_SHAREFLAG_VDO_CACHING 0x00000020
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625) #define SMB2_SHAREFLAG_NO_CACHING 0x00000030
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626) #define SHI1005_FLAGS_DFS 0x00000001
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627) #define SHI1005_FLAGS_DFS_ROOT 0x00000002
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628) #define SHI1005_FLAGS_RESTRICT_EXCLUSIVE_OPENS 0x00000100
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629) #define SHI1005_FLAGS_FORCE_SHARED_DELETE 0x00000200
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630) #define SHI1005_FLAGS_ALLOW_NAMESPACE_CACHING 0x00000400
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631) #define SHI1005_FLAGS_ACCESS_BASED_DIRECTORY_ENUM 0x00000800
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632) #define SHI1005_FLAGS_FORCE_LEVELII_OPLOCK 0x00001000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633) #define SHI1005_FLAGS_ENABLE_HASH_V1 0x00002000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634) #define SHI1005_FLAGS_ENABLE_HASH_V2 0x00004000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635) #define SHI1005_FLAGS_ENCRYPT_DATA 0x00008000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636) #define SMB2_SHAREFLAG_IDENTITY_REMOTING 0x00040000 /* 3.1.1 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637) #define SHI1005_FLAGS_ALL 0x0004FF33
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639) /* Possible share capabilities */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640) #define SMB2_SHARE_CAP_DFS cpu_to_le32(0x00000008) /* all dialects */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641) #define SMB2_SHARE_CAP_CONTINUOUS_AVAILABILITY cpu_to_le32(0x00000010) /* 3.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642) #define SMB2_SHARE_CAP_SCALEOUT cpu_to_le32(0x00000020) /* 3.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 643) #define SMB2_SHARE_CAP_CLUSTER cpu_to_le32(0x00000040) /* 3.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 644) #define SMB2_SHARE_CAP_ASYMMETRIC cpu_to_le32(0x00000080) /* 3.02 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 645) #define SMB2_SHARE_CAP_REDIRECT_TO_OWNER cpu_to_le32(0x00000100) /* 3.1.1 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 646)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 647) struct smb2_tree_disconnect_req {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 648) struct smb2_sync_hdr sync_hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 649) __le16 StructureSize; /* Must be 4 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 650) __le16 Reserved;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 651) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 652)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 653) struct smb2_tree_disconnect_rsp {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 654) struct smb2_sync_hdr sync_hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 655) __le16 StructureSize; /* Must be 4 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 656) __le16 Reserved;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 657) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 658)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 659) /* File Attrubutes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 660) #define FILE_ATTRIBUTE_READONLY 0x00000001
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 661) #define FILE_ATTRIBUTE_HIDDEN 0x00000002
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 662) #define FILE_ATTRIBUTE_SYSTEM 0x00000004
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 663) #define FILE_ATTRIBUTE_DIRECTORY 0x00000010
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 664) #define FILE_ATTRIBUTE_ARCHIVE 0x00000020
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 665) #define FILE_ATTRIBUTE_NORMAL 0x00000080
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 666) #define FILE_ATTRIBUTE_TEMPORARY 0x00000100
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 667) #define FILE_ATTRIBUTE_SPARSE_FILE 0x00000200
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 668) #define FILE_ATTRIBUTE_REPARSE_POINT 0x00000400
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 669) #define FILE_ATTRIBUTE_COMPRESSED 0x00000800
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 670) #define FILE_ATTRIBUTE_OFFLINE 0x00001000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 671) #define FILE_ATTRIBUTE_NOT_CONTENT_INDEXED 0x00002000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 672) #define FILE_ATTRIBUTE_ENCRYPTED 0x00004000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 673) #define FILE_ATTRIBUTE_INTEGRITY_STREAM 0x00008000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 674) #define FILE_ATTRIBUTE_NO_SCRUB_DATA 0x00020000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 675)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 676) /* Oplock levels */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 677) #define SMB2_OPLOCK_LEVEL_NONE 0x00
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 678) #define SMB2_OPLOCK_LEVEL_II 0x01
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 679) #define SMB2_OPLOCK_LEVEL_EXCLUSIVE 0x08
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 680) #define SMB2_OPLOCK_LEVEL_BATCH 0x09
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 681) #define SMB2_OPLOCK_LEVEL_LEASE 0xFF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 682) /* Non-spec internal type */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 683) #define SMB2_OPLOCK_LEVEL_NOCHANGE 0x99
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 684)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 685) /* Desired Access Flags */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 686) #define FILE_READ_DATA_LE cpu_to_le32(0x00000001)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 687) #define FILE_WRITE_DATA_LE cpu_to_le32(0x00000002)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 688) #define FILE_APPEND_DATA_LE cpu_to_le32(0x00000004)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 689) #define FILE_READ_EA_LE cpu_to_le32(0x00000008)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 690) #define FILE_WRITE_EA_LE cpu_to_le32(0x00000010)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 691) #define FILE_EXECUTE_LE cpu_to_le32(0x00000020)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 692) #define FILE_READ_ATTRIBUTES_LE cpu_to_le32(0x00000080)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 693) #define FILE_WRITE_ATTRIBUTES_LE cpu_to_le32(0x00000100)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 694) #define FILE_DELETE_LE cpu_to_le32(0x00010000)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 695) #define FILE_READ_CONTROL_LE cpu_to_le32(0x00020000)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 696) #define FILE_WRITE_DAC_LE cpu_to_le32(0x00040000)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 697) #define FILE_WRITE_OWNER_LE cpu_to_le32(0x00080000)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 698) #define FILE_SYNCHRONIZE_LE cpu_to_le32(0x00100000)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 699) #define FILE_ACCESS_SYSTEM_SECURITY_LE cpu_to_le32(0x01000000)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 700) #define FILE_MAXIMAL_ACCESS_LE cpu_to_le32(0x02000000)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 701) #define FILE_GENERIC_ALL_LE cpu_to_le32(0x10000000)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 702) #define FILE_GENERIC_EXECUTE_LE cpu_to_le32(0x20000000)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 703) #define FILE_GENERIC_WRITE_LE cpu_to_le32(0x40000000)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 704) #define FILE_GENERIC_READ_LE cpu_to_le32(0x80000000)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 705)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 706) /* ShareAccess Flags */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 707) #define FILE_SHARE_READ_LE cpu_to_le32(0x00000001)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 708) #define FILE_SHARE_WRITE_LE cpu_to_le32(0x00000002)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 709) #define FILE_SHARE_DELETE_LE cpu_to_le32(0x00000004)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 710) #define FILE_SHARE_ALL_LE cpu_to_le32(0x00000007)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 711)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 712) /* CreateDisposition Flags */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 713) #define FILE_SUPERSEDE_LE cpu_to_le32(0x00000000)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 714) #define FILE_OPEN_LE cpu_to_le32(0x00000001)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 715) #define FILE_CREATE_LE cpu_to_le32(0x00000002)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 716) #define FILE_OPEN_IF_LE cpu_to_le32(0x00000003)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 717) #define FILE_OVERWRITE_LE cpu_to_le32(0x00000004)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 718) #define FILE_OVERWRITE_IF_LE cpu_to_le32(0x00000005)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 719)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 720) /* CreateOptions Flags */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 721) #define FILE_DIRECTORY_FILE_LE cpu_to_le32(0x00000001)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 722) /* same as #define CREATE_NOT_FILE_LE cpu_to_le32(0x00000001) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 723) #define FILE_WRITE_THROUGH_LE cpu_to_le32(0x00000002)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 724) #define FILE_SEQUENTIAL_ONLY_LE cpu_to_le32(0x00000004)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 725) #define FILE_NO_INTERMEDIATE_BUFFERRING_LE cpu_to_le32(0x00000008)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 726) #define FILE_SYNCHRONOUS_IO_ALERT_LE cpu_to_le32(0x00000010)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 727) #define FILE_SYNCHRONOUS_IO_NON_ALERT_LE cpu_to_le32(0x00000020)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 728) #define FILE_NON_DIRECTORY_FILE_LE cpu_to_le32(0x00000040)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 729) #define FILE_COMPLETE_IF_OPLOCKED_LE cpu_to_le32(0x00000100)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 730) #define FILE_NO_EA_KNOWLEDGE_LE cpu_to_le32(0x00000200)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 731) #define FILE_RANDOM_ACCESS_LE cpu_to_le32(0x00000800)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 732) #define FILE_DELETE_ON_CLOSE_LE cpu_to_le32(0x00001000)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 733) #define FILE_OPEN_BY_FILE_ID_LE cpu_to_le32(0x00002000)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 734) #define FILE_OPEN_FOR_BACKUP_INTENT_LE cpu_to_le32(0x00004000)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 735) #define FILE_NO_COMPRESSION_LE cpu_to_le32(0x00008000)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 736) #define FILE_RESERVE_OPFILTER_LE cpu_to_le32(0x00100000)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 737) #define FILE_OPEN_REPARSE_POINT_LE cpu_to_le32(0x00200000)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 738) #define FILE_OPEN_NO_RECALL_LE cpu_to_le32(0x00400000)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 739) #define FILE_OPEN_FOR_FREE_SPACE_QUERY_LE cpu_to_le32(0x00800000)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 740)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 741) #define FILE_READ_RIGHTS_LE (FILE_READ_DATA_LE | FILE_READ_EA_LE \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 742) | FILE_READ_ATTRIBUTES_LE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 743) #define FILE_WRITE_RIGHTS_LE (FILE_WRITE_DATA_LE | FILE_APPEND_DATA_LE \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 744) | FILE_WRITE_EA_LE | FILE_WRITE_ATTRIBUTES_LE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 745) #define FILE_EXEC_RIGHTS_LE (FILE_EXECUTE_LE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 746)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 747) /* Impersonation Levels. See MS-WPO section 9.7 and MSDN-IMPERS */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 748) #define IL_ANONYMOUS cpu_to_le32(0x00000000)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 749) #define IL_IDENTIFICATION cpu_to_le32(0x00000001)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 750) #define IL_IMPERSONATION cpu_to_le32(0x00000002)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 751) #define IL_DELEGATE cpu_to_le32(0x00000003)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 752)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 753) /* Create Context Values */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 754) #define SMB2_CREATE_EA_BUFFER "ExtA" /* extended attributes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 755) #define SMB2_CREATE_SD_BUFFER "SecD" /* security descriptor */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 756) #define SMB2_CREATE_DURABLE_HANDLE_REQUEST "DHnQ"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 757) #define SMB2_CREATE_DURABLE_HANDLE_RECONNECT "DHnC"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 758) #define SMB2_CREATE_ALLOCATION_SIZE "AISi"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 759) #define SMB2_CREATE_QUERY_MAXIMAL_ACCESS_REQUEST "MxAc"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 760) #define SMB2_CREATE_TIMEWARP_REQUEST "TWrp"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 761) #define SMB2_CREATE_QUERY_ON_DISK_ID "QFid"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 762) #define SMB2_CREATE_REQUEST_LEASE "RqLs"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 763) #define SMB2_CREATE_DURABLE_HANDLE_REQUEST_V2 "DH2Q"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 764) #define SMB2_CREATE_DURABLE_HANDLE_RECONNECT_V2 "DH2C"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 765) #define SMB2_CREATE_APP_INSTANCE_ID 0x45BCA66AEFA7F74A9008FA462E144D74
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 766) #define SMB2_CREATE_APP_INSTANCE_VERSION 0xB982D0B73B56074FA07B524A8116A010
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 767) #define SVHDX_OPEN_DEVICE_CONTEX 0x9CCBCF9E04C1E643980E158DA1F6EC83
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 768) #define SMB2_CREATE_TAG_POSIX 0x93AD25509CB411E7B42383DE968BCD7C
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 769)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 770) /* Flag (SMB3 open response) values */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 771) #define SMB2_CREATE_FLAG_REPARSEPOINT 0x01
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 772)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 773) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 774) * Maximum number of iovs we need for an open/create request.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 775) * [0] : struct smb2_create_req
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 776) * [1] : path
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 777) * [2] : lease context
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 778) * [3] : durable context
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 779) * [4] : posix context
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 780) * [5] : time warp context
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 781) * [6] : query id context
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 782) * [7] : compound padding
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 783) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 784) #define SMB2_CREATE_IOV_SIZE 8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 785)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 786) struct smb2_create_req {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 787) struct smb2_sync_hdr sync_hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 788) __le16 StructureSize; /* Must be 57 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 789) __u8 SecurityFlags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 790) __u8 RequestedOplockLevel;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 791) __le32 ImpersonationLevel;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 792) __le64 SmbCreateFlags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 793) __le64 Reserved;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 794) __le32 DesiredAccess;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 795) __le32 FileAttributes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 796) __le32 ShareAccess;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 797) __le32 CreateDisposition;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 798) __le32 CreateOptions;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 799) __le16 NameOffset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 800) __le16 NameLength;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 801) __le32 CreateContextsOffset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 802) __le32 CreateContextsLength;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 803) __u8 Buffer[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 804) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 805)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 806) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 807) * Maximum size of a SMB2_CREATE response is 64 (smb2 header) +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 808) * 88 (fixed part of create response) + 520 (path) + 208 (contexts) +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 809) * 2 bytes of padding.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 810) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 811) #define MAX_SMB2_CREATE_RESPONSE_SIZE 880
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 812)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 813) struct smb2_create_rsp {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 814) struct smb2_sync_hdr sync_hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 815) __le16 StructureSize; /* Must be 89 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 816) __u8 OplockLevel;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 817) __u8 Flag; /* 0x01 if reparse point */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 818) __le32 CreateAction;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 819) __le64 CreationTime;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 820) __le64 LastAccessTime;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 821) __le64 LastWriteTime;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 822) __le64 ChangeTime;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 823) __le64 AllocationSize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 824) __le64 EndofFile;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 825) __le32 FileAttributes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 826) __le32 Reserved2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 827) __u64 PersistentFileId; /* opaque endianness */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 828) __u64 VolatileFileId; /* opaque endianness */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 829) __le32 CreateContextsOffset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 830) __le32 CreateContextsLength;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 831) __u8 Buffer[1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 832) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 833)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 834) struct create_context {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 835) __le32 Next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 836) __le16 NameOffset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 837) __le16 NameLength;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 838) __le16 Reserved;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 839) __le16 DataOffset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 840) __le32 DataLength;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 841) __u8 Buffer[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 842) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 843)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 844) #define SMB2_LEASE_READ_CACHING_HE 0x01
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 845) #define SMB2_LEASE_HANDLE_CACHING_HE 0x02
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 846) #define SMB2_LEASE_WRITE_CACHING_HE 0x04
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 847)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 848) #define SMB2_LEASE_NONE cpu_to_le32(0x00)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 849) #define SMB2_LEASE_READ_CACHING cpu_to_le32(0x01)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 850) #define SMB2_LEASE_HANDLE_CACHING cpu_to_le32(0x02)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 851) #define SMB2_LEASE_WRITE_CACHING cpu_to_le32(0x04)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 852)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 853) #define SMB2_LEASE_FLAG_BREAK_IN_PROGRESS cpu_to_le32(0x00000002)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 854) #define SMB2_LEASE_FLAG_PARENT_LEASE_KEY_SET cpu_to_le32(0x00000004)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 855)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 856) #define SMB2_LEASE_KEY_SIZE 16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 857)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 858) struct lease_context {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 859) u8 LeaseKey[SMB2_LEASE_KEY_SIZE];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 860) __le32 LeaseState;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 861) __le32 LeaseFlags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 862) __le64 LeaseDuration;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 863) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 864)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 865) struct lease_context_v2 {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 866) u8 LeaseKey[SMB2_LEASE_KEY_SIZE];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 867) __le32 LeaseState;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 868) __le32 LeaseFlags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 869) __le64 LeaseDuration;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 870) __le64 ParentLeaseKeyLow;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 871) __le64 ParentLeaseKeyHigh;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 872) __le16 Epoch;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 873) __le16 Reserved;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 874) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 875)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 876) struct create_lease {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 877) struct create_context ccontext;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 878) __u8 Name[8];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 879) struct lease_context lcontext;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 880) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 881)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 882) struct create_lease_v2 {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 883) struct create_context ccontext;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 884) __u8 Name[8];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 885) struct lease_context_v2 lcontext;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 886) __u8 Pad[4];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 887) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 888)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 889) struct create_durable {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 890) struct create_context ccontext;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 891) __u8 Name[8];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 892) union {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 893) __u8 Reserved[16];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 894) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 895) __u64 PersistentFileId;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 896) __u64 VolatileFileId;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 897) } Fid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 898) } Data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 899) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 900)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 901) struct create_posix {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 902) struct create_context ccontext;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 903) __u8 Name[16];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 904) __le32 Mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 905) __u32 Reserved;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 906) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 907)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 908) /* See MS-SMB2 2.2.13.2.11 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 909) /* Flags */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 910) #define SMB2_DHANDLE_FLAG_PERSISTENT 0x00000002
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 911) struct durable_context_v2 {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 912) __le32 Timeout;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 913) __le32 Flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 914) __u64 Reserved;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 915) __u8 CreateGuid[16];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 916) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 917)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 918) struct create_durable_v2 {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 919) struct create_context ccontext;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 920) __u8 Name[8];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 921) struct durable_context_v2 dcontext;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 922) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 923)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 924) /* See MS-SMB2 2.2.13.2.12 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 925) struct durable_reconnect_context_v2 {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 926) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 927) __u64 PersistentFileId;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 928) __u64 VolatileFileId;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 929) } Fid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 930) __u8 CreateGuid[16];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 931) __le32 Flags; /* see above DHANDLE_FLAG_PERSISTENT */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 932) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 933)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 934) /* See MS-SMB2 2.2.14.2.9 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 935) struct create_on_disk_id {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 936) struct create_context ccontext;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 937) __u8 Name[8];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 938) __le64 DiskFileId;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 939) __le64 VolumeId;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 940) __u32 Reserved[4];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 941) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 942)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 943) /* See MS-SMB2 2.2.14.2.12 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 944) struct durable_reconnect_context_v2_rsp {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 945) __le32 Timeout;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 946) __le32 Flags; /* see above DHANDLE_FLAG_PERSISTENT */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 947) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 948)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 949) struct create_durable_handle_reconnect_v2 {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 950) struct create_context ccontext;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 951) __u8 Name[8];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 952) struct durable_reconnect_context_v2 dcontext;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 953) __u8 Pad[4];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 954) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 955)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 956) /* See MS-SMB2 2.2.13.2.5 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 957) struct crt_twarp_ctxt {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 958) struct create_context ccontext;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 959) __u8 Name[8];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 960) __le64 Timestamp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 961)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 962) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 963)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 964) /* See MS-SMB2 2.2.13.2.9 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 965) struct crt_query_id_ctxt {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 966) struct create_context ccontext;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 967) __u8 Name[8];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 968) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 969)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 970) struct crt_sd_ctxt {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 971) struct create_context ccontext;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 972) __u8 Name[8];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 973) struct smb3_sd sd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 974) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 975)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 976)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 977) #define COPY_CHUNK_RES_KEY_SIZE 24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 978) struct resume_key_req {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 979) char ResumeKey[COPY_CHUNK_RES_KEY_SIZE];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 980) __le32 ContextLength; /* MBZ */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 981) char Context[]; /* ignored, Windows sets to 4 bytes of zero */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 982) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 983)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 984) /* this goes in the ioctl buffer when doing a copychunk request */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 985) struct copychunk_ioctl {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 986) char SourceKey[COPY_CHUNK_RES_KEY_SIZE];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 987) __le32 ChunkCount; /* we are only sending 1 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 988) __le32 Reserved;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 989) /* array will only be one chunk long for us */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 990) __le64 SourceOffset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 991) __le64 TargetOffset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 992) __le32 Length; /* how many bytes to copy */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 993) __u32 Reserved2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 994) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 995)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 996) /* this goes in the ioctl buffer when doing FSCTL_SET_ZERO_DATA */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 997) struct file_zero_data_information {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 998) __le64 FileOffset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 999) __le64 BeyondFinalZero;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1000) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1001)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1002) struct copychunk_ioctl_rsp {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1003) __le32 ChunksWritten;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1004) __le32 ChunkBytesWritten;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1005) __le32 TotalBytesWritten;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1006) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1007)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1008) /* See MS-FSCC 2.3.29 and 2.3.30 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1009) struct get_retrieval_pointer_count_req {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1010) __le64 StartingVcn; /* virtual cluster number (signed) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1011) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1012)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1013) struct get_retrieval_pointer_count_rsp {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1014) __le32 ExtentCount;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1015) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1016)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1017) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1018) * See MS-FSCC 2.3.33 and 2.3.34
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1019) * request is the same as get_retrieval_point_count_req struct above
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1020) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1021) struct smb3_extents {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1022) __le64 NextVcn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1023) __le64 Lcn; /* logical cluster number */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1024) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1025)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1026) struct get_retrieval_pointers_refcount_rsp {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1027) __le32 ExtentCount;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1028) __u32 Reserved;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1029) __le64 StartingVcn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1030) struct smb3_extents extents[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1031) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1032)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1033) struct fsctl_set_integrity_information_req {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1034) __le16 ChecksumAlgorithm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1035) __le16 Reserved;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1036) __le32 Flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1037) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1038)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1039) struct fsctl_get_integrity_information_rsp {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1040) __le16 ChecksumAlgorithm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1041) __le16 Reserved;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1042) __le32 Flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1043) __le32 ChecksumChunkSizeInBytes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1044) __le32 ClusterSizeInBytes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1045) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1046)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1047) struct file_allocated_range_buffer {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1048) __le64 file_offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1049) __le64 length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1050) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1051)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1052) /* Integrity ChecksumAlgorithm choices for above */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1053) #define CHECKSUM_TYPE_NONE 0x0000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1054) #define CHECKSUM_TYPE_CRC64 0x0002
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1055) #define CHECKSUM_TYPE_UNCHANGED 0xFFFF /* set only */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1056)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1057) /* Integrity flags for above */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1058) #define FSCTL_INTEGRITY_FLAG_CHECKSUM_ENFORCEMENT_OFF 0x00000001
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1059)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1060) /* Reparse structures - see MS-FSCC 2.1.2 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1061)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1062) /* struct fsctl_reparse_info_req is empty, only response structs (see below) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1063)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1064) struct reparse_data_buffer {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1065) __le32 ReparseTag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1066) __le16 ReparseDataLength;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1067) __u16 Reserved;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1068) __u8 DataBuffer[]; /* Variable Length */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1069) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1070)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1071) struct reparse_guid_data_buffer {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1072) __le32 ReparseTag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1073) __le16 ReparseDataLength;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1074) __u16 Reserved;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1075) __u8 ReparseGuid[16];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1076) __u8 DataBuffer[]; /* Variable Length */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1077) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1078)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1079) struct reparse_mount_point_data_buffer {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1080) __le32 ReparseTag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1081) __le16 ReparseDataLength;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1082) __u16 Reserved;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1083) __le16 SubstituteNameOffset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1084) __le16 SubstituteNameLength;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1085) __le16 PrintNameOffset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1086) __le16 PrintNameLength;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1087) __u8 PathBuffer[]; /* Variable Length */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1088) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1089)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1090) #define SYMLINK_FLAG_RELATIVE 0x00000001
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1091)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1092) struct reparse_symlink_data_buffer {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1093) __le32 ReparseTag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1094) __le16 ReparseDataLength;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1095) __u16 Reserved;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1096) __le16 SubstituteNameOffset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1097) __le16 SubstituteNameLength;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1098) __le16 PrintNameOffset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1099) __le16 PrintNameLength;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1100) __le32 Flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1101) __u8 PathBuffer[]; /* Variable Length */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1102) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1103)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1104) /* See MS-FSCC 2.1.2.6 and cifspdu.h for struct reparse_posix_data */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1105)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1106)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1107) /* See MS-DFSC 2.2.2 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1108) struct fsctl_get_dfs_referral_req {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1109) __le16 MaxReferralLevel;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1110) __u8 RequestFileName[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1111) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1112)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1113) /* DFS response is struct get_dfs_refer_rsp */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1114)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1115) /* See MS-SMB2 2.2.31.3 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1116) struct network_resiliency_req {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1117) __le32 Timeout;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1118) __le32 Reserved;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1119) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1120) /* There is no buffer for the response ie no struct network_resiliency_rsp */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1121)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1122)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1123) struct validate_negotiate_info_req {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1124) __le32 Capabilities;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1125) __u8 Guid[SMB2_CLIENT_GUID_SIZE];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1126) __le16 SecurityMode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1127) __le16 DialectCount;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1128) __le16 Dialects[4]; /* BB expand this if autonegotiate > 4 dialects */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1129) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1130)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1131) struct validate_negotiate_info_rsp {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1132) __le32 Capabilities;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1133) __u8 Guid[SMB2_CLIENT_GUID_SIZE];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1134) __le16 SecurityMode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1135) __le16 Dialect; /* Dialect in use for the connection */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1136) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1137)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1138) #define RSS_CAPABLE cpu_to_le32(0x00000001)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1139) #define RDMA_CAPABLE cpu_to_le32(0x00000002)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1140)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1141) #define INTERNETWORK cpu_to_le16(0x0002)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1142) #define INTERNETWORKV6 cpu_to_le16(0x0017)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1143)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1144) struct network_interface_info_ioctl_rsp {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1145) __le32 Next; /* next interface. zero if this is last one */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1146) __le32 IfIndex;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1147) __le32 Capability; /* RSS or RDMA Capable */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1148) __le32 Reserved;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1149) __le64 LinkSpeed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1150) __le16 Family;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1151) __u8 Buffer[126];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1152) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1153)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1154) struct iface_info_ipv4 {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1155) __be16 Port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1156) __be32 IPv4Address;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1157) __be64 Reserved;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1158) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1159)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1160) struct iface_info_ipv6 {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1161) __be16 Port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1162) __be32 FlowInfo;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1163) __u8 IPv6Address[16];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1164) __be32 ScopeId;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1165) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1166)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1167) #define NO_FILE_ID 0xFFFFFFFFFFFFFFFFULL /* general ioctls to srv not to file */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1168)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1169) struct compress_ioctl {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1170) __le16 CompressionState; /* See cifspdu.h for possible flag values */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1171) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1172)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1173) struct duplicate_extents_to_file {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1174) __u64 PersistentFileHandle; /* source file handle, opaque endianness */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1175) __u64 VolatileFileHandle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1176) __le64 SourceFileOffset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1177) __le64 TargetFileOffset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1178) __le64 ByteCount; /* Bytes to be copied */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1179) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1180)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1181) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1182) * Maximum number of iovs we need for an ioctl request.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1183) * [0] : struct smb2_ioctl_req
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1184) * [1] : in_data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1185) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1186) #define SMB2_IOCTL_IOV_SIZE 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1187)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1188) struct smb2_ioctl_req {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1189) struct smb2_sync_hdr sync_hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1190) __le16 StructureSize; /* Must be 57 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1191) __u16 Reserved;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1192) __le32 CtlCode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1193) __u64 PersistentFileId; /* opaque endianness */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1194) __u64 VolatileFileId; /* opaque endianness */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1195) __le32 InputOffset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1196) __le32 InputCount;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1197) __le32 MaxInputResponse;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1198) __le32 OutputOffset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1199) __le32 OutputCount;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1200) __le32 MaxOutputResponse;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1201) __le32 Flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1202) __u32 Reserved2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1203) __u8 Buffer[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1204) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1205)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1206) struct smb2_ioctl_rsp {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1207) struct smb2_sync_hdr sync_hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1208) __le16 StructureSize; /* Must be 57 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1209) __u16 Reserved;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1210) __le32 CtlCode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1211) __u64 PersistentFileId; /* opaque endianness */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1212) __u64 VolatileFileId; /* opaque endianness */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1213) __le32 InputOffset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1214) __le32 InputCount;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1215) __le32 OutputOffset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1216) __le32 OutputCount;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1217) __le32 Flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1218) __u32 Reserved2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1219) /* char * buffer[] */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1220) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1221)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1222) /* Currently defined values for close flags */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1223) #define SMB2_CLOSE_FLAG_POSTQUERY_ATTRIB cpu_to_le16(0x0001)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1224) struct smb2_close_req {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1225) struct smb2_sync_hdr sync_hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1226) __le16 StructureSize; /* Must be 24 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1227) __le16 Flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1228) __le32 Reserved;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1229) __u64 PersistentFileId; /* opaque endianness */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1230) __u64 VolatileFileId; /* opaque endianness */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1231) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1232)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1233) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1234) * Maximum size of a SMB2_CLOSE response is 64 (smb2 header) + 60 (data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1235) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1236) #define MAX_SMB2_CLOSE_RESPONSE_SIZE 124
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1237)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1238) struct smb2_close_rsp {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1239) struct smb2_sync_hdr sync_hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1240) __le16 StructureSize; /* 60 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1241) __le16 Flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1242) __le32 Reserved;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1243) __le64 CreationTime;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1244) __le64 LastAccessTime;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1245) __le64 LastWriteTime;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1246) __le64 ChangeTime;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1247) __le64 AllocationSize; /* Beginning of FILE_STANDARD_INFO equivalent */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1248) __le64 EndOfFile;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1249) __le32 Attributes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1250) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1251)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1252) struct smb2_flush_req {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1253) struct smb2_sync_hdr sync_hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1254) __le16 StructureSize; /* Must be 24 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1255) __le16 Reserved1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1256) __le32 Reserved2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1257) __u64 PersistentFileId; /* opaque endianness */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1258) __u64 VolatileFileId; /* opaque endianness */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1259) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1260)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1261) struct smb2_flush_rsp {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1262) struct smb2_sync_hdr sync_hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1263) __le16 StructureSize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1264) __le16 Reserved;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1265) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1266)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1267) /* For read request Flags field below, following flag is defined for SMB3.02 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1268) #define SMB2_READFLAG_READ_UNBUFFERED 0x01
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1269) #define SMB2_READFLAG_REQUEST_COMPRESSED 0x02 /* See MS-SMB2 2.2.19 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1270)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1271) /* Channel field for read and write: exactly one of following flags can be set*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1272) #define SMB2_CHANNEL_NONE cpu_to_le32(0x00000000)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1273) #define SMB2_CHANNEL_RDMA_V1 cpu_to_le32(0x00000001) /* SMB3 or later */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1274) #define SMB2_CHANNEL_RDMA_V1_INVALIDATE cpu_to_le32(0x00000002) /* >= SMB3.02 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1275) #define SMB2_CHANNEL_RDMA_TRANSFORM cpu_to_le32(0x00000003) /* >= SMB3.02, only used on write */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1276)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1277) /* SMB2 read request without RFC1001 length at the beginning */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1278) struct smb2_read_plain_req {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1279) struct smb2_sync_hdr sync_hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1280) __le16 StructureSize; /* Must be 49 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1281) __u8 Padding; /* offset from start of SMB2 header to place read */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1282) __u8 Flags; /* MBZ unless SMB3.02 or later */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1283) __le32 Length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1284) __le64 Offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1285) __u64 PersistentFileId; /* opaque endianness */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1286) __u64 VolatileFileId; /* opaque endianness */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1287) __le32 MinimumCount;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1288) __le32 Channel; /* MBZ except for SMB3 or later */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1289) __le32 RemainingBytes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1290) __le16 ReadChannelInfoOffset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1291) __le16 ReadChannelInfoLength;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1292) __u8 Buffer[1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1293) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1294)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1295) /* Read flags */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1296) #define SMB2_READFLAG_RESPONSE_NONE 0x00000000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1297) #define SMB2_READFLAG_RESPONSE_RDMA_TRANSFORM 0x00000001
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1298)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1299) struct smb2_read_rsp {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1300) struct smb2_sync_hdr sync_hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1301) __le16 StructureSize; /* Must be 17 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1302) __u8 DataOffset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1303) __u8 Reserved;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1304) __le32 DataLength;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1305) __le32 DataRemaining;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1306) __u32 Flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1307) __u8 Buffer[1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1308) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1309)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1310) /* For write request Flags field below the following flags are defined: */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1311) #define SMB2_WRITEFLAG_WRITE_THROUGH 0x00000001 /* SMB2.1 or later */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1312) #define SMB2_WRITEFLAG_WRITE_UNBUFFERED 0x00000002 /* SMB3.02 or later */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1313)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1314) struct smb2_write_req {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1315) struct smb2_sync_hdr sync_hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1316) __le16 StructureSize; /* Must be 49 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1317) __le16 DataOffset; /* offset from start of SMB2 header to write data */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1318) __le32 Length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1319) __le64 Offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1320) __u64 PersistentFileId; /* opaque endianness */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1321) __u64 VolatileFileId; /* opaque endianness */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1322) __le32 Channel; /* MBZ unless SMB3.02 or later */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1323) __le32 RemainingBytes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1324) __le16 WriteChannelInfoOffset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1325) __le16 WriteChannelInfoLength;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1326) __le32 Flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1327) __u8 Buffer[1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1328) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1329)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1330) struct smb2_write_rsp {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1331) struct smb2_sync_hdr sync_hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1332) __le16 StructureSize; /* Must be 17 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1333) __u8 DataOffset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1334) __u8 Reserved;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1335) __le32 DataLength;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1336) __le32 DataRemaining;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1337) __u32 Reserved2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1338) __u8 Buffer[1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1339) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1340)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1341) /* notify flags */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1342) #define SMB2_WATCH_TREE 0x0001
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1343)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1344) /* notify completion filter flags. See MS-FSCC 2.6 and MS-SMB2 2.2.35 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1345) #define FILE_NOTIFY_CHANGE_FILE_NAME 0x00000001
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1346) #define FILE_NOTIFY_CHANGE_DIR_NAME 0x00000002
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1347) #define FILE_NOTIFY_CHANGE_ATTRIBUTES 0x00000004
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1348) #define FILE_NOTIFY_CHANGE_SIZE 0x00000008
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1349) #define FILE_NOTIFY_CHANGE_LAST_WRITE 0x00000010
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1350) #define FILE_NOTIFY_CHANGE_LAST_ACCESS 0x00000020
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1351) #define FILE_NOTIFY_CHANGE_CREATION 0x00000040
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1352) #define FILE_NOTIFY_CHANGE_EA 0x00000080
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1353) #define FILE_NOTIFY_CHANGE_SECURITY 0x00000100
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1354) #define FILE_NOTIFY_CHANGE_STREAM_NAME 0x00000200
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1355) #define FILE_NOTIFY_CHANGE_STREAM_SIZE 0x00000400
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1356) #define FILE_NOTIFY_CHANGE_STREAM_WRITE 0x00000800
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1357)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1358) struct smb2_change_notify_req {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1359) struct smb2_sync_hdr sync_hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1360) __le16 StructureSize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1361) __le16 Flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1362) __le32 OutputBufferLength;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1363) __u64 PersistentFileId; /* opaque endianness */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1364) __u64 VolatileFileId; /* opaque endianness */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1365) __le32 CompletionFilter;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1366) __u32 Reserved;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1367) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1368)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1369) struct smb2_change_notify_rsp {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1370) struct smb2_sync_hdr sync_hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1371) __le16 StructureSize; /* Must be 9 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1372) __le16 OutputBufferOffset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1373) __le32 OutputBufferLength;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1374) __u8 Buffer[1]; /* array of file notify structs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1375) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1376)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1377) #define SMB2_LOCKFLAG_SHARED_LOCK 0x0001
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1378) #define SMB2_LOCKFLAG_EXCLUSIVE_LOCK 0x0002
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1379) #define SMB2_LOCKFLAG_UNLOCK 0x0004
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1380) #define SMB2_LOCKFLAG_FAIL_IMMEDIATELY 0x0010
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1381)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1382) struct smb2_lock_element {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1383) __le64 Offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1384) __le64 Length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1385) __le32 Flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1386) __le32 Reserved;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1387) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1388)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1389) struct smb2_lock_req {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1390) struct smb2_sync_hdr sync_hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1391) __le16 StructureSize; /* Must be 48 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1392) __le16 LockCount;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1393) __le32 Reserved;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1394) __u64 PersistentFileId; /* opaque endianness */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1395) __u64 VolatileFileId; /* opaque endianness */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1396) /* Followed by at least one */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1397) struct smb2_lock_element locks[1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1398) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1399)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1400) struct smb2_lock_rsp {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1401) struct smb2_sync_hdr sync_hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1402) __le16 StructureSize; /* Must be 4 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1403) __le16 Reserved;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1404) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1405)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1406) struct smb2_echo_req {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1407) struct smb2_sync_hdr sync_hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1408) __le16 StructureSize; /* Must be 4 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1409) __u16 Reserved;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1410) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1411)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1412) struct smb2_echo_rsp {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1413) struct smb2_sync_hdr sync_hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1414) __le16 StructureSize; /* Must be 4 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1415) __u16 Reserved;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1416) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1417)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1418) /* search (query_directory) Flags field */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1419) #define SMB2_RESTART_SCANS 0x01
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1420) #define SMB2_RETURN_SINGLE_ENTRY 0x02
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1421) #define SMB2_INDEX_SPECIFIED 0x04
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1422) #define SMB2_REOPEN 0x10
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1423)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1424) #define SMB2_QUERY_DIRECTORY_IOV_SIZE 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1425)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1426) struct smb2_query_directory_req {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1427) struct smb2_sync_hdr sync_hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1428) __le16 StructureSize; /* Must be 33 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1429) __u8 FileInformationClass;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1430) __u8 Flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1431) __le32 FileIndex;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1432) __u64 PersistentFileId; /* opaque endianness */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1433) __u64 VolatileFileId; /* opaque endianness */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1434) __le16 FileNameOffset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1435) __le16 FileNameLength;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1436) __le32 OutputBufferLength;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1437) __u8 Buffer[1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1438) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1439)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1440) struct smb2_query_directory_rsp {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1441) struct smb2_sync_hdr sync_hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1442) __le16 StructureSize; /* Must be 9 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1443) __le16 OutputBufferOffset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1444) __le32 OutputBufferLength;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1445) __u8 Buffer[1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1446) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1447)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1448) /* Possible InfoType values */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1449) #define SMB2_O_INFO_FILE 0x01
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1450) #define SMB2_O_INFO_FILESYSTEM 0x02
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1451) #define SMB2_O_INFO_SECURITY 0x03
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1452) #define SMB2_O_INFO_QUOTA 0x04
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1453)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1454) /* Security info type additionalinfo flags. See MS-SMB2 (2.2.37) or MS-DTYP */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1455) #define OWNER_SECINFO 0x00000001
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1456) #define GROUP_SECINFO 0x00000002
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1457) #define DACL_SECINFO 0x00000004
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1458) #define SACL_SECINFO 0x00000008
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1459) #define LABEL_SECINFO 0x00000010
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1460) #define ATTRIBUTE_SECINFO 0x00000020
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1461) #define SCOPE_SECINFO 0x00000040
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1462) #define BACKUP_SECINFO 0x00010000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1463) #define UNPROTECTED_SACL_SECINFO 0x10000000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1464) #define UNPROTECTED_DACL_SECINFO 0x20000000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1465) #define PROTECTED_SACL_SECINFO 0x40000000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1466) #define PROTECTED_DACL_SECINFO 0x80000000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1467)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1468) /* Flags used for FileFullEAinfo */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1469) #define SL_RESTART_SCAN 0x00000001
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1470) #define SL_RETURN_SINGLE_ENTRY 0x00000002
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1471) #define SL_INDEX_SPECIFIED 0x00000004
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1472)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1473) struct smb2_query_info_req {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1474) struct smb2_sync_hdr sync_hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1475) __le16 StructureSize; /* Must be 41 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1476) __u8 InfoType;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1477) __u8 FileInfoClass;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1478) __le32 OutputBufferLength;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1479) __le16 InputBufferOffset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1480) __u16 Reserved;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1481) __le32 InputBufferLength;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1482) __le32 AdditionalInformation;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1483) __le32 Flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1484) __u64 PersistentFileId; /* opaque endianness */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1485) __u64 VolatileFileId; /* opaque endianness */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1486) __u8 Buffer[1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1487) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1488)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1489) struct smb2_query_info_rsp {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1490) struct smb2_sync_hdr sync_hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1491) __le16 StructureSize; /* Must be 9 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1492) __le16 OutputBufferOffset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1493) __le32 OutputBufferLength;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1494) __u8 Buffer[1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1495) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1496)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1497) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1498) * Maximum number of iovs we need for a set-info request.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1499) * The largest one is rename/hardlink
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1500) * [0] : struct smb2_set_info_req + smb2_file_[rename|link]_info
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1501) * [1] : path
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1502) * [2] : compound padding
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1503) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1504) #define SMB2_SET_INFO_IOV_SIZE 3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1505)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1506) struct smb2_set_info_req {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1507) struct smb2_sync_hdr sync_hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1508) __le16 StructureSize; /* Must be 33 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1509) __u8 InfoType;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1510) __u8 FileInfoClass;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1511) __le32 BufferLength;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1512) __le16 BufferOffset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1513) __u16 Reserved;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1514) __le32 AdditionalInformation;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1515) __u64 PersistentFileId; /* opaque endianness */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1516) __u64 VolatileFileId; /* opaque endianness */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1517) __u8 Buffer[1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1518) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1519)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1520) struct smb2_set_info_rsp {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1521) struct smb2_sync_hdr sync_hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1522) __le16 StructureSize; /* Must be 2 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1523) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1524)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1525) struct smb2_oplock_break {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1526) struct smb2_sync_hdr sync_hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1527) __le16 StructureSize; /* Must be 24 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1528) __u8 OplockLevel;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1529) __u8 Reserved;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1530) __le32 Reserved2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1531) __u64 PersistentFid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1532) __u64 VolatileFid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1533) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1534)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1535) #define SMB2_NOTIFY_BREAK_LEASE_FLAG_ACK_REQUIRED cpu_to_le32(0x01)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1536)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1537) struct smb2_lease_break {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1538) struct smb2_sync_hdr sync_hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1539) __le16 StructureSize; /* Must be 44 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1540) __le16 Epoch;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1541) __le32 Flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1542) __u8 LeaseKey[16];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1543) __le32 CurrentLeaseState;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1544) __le32 NewLeaseState;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1545) __le32 BreakReason;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1546) __le32 AccessMaskHint;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1547) __le32 ShareMaskHint;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1548) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1549)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1550) struct smb2_lease_ack {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1551) struct smb2_sync_hdr sync_hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1552) __le16 StructureSize; /* Must be 36 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1553) __le16 Reserved;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1554) __le32 Flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1555) __u8 LeaseKey[16];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1556) __le32 LeaseState;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1557) __le64 LeaseDuration;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1558) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1559)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1560) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1561) * PDU infolevel structure definitions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1562) * BB consider moving to a different header
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1563) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1564)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1565) /* File System Information Classes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1566) #define FS_VOLUME_INFORMATION 1 /* Query */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1567) #define FS_LABEL_INFORMATION 2 /* Local only */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1568) #define FS_SIZE_INFORMATION 3 /* Query */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1569) #define FS_DEVICE_INFORMATION 4 /* Query */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1570) #define FS_ATTRIBUTE_INFORMATION 5 /* Query */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1571) #define FS_CONTROL_INFORMATION 6 /* Query, Set */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1572) #define FS_FULL_SIZE_INFORMATION 7 /* Query */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1573) #define FS_OBJECT_ID_INFORMATION 8 /* Query, Set */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1574) #define FS_DRIVER_PATH_INFORMATION 9 /* Local only */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1575) #define FS_VOLUME_FLAGS_INFORMATION 10 /* Local only */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1576) #define FS_SECTOR_SIZE_INFORMATION 11 /* SMB3 or later. Query */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1577) #define FS_POSIX_INFORMATION 100 /* SMB3.1.1 POSIX. Query */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1578)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1579) struct smb2_fs_full_size_info {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1580) __le64 TotalAllocationUnits;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1581) __le64 CallerAvailableAllocationUnits;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1582) __le64 ActualAvailableAllocationUnits;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1583) __le32 SectorsPerAllocationUnit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1584) __le32 BytesPerSector;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1585) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1586)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1587) #define SSINFO_FLAGS_ALIGNED_DEVICE 0x00000001
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1588) #define SSINFO_FLAGS_PARTITION_ALIGNED_ON_DEVICE 0x00000002
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1589) #define SSINFO_FLAGS_NO_SEEK_PENALTY 0x00000004
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1590) #define SSINFO_FLAGS_TRIM_ENABLED 0x00000008
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1591)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1592) /* sector size info struct */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1593) struct smb3_fs_ss_info {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1594) __le32 LogicalBytesPerSector;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1595) __le32 PhysicalBytesPerSectorForAtomicity;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1596) __le32 PhysicalBytesPerSectorForPerf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1597) __le32 FileSystemEffectivePhysicalBytesPerSectorForAtomicity;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1598) __le32 Flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1599) __le32 ByteOffsetForSectorAlignment;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1600) __le32 ByteOffsetForPartitionAlignment;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1601) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1602)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1603) /* volume info struct - see MS-FSCC 2.5.9 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1604) #define MAX_VOL_LABEL_LEN 32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1605) struct smb3_fs_vol_info {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1606) __le64 VolumeCreationTime;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1607) __u32 VolumeSerialNumber;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1608) __le32 VolumeLabelLength; /* includes trailing null */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1609) __u8 SupportsObjects; /* True if eg like NTFS, supports objects */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1610) __u8 Reserved;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1611) __u8 VolumeLabel[]; /* variable len */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1612) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1613)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1614) /* partial list of QUERY INFO levels */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1615) #define FILE_DIRECTORY_INFORMATION 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1616) #define FILE_FULL_DIRECTORY_INFORMATION 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1617) #define FILE_BOTH_DIRECTORY_INFORMATION 3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1618) #define FILE_BASIC_INFORMATION 4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1619) #define FILE_STANDARD_INFORMATION 5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1620) #define FILE_INTERNAL_INFORMATION 6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1621) #define FILE_EA_INFORMATION 7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1622) #define FILE_ACCESS_INFORMATION 8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1623) #define FILE_NAME_INFORMATION 9
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1624) #define FILE_RENAME_INFORMATION 10
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1625) #define FILE_LINK_INFORMATION 11
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1626) #define FILE_NAMES_INFORMATION 12
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1627) #define FILE_DISPOSITION_INFORMATION 13
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1628) #define FILE_POSITION_INFORMATION 14
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1629) #define FILE_FULL_EA_INFORMATION 15
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1630) #define FILE_MODE_INFORMATION 16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1631) #define FILE_ALIGNMENT_INFORMATION 17
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1632) #define FILE_ALL_INFORMATION 18
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1633) #define FILE_ALLOCATION_INFORMATION 19
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1634) #define FILE_END_OF_FILE_INFORMATION 20
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1635) #define FILE_ALTERNATE_NAME_INFORMATION 21
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1636) #define FILE_STREAM_INFORMATION 22
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1637) #define FILE_PIPE_INFORMATION 23
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1638) #define FILE_PIPE_LOCAL_INFORMATION 24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1639) #define FILE_PIPE_REMOTE_INFORMATION 25
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1640) #define FILE_MAILSLOT_QUERY_INFORMATION 26
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1641) #define FILE_MAILSLOT_SET_INFORMATION 27
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1642) #define FILE_COMPRESSION_INFORMATION 28
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1643) #define FILE_OBJECT_ID_INFORMATION 29
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1644) /* Number 30 not defined in documents */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1645) #define FILE_MOVE_CLUSTER_INFORMATION 31
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1646) #define FILE_QUOTA_INFORMATION 32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1647) #define FILE_REPARSE_POINT_INFORMATION 33
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1648) #define FILE_NETWORK_OPEN_INFORMATION 34
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1649) #define FILE_ATTRIBUTE_TAG_INFORMATION 35
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1650) #define FILE_TRACKING_INFORMATION 36
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1651) #define FILEID_BOTH_DIRECTORY_INFORMATION 37
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1652) #define FILEID_FULL_DIRECTORY_INFORMATION 38
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1653) #define FILE_VALID_DATA_LENGTH_INFORMATION 39
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1654) #define FILE_SHORT_NAME_INFORMATION 40
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1655) #define FILE_SFIO_RESERVE_INFORMATION 44
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1656) #define FILE_SFIO_VOLUME_INFORMATION 45
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1657) #define FILE_HARD_LINK_INFORMATION 46
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1658) #define FILE_NORMALIZED_NAME_INFORMATION 48
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1659) #define FILEID_GLOBAL_TX_DIRECTORY_INFORMATION 50
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1660) #define FILE_STANDARD_LINK_INFORMATION 54
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1661) #define FILE_ID_INFORMATION 59
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1662)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1663) struct smb2_file_internal_info {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1664) __le64 IndexNumber;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1665) } __packed; /* level 6 Query */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1666)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1667) struct smb2_file_rename_info { /* encoding of request for level 10 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1668) __u8 ReplaceIfExists; /* 1 = replace existing target with new */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1669) /* 0 = fail if target already exists */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1670) __u8 Reserved[7];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1671) __u64 RootDirectory; /* MBZ for network operations (why says spec?) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1672) __le32 FileNameLength;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1673) char FileName[]; /* New name to be assigned */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1674) /* padding - overall struct size must be >= 24 so filename + pad >= 6 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1675) } __packed; /* level 10 Set */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1676)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1677) struct smb2_file_link_info { /* encoding of request for level 11 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1678) __u8 ReplaceIfExists; /* 1 = replace existing link with new */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1679) /* 0 = fail if link already exists */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1680) __u8 Reserved[7];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1681) __u64 RootDirectory; /* MBZ for network operations (why says spec?) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1682) __le32 FileNameLength;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1683) char FileName[]; /* Name to be assigned to new link */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1684) } __packed; /* level 11 Set */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1685)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1686) struct smb2_file_full_ea_info { /* encoding of response for level 15 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1687) __le32 next_entry_offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1688) __u8 flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1689) __u8 ea_name_length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1690) __le16 ea_value_length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1691) char ea_data[]; /* \0 terminated name plus value */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1692) } __packed; /* level 15 Set */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1693)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1694) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1695) * This level 18, although with struct with same name is different from cifs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1696) * level 0x107. Level 0x107 has an extra u64 between AccessFlags and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1697) * CurrentByteOffset.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1698) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1699) struct smb2_file_all_info { /* data block encoding of response to level 18 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1700) __le64 CreationTime; /* Beginning of FILE_BASIC_INFO equivalent */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1701) __le64 LastAccessTime;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1702) __le64 LastWriteTime;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1703) __le64 ChangeTime;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1704) __le32 Attributes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1705) __u32 Pad1; /* End of FILE_BASIC_INFO_INFO equivalent */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1706) __le64 AllocationSize; /* Beginning of FILE_STANDARD_INFO equivalent */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1707) __le64 EndOfFile; /* size ie offset to first free byte in file */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1708) __le32 NumberOfLinks; /* hard links */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1709) __u8 DeletePending;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1710) __u8 Directory;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1711) __u16 Pad2; /* End of FILE_STANDARD_INFO equivalent */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1712) __le64 IndexNumber;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1713) __le32 EASize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1714) __le32 AccessFlags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1715) __le64 CurrentByteOffset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1716) __le32 Mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1717) __le32 AlignmentRequirement;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1718) __le32 FileNameLength;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1719) char FileName[1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1720) } __packed; /* level 18 Query */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1721)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1722) struct smb2_file_eof_info { /* encoding of request for level 10 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1723) __le64 EndOfFile; /* new end of file value */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1724) } __packed; /* level 20 Set */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1725)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1726) struct smb2_file_reparse_point_info {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1727) __le64 IndexNumber;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1728) __le32 Tag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1729) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1730)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1731) struct smb2_file_network_open_info {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1732) __le64 CreationTime;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1733) __le64 LastAccessTime;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1734) __le64 LastWriteTime;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1735) __le64 ChangeTime;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1736) __le64 AllocationSize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1737) __le64 EndOfFile;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1738) __le32 Attributes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1739) __le32 Reserved;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1740) } __packed; /* level 34 Query also similar returned in close rsp and open rsp */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1741)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1742) /* See MS-FSCC 2.4.43 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1743) struct smb2_file_id_information {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1744) __le64 VolumeSerialNumber;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1745) __u64 PersistentFileId; /* opaque endianness */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1746) __u64 VolatileFileId; /* opaque endianness */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1747) } __packed; /* level 59 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1748)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1749) extern char smb2_padding[7];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1750)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1751) /* equivalent of the contents of SMB3.1.1 POSIX open context response */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1752) struct create_posix_rsp {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1753) u32 nlink;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1754) u32 reparse_tag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1755) u32 mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1756) struct cifs_sid owner; /* var-sized on the wire */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1757) struct cifs_sid group; /* var-sized on the wire */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1758) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1759)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1760) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1761) * SMB2-only POSIX info level for query dir
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1762) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1763) * See posix_info_sid_size(), posix_info_extra_size() and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1764) * posix_info_parse() to help with the handling of this struct.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1765) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1766) struct smb2_posix_info {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1767) __le32 NextEntryOffset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1768) __u32 Ignored;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1769) __le64 CreationTime;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1770) __le64 LastAccessTime;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1771) __le64 LastWriteTime;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1772) __le64 ChangeTime;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1773) __le64 EndOfFile;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1774) __le64 AllocationSize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1775) __le32 DosAttributes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1776) __le64 Inode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1777) __le32 DeviceId;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1778) __le32 Zero;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1779) /* beginning of POSIX Create Context Response */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1780) __le32 HardLinks;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1781) __le32 ReparseTag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1782) __le32 Mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1783) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1784) * var sized owner SID
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1785) * var sized group SID
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1786) * le32 filenamelength
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1787) * u8 filename[]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1788) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1789) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1790)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1791) /* Level 100 query info */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1792) struct smb311_posix_qinfo {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1793) __le64 CreationTime;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1794) __le64 LastAccessTime;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1795) __le64 LastWriteTime;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1796) __le64 ChangeTime;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1797) __le64 EndOfFile;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1798) __le64 AllocationSize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1799) __le32 DosAttributes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1800) __le64 Inode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1801) __le32 DeviceId;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1802) __le32 Zero;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1803) /* beginning of POSIX Create Context Response */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1804) __le32 HardLinks;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1805) __le32 ReparseTag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1806) __le32 Mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1807) u8 Sids[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1808) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1809) * var sized owner SID
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1810) * var sized group SID
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1811) * le32 filenamelength
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1812) * u8 filename[]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1813) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1814) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1815)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1816) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1817) * Parsed version of the above struct. Allows direct access to the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1818) * variable length fields
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1819) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1820) struct smb2_posix_info_parsed {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1821) const struct smb2_posix_info *base;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1822) size_t size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1823) struct cifs_sid owner;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1824) struct cifs_sid group;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1825) int name_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1826) const u8 *name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1827) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1828)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1829) #endif /* _SMB2PDU_H */