Steve French | ddfbefb | 2011-03-15 02:08:48 +0000 | [diff] [blame] | 1 | /* |
| 2 | * fs/cifs/smb2pdu.h |
| 3 | * |
Steve French | be7457d | 2013-06-19 17:41:10 -0500 | [diff] [blame] | 4 | * Copyright (c) International Business Machines Corp., 2009, 2013 |
Steve French | ddfbefb | 2011-03-15 02:08:48 +0000 | [diff] [blame] | 5 | * Etersoft, 2012 |
| 6 | * Author(s): Steve French (sfrench@us.ibm.com) |
| 7 | * Pavel Shilovsky (pshilovsky@samba.org) 2012 |
| 8 | * |
| 9 | * This library is free software; you can redistribute it and/or modify |
| 10 | * it under the terms of the GNU Lesser General Public License as published |
| 11 | * by the Free Software Foundation; either version 2.1 of the License, or |
| 12 | * (at your option) any later version. |
| 13 | * |
| 14 | * This library is distributed in the hope that it will be useful, |
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See |
| 17 | * the GNU Lesser General Public License for more details. |
| 18 | * |
| 19 | * You should have received a copy of the GNU Lesser General Public License |
| 20 | * along with this library; if not, write to the Free Software |
| 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 22 | */ |
| 23 | |
| 24 | #ifndef _SMB2PDU_H |
| 25 | #define _SMB2PDU_H |
| 26 | |
| 27 | #include <net/sock.h> |
| 28 | |
| 29 | /* |
Pavel Shilovsky | 2dc7e1c | 2011-12-26 22:53:34 +0400 | [diff] [blame] | 30 | * Note that, due to trying to use names similar to the protocol specifications, |
| 31 | * there are many mixed case field names in the structures below. Although |
| 32 | * this does not match typical Linux kernel style, it is necessary to be |
| 33 | * be able to match against the protocol specfication. |
| 34 | * |
| 35 | * SMB2 commands |
| 36 | * Some commands have minimal (wct=0,bcc=0), or uninteresting, responses |
| 37 | * (ie no useful data other than the SMB error code itself) and are marked such. |
| 38 | * Knowing this helps avoid response buffer allocations and copy in some cases. |
| 39 | */ |
| 40 | |
| 41 | /* List of commands in host endian */ |
| 42 | #define SMB2_NEGOTIATE_HE 0x0000 |
| 43 | #define SMB2_SESSION_SETUP_HE 0x0001 |
| 44 | #define SMB2_LOGOFF_HE 0x0002 /* trivial request/resp */ |
| 45 | #define SMB2_TREE_CONNECT_HE 0x0003 |
| 46 | #define SMB2_TREE_DISCONNECT_HE 0x0004 /* trivial req/resp */ |
| 47 | #define SMB2_CREATE_HE 0x0005 |
| 48 | #define SMB2_CLOSE_HE 0x0006 |
| 49 | #define SMB2_FLUSH_HE 0x0007 /* trivial resp */ |
| 50 | #define SMB2_READ_HE 0x0008 |
| 51 | #define SMB2_WRITE_HE 0x0009 |
| 52 | #define SMB2_LOCK_HE 0x000A |
| 53 | #define SMB2_IOCTL_HE 0x000B |
| 54 | #define SMB2_CANCEL_HE 0x000C |
| 55 | #define SMB2_ECHO_HE 0x000D |
| 56 | #define SMB2_QUERY_DIRECTORY_HE 0x000E |
| 57 | #define SMB2_CHANGE_NOTIFY_HE 0x000F |
| 58 | #define SMB2_QUERY_INFO_HE 0x0010 |
| 59 | #define SMB2_SET_INFO_HE 0x0011 |
| 60 | #define SMB2_OPLOCK_BREAK_HE 0x0012 |
| 61 | |
| 62 | /* The same list in little endian */ |
| 63 | #define SMB2_NEGOTIATE cpu_to_le16(SMB2_NEGOTIATE_HE) |
| 64 | #define SMB2_SESSION_SETUP cpu_to_le16(SMB2_SESSION_SETUP_HE) |
| 65 | #define SMB2_LOGOFF cpu_to_le16(SMB2_LOGOFF_HE) |
| 66 | #define SMB2_TREE_CONNECT cpu_to_le16(SMB2_TREE_CONNECT_HE) |
| 67 | #define SMB2_TREE_DISCONNECT cpu_to_le16(SMB2_TREE_DISCONNECT_HE) |
| 68 | #define SMB2_CREATE cpu_to_le16(SMB2_CREATE_HE) |
| 69 | #define SMB2_CLOSE cpu_to_le16(SMB2_CLOSE_HE) |
| 70 | #define SMB2_FLUSH cpu_to_le16(SMB2_FLUSH_HE) |
| 71 | #define SMB2_READ cpu_to_le16(SMB2_READ_HE) |
| 72 | #define SMB2_WRITE cpu_to_le16(SMB2_WRITE_HE) |
| 73 | #define SMB2_LOCK cpu_to_le16(SMB2_LOCK_HE) |
| 74 | #define SMB2_IOCTL cpu_to_le16(SMB2_IOCTL_HE) |
| 75 | #define SMB2_CANCEL cpu_to_le16(SMB2_CANCEL_HE) |
| 76 | #define SMB2_ECHO cpu_to_le16(SMB2_ECHO_HE) |
| 77 | #define SMB2_QUERY_DIRECTORY cpu_to_le16(SMB2_QUERY_DIRECTORY_HE) |
| 78 | #define SMB2_CHANGE_NOTIFY cpu_to_le16(SMB2_CHANGE_NOTIFY_HE) |
| 79 | #define SMB2_QUERY_INFO cpu_to_le16(SMB2_QUERY_INFO_HE) |
| 80 | #define SMB2_SET_INFO cpu_to_le16(SMB2_SET_INFO_HE) |
| 81 | #define SMB2_OPLOCK_BREAK cpu_to_le16(SMB2_OPLOCK_BREAK_HE) |
| 82 | |
Pavel Shilovsky | 96a988f | 2016-11-29 11:31:23 -0800 | [diff] [blame] | 83 | #define SMB2_INTERNAL_CMD cpu_to_le16(0xFFFF) |
| 84 | |
Pavel Shilovsky | 2dc7e1c | 2011-12-26 22:53:34 +0400 | [diff] [blame] | 85 | #define NUMBER_OF_SMB2_COMMANDS 0x0013 |
| 86 | |
Pavel Shilovsky | 9e37b17 | 2017-08-24 15:16:40 -0700 | [diff] [blame] | 87 | /* 4 len + 52 transform hdr + 64 hdr + 56 create rsp */ |
| 88 | #define MAX_SMB2_HDR_SIZE 0x00b0 |
Pavel Shilovsky | 2dc7e1c | 2011-12-26 22:53:34 +0400 | [diff] [blame] | 89 | |
Fabian Frederick | bc09d14 | 2014-12-10 15:41:15 -0800 | [diff] [blame] | 90 | #define SMB2_PROTO_NUMBER cpu_to_le32(0x424d53fe) |
Steve French | 373512e | 2015-12-18 13:05:30 -0600 | [diff] [blame] | 91 | #define SMB2_TRANSFORM_PROTO_NUM cpu_to_le32(0x424d53fd) |
Pavel Shilovsky | 093b2bd | 2011-06-08 15:51:07 +0400 | [diff] [blame] | 92 | |
Pavel Shilovsky | 2dc7e1c | 2011-12-26 22:53:34 +0400 | [diff] [blame] | 93 | /* |
Steve French | ddfbefb | 2011-03-15 02:08:48 +0000 | [diff] [blame] | 94 | * SMB2 Header Definition |
| 95 | * |
| 96 | * "MBZ" : Must be Zero |
| 97 | * "BB" : BugBug, Something to check/review/analyze later |
| 98 | * "PDU" : "Protocol Data Unit" (ie a network "frame") |
| 99 | * |
| 100 | */ |
Pavel Shilovsky | 7411286 | 2012-07-27 01:20:41 +0400 | [diff] [blame] | 101 | |
Fabian Frederick | bc09d14 | 2014-12-10 15:41:15 -0800 | [diff] [blame] | 102 | #define SMB2_HEADER_STRUCTURE_SIZE cpu_to_le16(64) |
Pavel Shilovsky | 7411286 | 2012-07-27 01:20:41 +0400 | [diff] [blame] | 103 | |
Pavel Shilovsky | 31473fc | 2016-10-24 15:33:04 -0700 | [diff] [blame] | 104 | struct smb2_sync_hdr { |
Steve French | 373512e | 2015-12-18 13:05:30 -0600 | [diff] [blame] | 105 | __le32 ProtocolId; /* 0xFE 'S' 'M' 'B' */ |
Steve French | ddfbefb | 2011-03-15 02:08:48 +0000 | [diff] [blame] | 106 | __le16 StructureSize; /* 64 */ |
| 107 | __le16 CreditCharge; /* MBZ */ |
| 108 | __le32 Status; /* Error from server */ |
| 109 | __le16 Command; |
| 110 | __le16 CreditRequest; /* CreditResponse */ |
| 111 | __le32 Flags; |
| 112 | __le32 NextCommand; |
Sachin Prabhu | 9235d09 | 2014-12-09 17:37:00 +0000 | [diff] [blame] | 113 | __le64 MessageId; |
Steve French | ddfbefb | 2011-03-15 02:08:48 +0000 | [diff] [blame] | 114 | __le32 ProcessId; |
| 115 | __u32 TreeId; /* opaque - so do not make little endian */ |
| 116 | __u64 SessionId; /* opaque - so do not make little endian */ |
| 117 | __u8 Signature[16]; |
| 118 | } __packed; |
| 119 | |
Pavel Shilovsky | cb200bd | 2016-10-24 16:59:57 -0700 | [diff] [blame] | 120 | struct smb2_sync_pdu { |
| 121 | struct smb2_sync_hdr sync_hdr; |
| 122 | __le16 StructureSize2; /* size of wct area (varies, request specific) */ |
| 123 | } __packed; |
| 124 | |
Pavel Shilovsky | 31473fc | 2016-10-24 15:33:04 -0700 | [diff] [blame] | 125 | struct smb2_hdr { |
| 126 | __be32 smb2_buf_length; /* big endian on wire */ |
| 127 | /* length is only two or three bytes - with */ |
| 128 | /* one or two byte type preceding it that MBZ */ |
| 129 | struct smb2_sync_hdr sync_hdr; |
| 130 | } __packed; |
| 131 | |
Pavel Shilovsky | 093b2bd | 2011-06-08 15:51:07 +0400 | [diff] [blame] | 132 | struct smb2_pdu { |
| 133 | struct smb2_hdr hdr; |
| 134 | __le16 StructureSize2; /* size of wct area (varies, request specific) */ |
| 135 | } __packed; |
| 136 | |
Pavel Shilovsky | 026e93d | 2016-11-03 16:47:37 -0700 | [diff] [blame] | 137 | #define SMB3_AES128CMM_NONCE 11 |
| 138 | #define SMB3_AES128GCM_NONCE 12 |
| 139 | |
Steve French | 0cbaa53 | 2013-11-15 23:50:24 -0600 | [diff] [blame] | 140 | struct smb2_transform_hdr { |
| 141 | __be32 smb2_buf_length; /* big endian on wire */ |
| 142 | /* length is only two or three bytes - with |
| 143 | one or two byte type preceding it that MBZ */ |
Pavel Shilovsky | 026e93d | 2016-11-03 16:47:37 -0700 | [diff] [blame] | 144 | __le32 ProtocolId; /* 0xFD 'S' 'M' 'B' */ |
Steve French | 0cbaa53 | 2013-11-15 23:50:24 -0600 | [diff] [blame] | 145 | __u8 Signature[16]; |
Steve French | 373512e | 2015-12-18 13:05:30 -0600 | [diff] [blame] | 146 | __u8 Nonce[16]; |
Steve French | 0cbaa53 | 2013-11-15 23:50:24 -0600 | [diff] [blame] | 147 | __le32 OriginalMessageSize; |
| 148 | __u16 Reserved1; |
Steve French | 373512e | 2015-12-18 13:05:30 -0600 | [diff] [blame] | 149 | __le16 Flags; /* EncryptionAlgorithm */ |
Steve French | 0cbaa53 | 2013-11-15 23:50:24 -0600 | [diff] [blame] | 150 | __u64 SessionId; |
| 151 | } __packed; |
| 152 | |
Pavel Shilovsky | 093b2bd | 2011-06-08 15:51:07 +0400 | [diff] [blame] | 153 | /* |
| 154 | * SMB2 flag definitions |
| 155 | */ |
Fabian Frederick | bc09d14 | 2014-12-10 15:41:15 -0800 | [diff] [blame] | 156 | #define SMB2_FLAGS_SERVER_TO_REDIR cpu_to_le32(0x00000001) |
| 157 | #define SMB2_FLAGS_ASYNC_COMMAND cpu_to_le32(0x00000002) |
| 158 | #define SMB2_FLAGS_RELATED_OPERATIONS cpu_to_le32(0x00000004) |
| 159 | #define SMB2_FLAGS_SIGNED cpu_to_le32(0x00000008) |
| 160 | #define SMB2_FLAGS_DFS_OPERATIONS cpu_to_le32(0x10000000) |
Pavel Shilovsky | 093b2bd | 2011-06-08 15:51:07 +0400 | [diff] [blame] | 161 | |
| 162 | /* |
| 163 | * Definitions for SMB2 Protocol Data Units (network frames) |
| 164 | * |
| 165 | * See MS-SMB2.PDF specification for protocol details. |
| 166 | * The Naming convention is the lower case version of the SMB2 |
| 167 | * command code name for the struct. Note that structures must be packed. |
| 168 | * |
| 169 | */ |
Pavel Shilovsky | 7411286 | 2012-07-27 01:20:41 +0400 | [diff] [blame] | 170 | |
Fabian Frederick | bc09d14 | 2014-12-10 15:41:15 -0800 | [diff] [blame] | 171 | #define SMB2_ERROR_STRUCTURE_SIZE2 cpu_to_le16(9) |
Pavel Shilovsky | 7411286 | 2012-07-27 01:20:41 +0400 | [diff] [blame] | 172 | |
Pavel Shilovsky | 093b2bd | 2011-06-08 15:51:07 +0400 | [diff] [blame] | 173 | struct smb2_err_rsp { |
| 174 | struct smb2_hdr hdr; |
| 175 | __le16 StructureSize; |
| 176 | __le16 Reserved; /* MBZ */ |
| 177 | __le32 ByteCount; /* even if zero, at least one byte follows */ |
| 178 | __u8 ErrorData[1]; /* variable length */ |
| 179 | } __packed; |
| 180 | |
Pavel Shilovsky | b42bf88 | 2013-08-14 19:25:21 +0400 | [diff] [blame] | 181 | struct smb2_symlink_err_rsp { |
| 182 | __le32 SymLinkLength; |
| 183 | __le32 SymLinkErrorTag; |
| 184 | __le32 ReparseTag; |
| 185 | __le16 ReparseDataLength; |
| 186 | __le16 UnparsedPathLength; |
| 187 | __le16 SubstituteNameOffset; |
| 188 | __le16 SubstituteNameLength; |
| 189 | __le16 PrintNameOffset; |
| 190 | __le16 PrintNameLength; |
| 191 | __le32 Flags; |
| 192 | __u8 PathBuffer[0]; |
| 193 | } __packed; |
| 194 | |
Pavel Shilovsky | b8c32db | 2012-09-19 06:22:44 -0700 | [diff] [blame] | 195 | #define SMB2_CLIENT_GUID_SIZE 16 |
| 196 | |
Pavel Shilovsky | ec2e452 | 2011-12-27 16:12:43 +0400 | [diff] [blame] | 197 | struct smb2_negotiate_req { |
| 198 | struct smb2_hdr hdr; |
| 199 | __le16 StructureSize; /* Must be 36 */ |
| 200 | __le16 DialectCount; |
| 201 | __le16 SecurityMode; |
| 202 | __le16 Reserved; /* MBZ */ |
| 203 | __le32 Capabilities; |
Pavel Shilovsky | b8c32db | 2012-09-19 06:22:44 -0700 | [diff] [blame] | 204 | __u8 ClientGUID[SMB2_CLIENT_GUID_SIZE]; |
Steve French | 5f7fbf7 | 2014-12-17 22:52:58 -0600 | [diff] [blame] | 205 | /* In SMB3.02 and earlier next three were MBZ le64 ClientStartTime */ |
| 206 | __le32 NegotiateContextOffset; /* SMB3.1.1 only. MBZ earlier */ |
| 207 | __le16 NegotiateContextCount; /* SMB3.1.1 only. MBZ earlier */ |
| 208 | __le16 Reserved2; |
Steve French | e4aa25e | 2012-10-01 12:26:22 -0500 | [diff] [blame] | 209 | __le16 Dialects[1]; /* One dialect (vers=) at a time for now */ |
Pavel Shilovsky | ec2e452 | 2011-12-27 16:12:43 +0400 | [diff] [blame] | 210 | } __packed; |
| 211 | |
Steve French | e4aa25e | 2012-10-01 12:26:22 -0500 | [diff] [blame] | 212 | /* Dialects */ |
| 213 | #define SMB20_PROT_ID 0x0202 |
| 214 | #define SMB21_PROT_ID 0x0210 |
| 215 | #define SMB30_PROT_ID 0x0300 |
Steve French | 20b6d8b | 2013-06-12 22:48:41 -0500 | [diff] [blame] | 216 | #define SMB302_PROT_ID 0x0302 |
Steve French | 5f7fbf7 | 2014-12-17 22:52:58 -0600 | [diff] [blame] | 217 | #define SMB311_PROT_ID 0x0311 |
Steve French | e4aa25e | 2012-10-01 12:26:22 -0500 | [diff] [blame] | 218 | #define BAD_PROT_ID 0xFFFF |
| 219 | |
Pavel Shilovsky | ec2e452 | 2011-12-27 16:12:43 +0400 | [diff] [blame] | 220 | /* SecurityMode flags */ |
| 221 | #define SMB2_NEGOTIATE_SIGNING_ENABLED 0x0001 |
| 222 | #define SMB2_NEGOTIATE_SIGNING_REQUIRED 0x0002 |
| 223 | /* Capabilities flags */ |
| 224 | #define SMB2_GLOBAL_CAP_DFS 0x00000001 |
| 225 | #define SMB2_GLOBAL_CAP_LEASING 0x00000002 /* Resp only New to SMB2.1 */ |
| 226 | #define SMB2_GLOBAL_CAP_LARGE_MTU 0X00000004 /* Resp only New to SMB2.1 */ |
Steve French | e4aa25e | 2012-10-01 12:26:22 -0500 | [diff] [blame] | 227 | #define SMB2_GLOBAL_CAP_MULTI_CHANNEL 0x00000008 /* New to SMB3 */ |
| 228 | #define SMB2_GLOBAL_CAP_PERSISTENT_HANDLES 0x00000010 /* New to SMB3 */ |
| 229 | #define SMB2_GLOBAL_CAP_DIRECTORY_LEASING 0x00000020 /* New to SMB3 */ |
| 230 | #define SMB2_GLOBAL_CAP_ENCRYPTION 0x00000040 /* New to SMB3 */ |
Pavel Shilovsky | 29e20f9 | 2012-07-13 13:58:14 +0400 | [diff] [blame] | 231 | /* Internal types */ |
| 232 | #define SMB2_NT_FIND 0x00100000 |
| 233 | #define SMB2_LARGE_FILES 0x00200000 |
Pavel Shilovsky | ec2e452 | 2011-12-27 16:12:43 +0400 | [diff] [blame] | 234 | |
Steve French | eed0e17 | 2015-02-06 00:03:52 -0600 | [diff] [blame] | 235 | #define SMB311_SALT_SIZE 32 |
| 236 | /* Hash Algorithm Types */ |
Steve French | ebb3a9d | 2015-06-18 04:49:47 -0500 | [diff] [blame] | 237 | #define SMB2_PREAUTH_INTEGRITY_SHA512 cpu_to_le16(0x0001) |
Steve French | eed0e17 | 2015-02-06 00:03:52 -0600 | [diff] [blame] | 238 | |
| 239 | struct smb2_preauth_neg_context { |
| 240 | __le16 ContextType; /* 1 */ |
| 241 | __le16 DataLength; |
| 242 | __le32 Reserved; |
| 243 | __le16 HashAlgorithmCount; /* 1 */ |
| 244 | __le16 SaltLength; |
| 245 | __le16 HashAlgorithms; /* HashAlgorithms[0] since only one defined */ |
| 246 | __u8 Salt[SMB311_SALT_SIZE]; |
| 247 | } __packed; |
| 248 | |
| 249 | /* Encryption Algorithms Ciphers */ |
| 250 | #define SMB2_ENCRYPTION_AES128_CCM cpu_to_le16(0x0001) |
| 251 | #define SMB2_ENCRYPTION_AES128_GCM cpu_to_le16(0x0002) |
| 252 | |
| 253 | struct smb2_encryption_neg_context { |
| 254 | __le16 ContextType; /* 2 */ |
| 255 | __le16 DataLength; |
| 256 | __le32 Reserved; |
Steve French | ebb3a9d | 2015-06-18 04:49:47 -0500 | [diff] [blame] | 257 | __le16 CipherCount; /* AES-128-GCM and AES-128-CCM */ |
| 258 | __le16 Ciphers[2]; /* Ciphers[0] since only one used now */ |
Steve French | eed0e17 | 2015-02-06 00:03:52 -0600 | [diff] [blame] | 259 | } __packed; |
| 260 | |
Pavel Shilovsky | ec2e452 | 2011-12-27 16:12:43 +0400 | [diff] [blame] | 261 | struct smb2_negotiate_rsp { |
| 262 | struct smb2_hdr hdr; |
| 263 | __le16 StructureSize; /* Must be 65 */ |
| 264 | __le16 SecurityMode; |
| 265 | __le16 DialectRevision; |
Steve French | 5f7fbf7 | 2014-12-17 22:52:58 -0600 | [diff] [blame] | 266 | __le16 NegotiateContextCount; /* Prior to SMB3.1.1 was Reserved & MBZ */ |
Pavel Shilovsky | ec2e452 | 2011-12-27 16:12:43 +0400 | [diff] [blame] | 267 | __u8 ServerGUID[16]; |
| 268 | __le32 Capabilities; |
| 269 | __le32 MaxTransactSize; |
| 270 | __le32 MaxReadSize; |
| 271 | __le32 MaxWriteSize; |
| 272 | __le64 SystemTime; /* MBZ */ |
| 273 | __le64 ServerStartTime; |
| 274 | __le16 SecurityBufferOffset; |
| 275 | __le16 SecurityBufferLength; |
Steve French | 5f7fbf7 | 2014-12-17 22:52:58 -0600 | [diff] [blame] | 276 | __le32 NegotiateContextOffset; /* Pre:SMB3.1.1 was reserved/ignored */ |
Pavel Shilovsky | ec2e452 | 2011-12-27 16:12:43 +0400 | [diff] [blame] | 277 | __u8 Buffer[1]; /* variable length GSS security buffer */ |
| 278 | } __packed; |
| 279 | |
Steve French | eed0e17 | 2015-02-06 00:03:52 -0600 | [diff] [blame] | 280 | /* Flags */ |
| 281 | #define SMB2_SESSION_REQ_FLAG_BINDING 0x01 |
| 282 | #define SMB2_SESSION_REQ_FLAG_ENCRYPT_DATA 0x04 |
| 283 | |
Pavel Shilovsky | 5478f9b | 2011-12-27 16:22:00 +0400 | [diff] [blame] | 284 | struct smb2_sess_setup_req { |
| 285 | struct smb2_hdr hdr; |
| 286 | __le16 StructureSize; /* Must be 25 */ |
Steve French | eed0e17 | 2015-02-06 00:03:52 -0600 | [diff] [blame] | 287 | __u8 Flags; |
Pavel Shilovsky | 5478f9b | 2011-12-27 16:22:00 +0400 | [diff] [blame] | 288 | __u8 SecurityMode; |
| 289 | __le32 Capabilities; |
| 290 | __le32 Channel; |
| 291 | __le16 SecurityBufferOffset; |
| 292 | __le16 SecurityBufferLength; |
Steve French | c2afb81 | 2016-09-20 22:56:13 -0500 | [diff] [blame] | 293 | __u64 PreviousSessionId; |
Pavel Shilovsky | 5478f9b | 2011-12-27 16:22:00 +0400 | [diff] [blame] | 294 | __u8 Buffer[1]; /* variable length GSS security buffer */ |
| 295 | } __packed; |
| 296 | |
| 297 | /* Currently defined SessionFlags */ |
| 298 | #define SMB2_SESSION_FLAG_IS_GUEST 0x0001 |
| 299 | #define SMB2_SESSION_FLAG_IS_NULL 0x0002 |
Steve French | 0cbaa53 | 2013-11-15 23:50:24 -0600 | [diff] [blame] | 300 | #define SMB2_SESSION_FLAG_ENCRYPT_DATA 0x0004 |
Pavel Shilovsky | 5478f9b | 2011-12-27 16:22:00 +0400 | [diff] [blame] | 301 | struct smb2_sess_setup_rsp { |
| 302 | struct smb2_hdr hdr; |
| 303 | __le16 StructureSize; /* Must be 9 */ |
| 304 | __le16 SessionFlags; |
| 305 | __le16 SecurityBufferOffset; |
| 306 | __le16 SecurityBufferLength; |
| 307 | __u8 Buffer[1]; /* variable length GSS security buffer */ |
| 308 | } __packed; |
| 309 | |
| 310 | struct smb2_logoff_req { |
| 311 | struct smb2_hdr hdr; |
| 312 | __le16 StructureSize; /* Must be 4 */ |
| 313 | __le16 Reserved; |
| 314 | } __packed; |
| 315 | |
| 316 | struct smb2_logoff_rsp { |
| 317 | struct smb2_hdr hdr; |
| 318 | __le16 StructureSize; /* Must be 4 */ |
| 319 | __le16 Reserved; |
| 320 | } __packed; |
| 321 | |
Steve French | eed0e17 | 2015-02-06 00:03:52 -0600 | [diff] [blame] | 322 | /* Flags/Reserved for SMB3.1.1 */ |
| 323 | #define SMB2_SHAREFLAG_CLUSTER_RECONNECT 0x0001 |
| 324 | |
Pavel Shilovsky | faaf946 | 2011-12-27 16:04:00 +0400 | [diff] [blame] | 325 | struct smb2_tree_connect_req { |
| 326 | struct smb2_hdr hdr; |
| 327 | __le16 StructureSize; /* Must be 9 */ |
Steve French | eed0e17 | 2015-02-06 00:03:52 -0600 | [diff] [blame] | 328 | __le16 Reserved; /* Flags in SMB3.1.1 */ |
Pavel Shilovsky | faaf946 | 2011-12-27 16:04:00 +0400 | [diff] [blame] | 329 | __le16 PathOffset; |
| 330 | __le16 PathLength; |
| 331 | __u8 Buffer[1]; /* variable length */ |
| 332 | } __packed; |
| 333 | |
| 334 | struct smb2_tree_connect_rsp { |
| 335 | struct smb2_hdr hdr; |
| 336 | __le16 StructureSize; /* Must be 16 */ |
| 337 | __u8 ShareType; /* see below */ |
| 338 | __u8 Reserved; |
| 339 | __le32 ShareFlags; /* see below */ |
| 340 | __le32 Capabilities; /* see below */ |
| 341 | __le32 MaximalAccess; |
| 342 | } __packed; |
| 343 | |
| 344 | /* Possible ShareType values */ |
| 345 | #define SMB2_SHARE_TYPE_DISK 0x01 |
| 346 | #define SMB2_SHARE_TYPE_PIPE 0x02 |
| 347 | #define SMB2_SHARE_TYPE_PRINT 0x03 |
| 348 | |
| 349 | /* |
| 350 | * Possible ShareFlags - exactly one and only one of the first 4 caching flags |
| 351 | * must be set (any of the remaining, SHI1005, flags may be set individually |
| 352 | * or in combination. |
| 353 | */ |
| 354 | #define SMB2_SHAREFLAG_MANUAL_CACHING 0x00000000 |
| 355 | #define SMB2_SHAREFLAG_AUTO_CACHING 0x00000010 |
| 356 | #define SMB2_SHAREFLAG_VDO_CACHING 0x00000020 |
| 357 | #define SMB2_SHAREFLAG_NO_CACHING 0x00000030 |
| 358 | #define SHI1005_FLAGS_DFS 0x00000001 |
| 359 | #define SHI1005_FLAGS_DFS_ROOT 0x00000002 |
| 360 | #define SHI1005_FLAGS_RESTRICT_EXCLUSIVE_OPENS 0x00000100 |
| 361 | #define SHI1005_FLAGS_FORCE_SHARED_DELETE 0x00000200 |
| 362 | #define SHI1005_FLAGS_ALLOW_NAMESPACE_CACHING 0x00000400 |
| 363 | #define SHI1005_FLAGS_ACCESS_BASED_DIRECTORY_ENUM 0x00000800 |
| 364 | #define SHI1005_FLAGS_FORCE_LEVELII_OPLOCK 0x00001000 |
Steve French | c866473 | 2013-06-21 15:35:45 -0500 | [diff] [blame] | 365 | #define SHI1005_FLAGS_ENABLE_HASH_V1 0x00002000 |
| 366 | #define SHI1005_FLAGS_ENABLE_HASH_V2 0x00004000 |
| 367 | #define SHI1005_FLAGS_ENCRYPT_DATA 0x00008000 |
| 368 | #define SHI1005_FLAGS_ALL 0x0000FF33 |
Pavel Shilovsky | faaf946 | 2011-12-27 16:04:00 +0400 | [diff] [blame] | 369 | |
| 370 | /* Possible share capabilities */ |
Steve French | 2b5dc28 | 2013-06-13 10:51:10 -0500 | [diff] [blame] | 371 | #define SMB2_SHARE_CAP_DFS cpu_to_le32(0x00000008) /* all dialects */ |
| 372 | #define SMB2_SHARE_CAP_CONTINUOUS_AVAILABILITY cpu_to_le32(0x00000010) /* 3.0 */ |
| 373 | #define SMB2_SHARE_CAP_SCALEOUT cpu_to_le32(0x00000020) /* 3.0 */ |
| 374 | #define SMB2_SHARE_CAP_CLUSTER cpu_to_le32(0x00000040) /* 3.0 */ |
| 375 | #define SMB2_SHARE_CAP_ASYMMETRIC cpu_to_le32(0x00000080) /* 3.02 */ |
Pavel Shilovsky | faaf946 | 2011-12-27 16:04:00 +0400 | [diff] [blame] | 376 | |
| 377 | struct smb2_tree_disconnect_req { |
| 378 | struct smb2_hdr hdr; |
| 379 | __le16 StructureSize; /* Must be 4 */ |
| 380 | __le16 Reserved; |
| 381 | } __packed; |
| 382 | |
| 383 | struct smb2_tree_disconnect_rsp { |
| 384 | struct smb2_hdr hdr; |
| 385 | __le16 StructureSize; /* Must be 4 */ |
| 386 | __le16 Reserved; |
| 387 | } __packed; |
| 388 | |
Pavel Shilovsky | 2503a0d | 2011-12-26 22:58:46 +0400 | [diff] [blame] | 389 | /* File Attrubutes */ |
| 390 | #define FILE_ATTRIBUTE_READONLY 0x00000001 |
| 391 | #define FILE_ATTRIBUTE_HIDDEN 0x00000002 |
| 392 | #define FILE_ATTRIBUTE_SYSTEM 0x00000004 |
| 393 | #define FILE_ATTRIBUTE_DIRECTORY 0x00000010 |
| 394 | #define FILE_ATTRIBUTE_ARCHIVE 0x00000020 |
| 395 | #define FILE_ATTRIBUTE_NORMAL 0x00000080 |
| 396 | #define FILE_ATTRIBUTE_TEMPORARY 0x00000100 |
| 397 | #define FILE_ATTRIBUTE_SPARSE_FILE 0x00000200 |
| 398 | #define FILE_ATTRIBUTE_REPARSE_POINT 0x00000400 |
| 399 | #define FILE_ATTRIBUTE_COMPRESSED 0x00000800 |
| 400 | #define FILE_ATTRIBUTE_OFFLINE 0x00001000 |
| 401 | #define FILE_ATTRIBUTE_NOT_CONTENT_INDEXED 0x00002000 |
| 402 | #define FILE_ATTRIBUTE_ENCRYPTED 0x00004000 |
Steve French | 7332297 | 2014-09-23 19:25:42 -0500 | [diff] [blame] | 403 | #define FILE_ATTRIBUTE_INTEGRITY_STREAM 0x00008000 |
| 404 | #define FILE_ATTRIBUTE_NO_SCRUB_DATA 0x00020000 |
Pavel Shilovsky | 2503a0d | 2011-12-26 22:58:46 +0400 | [diff] [blame] | 405 | |
| 406 | /* Oplock levels */ |
| 407 | #define SMB2_OPLOCK_LEVEL_NONE 0x00 |
| 408 | #define SMB2_OPLOCK_LEVEL_II 0x01 |
| 409 | #define SMB2_OPLOCK_LEVEL_EXCLUSIVE 0x08 |
| 410 | #define SMB2_OPLOCK_LEVEL_BATCH 0x09 |
| 411 | #define SMB2_OPLOCK_LEVEL_LEASE 0xFF |
Pavel Shilovsky | b8c32db | 2012-09-19 06:22:44 -0700 | [diff] [blame] | 412 | /* Non-spec internal type */ |
| 413 | #define SMB2_OPLOCK_LEVEL_NOCHANGE 0x99 |
Pavel Shilovsky | 2503a0d | 2011-12-26 22:58:46 +0400 | [diff] [blame] | 414 | |
| 415 | /* Desired Access Flags */ |
| 416 | #define FILE_READ_DATA_LE cpu_to_le32(0x00000001) |
| 417 | #define FILE_WRITE_DATA_LE cpu_to_le32(0x00000002) |
| 418 | #define FILE_APPEND_DATA_LE cpu_to_le32(0x00000004) |
| 419 | #define FILE_READ_EA_LE cpu_to_le32(0x00000008) |
| 420 | #define FILE_WRITE_EA_LE cpu_to_le32(0x00000010) |
| 421 | #define FILE_EXECUTE_LE cpu_to_le32(0x00000020) |
| 422 | #define FILE_READ_ATTRIBUTES_LE cpu_to_le32(0x00000080) |
| 423 | #define FILE_WRITE_ATTRIBUTES_LE cpu_to_le32(0x00000100) |
| 424 | #define FILE_DELETE_LE cpu_to_le32(0x00010000) |
| 425 | #define FILE_READ_CONTROL_LE cpu_to_le32(0x00020000) |
| 426 | #define FILE_WRITE_DAC_LE cpu_to_le32(0x00040000) |
| 427 | #define FILE_WRITE_OWNER_LE cpu_to_le32(0x00080000) |
| 428 | #define FILE_SYNCHRONIZE_LE cpu_to_le32(0x00100000) |
| 429 | #define FILE_ACCESS_SYSTEM_SECURITY_LE cpu_to_le32(0x01000000) |
| 430 | #define FILE_MAXIMAL_ACCESS_LE cpu_to_le32(0x02000000) |
| 431 | #define FILE_GENERIC_ALL_LE cpu_to_le32(0x10000000) |
| 432 | #define FILE_GENERIC_EXECUTE_LE cpu_to_le32(0x20000000) |
| 433 | #define FILE_GENERIC_WRITE_LE cpu_to_le32(0x40000000) |
| 434 | #define FILE_GENERIC_READ_LE cpu_to_le32(0x80000000) |
| 435 | |
| 436 | /* ShareAccess Flags */ |
| 437 | #define FILE_SHARE_READ_LE cpu_to_le32(0x00000001) |
| 438 | #define FILE_SHARE_WRITE_LE cpu_to_le32(0x00000002) |
| 439 | #define FILE_SHARE_DELETE_LE cpu_to_le32(0x00000004) |
| 440 | #define FILE_SHARE_ALL_LE cpu_to_le32(0x00000007) |
| 441 | |
| 442 | /* CreateDisposition Flags */ |
| 443 | #define FILE_SUPERSEDE_LE cpu_to_le32(0x00000000) |
| 444 | #define FILE_OPEN_LE cpu_to_le32(0x00000001) |
| 445 | #define FILE_CREATE_LE cpu_to_le32(0x00000002) |
| 446 | #define FILE_OPEN_IF_LE cpu_to_le32(0x00000003) |
| 447 | #define FILE_OVERWRITE_LE cpu_to_le32(0x00000004) |
| 448 | #define FILE_OVERWRITE_IF_LE cpu_to_le32(0x00000005) |
| 449 | |
| 450 | /* CreateOptions Flags */ |
| 451 | #define FILE_DIRECTORY_FILE_LE cpu_to_le32(0x00000001) |
| 452 | /* same as #define CREATE_NOT_FILE_LE cpu_to_le32(0x00000001) */ |
| 453 | #define FILE_WRITE_THROUGH_LE cpu_to_le32(0x00000002) |
| 454 | #define FILE_SEQUENTIAL_ONLY_LE cpu_to_le32(0x00000004) |
| 455 | #define FILE_NO_INTERMEDIATE_BUFFERRING_LE cpu_to_le32(0x00000008) |
| 456 | #define FILE_SYNCHRONOUS_IO_ALERT_LE cpu_to_le32(0x00000010) |
| 457 | #define FILE_SYNCHRONOUS_IO_NON_ALERT_LE cpu_to_le32(0x00000020) |
| 458 | #define FILE_NON_DIRECTORY_FILE_LE cpu_to_le32(0x00000040) |
| 459 | #define FILE_COMPLETE_IF_OPLOCKED_LE cpu_to_le32(0x00000100) |
| 460 | #define FILE_NO_EA_KNOWLEDGE_LE cpu_to_le32(0x00000200) |
| 461 | #define FILE_RANDOM_ACCESS_LE cpu_to_le32(0x00000800) |
| 462 | #define FILE_DELETE_ON_CLOSE_LE cpu_to_le32(0x00001000) |
| 463 | #define FILE_OPEN_BY_FILE_ID_LE cpu_to_le32(0x00002000) |
| 464 | #define FILE_OPEN_FOR_BACKUP_INTENT_LE cpu_to_le32(0x00004000) |
| 465 | #define FILE_NO_COMPRESSION_LE cpu_to_le32(0x00008000) |
| 466 | #define FILE_RESERVE_OPFILTER_LE cpu_to_le32(0x00100000) |
| 467 | #define FILE_OPEN_REPARSE_POINT_LE cpu_to_le32(0x00200000) |
| 468 | #define FILE_OPEN_NO_RECALL_LE cpu_to_le32(0x00400000) |
| 469 | #define FILE_OPEN_FOR_FREE_SPACE_QUERY_LE cpu_to_le32(0x00800000) |
| 470 | |
| 471 | #define FILE_READ_RIGHTS_LE (FILE_READ_DATA_LE | FILE_READ_EA_LE \ |
| 472 | | FILE_READ_ATTRIBUTES_LE) |
| 473 | #define FILE_WRITE_RIGHTS_LE (FILE_WRITE_DATA_LE | FILE_APPEND_DATA_LE \ |
| 474 | | FILE_WRITE_EA_LE | FILE_WRITE_ATTRIBUTES_LE) |
| 475 | #define FILE_EXEC_RIGHTS_LE (FILE_EXECUTE_LE) |
| 476 | |
| 477 | /* Impersonation Levels */ |
| 478 | #define IL_ANONYMOUS cpu_to_le32(0x00000000) |
| 479 | #define IL_IDENTIFICATION cpu_to_le32(0x00000001) |
| 480 | #define IL_IMPERSONATION cpu_to_le32(0x00000002) |
| 481 | #define IL_DELEGATE cpu_to_le32(0x00000003) |
| 482 | |
| 483 | /* Create Context Values */ |
| 484 | #define SMB2_CREATE_EA_BUFFER "ExtA" /* extended attributes */ |
| 485 | #define SMB2_CREATE_SD_BUFFER "SecD" /* security descriptor */ |
| 486 | #define SMB2_CREATE_DURABLE_HANDLE_REQUEST "DHnQ" |
| 487 | #define SMB2_CREATE_DURABLE_HANDLE_RECONNECT "DHnC" |
Steve French | 12197a7 | 2014-05-14 05:29:40 -0700 | [diff] [blame] | 488 | #define SMB2_CREATE_ALLOCATION_SIZE "AISi" |
Pavel Shilovsky | 2503a0d | 2011-12-26 22:58:46 +0400 | [diff] [blame] | 489 | #define SMB2_CREATE_QUERY_MAXIMAL_ACCESS_REQUEST "MxAc" |
| 490 | #define SMB2_CREATE_TIMEWARP_REQUEST "TWrp" |
| 491 | #define SMB2_CREATE_QUERY_ON_DISK_ID "QFid" |
| 492 | #define SMB2_CREATE_REQUEST_LEASE "RqLs" |
Steve French | 12197a7 | 2014-05-14 05:29:40 -0700 | [diff] [blame] | 493 | #define SMB2_CREATE_DURABLE_HANDLE_REQUEST_V2 "DH2Q" |
| 494 | #define SMB2_CREATE_DURABLE_HANDLE_RECONNECT_V2 "DH2C" |
| 495 | #define SMB2_CREATE_APP_INSTANCE_ID 0x45BCA66AEFA7F74A9008FA462E144D74 |
| 496 | #define SVHDX_OPEN_DEVICE_CONTEXT 0x83CE6F1AD851E0986E34401CC9BCFCE9 |
Pavel Shilovsky | 2503a0d | 2011-12-26 22:58:46 +0400 | [diff] [blame] | 497 | |
| 498 | struct smb2_create_req { |
| 499 | struct smb2_hdr hdr; |
| 500 | __le16 StructureSize; /* Must be 57 */ |
| 501 | __u8 SecurityFlags; |
| 502 | __u8 RequestedOplockLevel; |
| 503 | __le32 ImpersonationLevel; |
| 504 | __le64 SmbCreateFlags; |
| 505 | __le64 Reserved; |
| 506 | __le32 DesiredAccess; |
| 507 | __le32 FileAttributes; |
| 508 | __le32 ShareAccess; |
| 509 | __le32 CreateDisposition; |
| 510 | __le32 CreateOptions; |
| 511 | __le16 NameOffset; |
| 512 | __le16 NameLength; |
| 513 | __le32 CreateContextsOffset; |
| 514 | __le32 CreateContextsLength; |
Pavel Shilovsky | 59aa371 | 2013-07-04 19:41:24 +0400 | [diff] [blame] | 515 | __u8 Buffer[0]; |
Pavel Shilovsky | 2503a0d | 2011-12-26 22:58:46 +0400 | [diff] [blame] | 516 | } __packed; |
| 517 | |
| 518 | struct smb2_create_rsp { |
| 519 | struct smb2_hdr hdr; |
| 520 | __le16 StructureSize; /* Must be 89 */ |
| 521 | __u8 OplockLevel; |
| 522 | __u8 Reserved; |
| 523 | __le32 CreateAction; |
| 524 | __le64 CreationTime; |
| 525 | __le64 LastAccessTime; |
| 526 | __le64 LastWriteTime; |
| 527 | __le64 ChangeTime; |
| 528 | __le64 AllocationSize; |
| 529 | __le64 EndofFile; |
| 530 | __le32 FileAttributes; |
| 531 | __le32 Reserved2; |
| 532 | __u64 PersistentFileId; /* opaque endianness */ |
| 533 | __u64 VolatileFileId; /* opaque endianness */ |
| 534 | __le32 CreateContextsOffset; |
| 535 | __le32 CreateContextsLength; |
| 536 | __u8 Buffer[1]; |
| 537 | } __packed; |
| 538 | |
Pavel Shilovsky | b8c32db | 2012-09-19 06:22:44 -0700 | [diff] [blame] | 539 | struct create_context { |
| 540 | __le32 Next; |
| 541 | __le16 NameOffset; |
| 542 | __le16 NameLength; |
| 543 | __le16 Reserved; |
| 544 | __le16 DataOffset; |
| 545 | __le32 DataLength; |
| 546 | __u8 Buffer[0]; |
| 547 | } __packed; |
| 548 | |
Pavel Shilovsky | 53ef101 | 2013-09-05 16:11:28 +0400 | [diff] [blame] | 549 | #define SMB2_LEASE_READ_CACHING_HE 0x01 |
| 550 | #define SMB2_LEASE_HANDLE_CACHING_HE 0x02 |
| 551 | #define SMB2_LEASE_WRITE_CACHING_HE 0x04 |
| 552 | |
Fabian Frederick | bc09d14 | 2014-12-10 15:41:15 -0800 | [diff] [blame] | 553 | #define SMB2_LEASE_NONE cpu_to_le32(0x00) |
| 554 | #define SMB2_LEASE_READ_CACHING cpu_to_le32(0x01) |
| 555 | #define SMB2_LEASE_HANDLE_CACHING cpu_to_le32(0x02) |
| 556 | #define SMB2_LEASE_WRITE_CACHING cpu_to_le32(0x04) |
Pavel Shilovsky | b8c32db | 2012-09-19 06:22:44 -0700 | [diff] [blame] | 557 | |
Fabian Frederick | bc09d14 | 2014-12-10 15:41:15 -0800 | [diff] [blame] | 558 | #define SMB2_LEASE_FLAG_BREAK_IN_PROGRESS cpu_to_le32(0x02) |
Pavel Shilovsky | b8c32db | 2012-09-19 06:22:44 -0700 | [diff] [blame] | 559 | |
| 560 | #define SMB2_LEASE_KEY_SIZE 16 |
| 561 | |
| 562 | struct lease_context { |
| 563 | __le64 LeaseKeyLow; |
| 564 | __le64 LeaseKeyHigh; |
| 565 | __le32 LeaseState; |
| 566 | __le32 LeaseFlags; |
| 567 | __le64 LeaseDuration; |
| 568 | } __packed; |
| 569 | |
Pavel Shilovsky | f047390 | 2013-09-04 13:44:05 +0400 | [diff] [blame] | 570 | struct lease_context_v2 { |
| 571 | __le64 LeaseKeyLow; |
| 572 | __le64 LeaseKeyHigh; |
| 573 | __le32 LeaseState; |
| 574 | __le32 LeaseFlags; |
| 575 | __le64 LeaseDuration; |
| 576 | __le64 ParentLeaseKeyLow; |
| 577 | __le64 ParentLeaseKeyHigh; |
| 578 | __le16 Epoch; |
| 579 | __le16 Reserved; |
| 580 | } __packed; |
| 581 | |
Pavel Shilovsky | b8c32db | 2012-09-19 06:22:44 -0700 | [diff] [blame] | 582 | struct create_lease { |
| 583 | struct create_context ccontext; |
| 584 | __u8 Name[8]; |
| 585 | struct lease_context lcontext; |
| 586 | } __packed; |
| 587 | |
Pavel Shilovsky | f047390 | 2013-09-04 13:44:05 +0400 | [diff] [blame] | 588 | struct create_lease_v2 { |
| 589 | struct create_context ccontext; |
| 590 | __u8 Name[8]; |
| 591 | struct lease_context_v2 lcontext; |
| 592 | __u8 Pad[4]; |
| 593 | } __packed; |
| 594 | |
Pavel Shilovsky | 63eb3de | 2013-07-04 18:41:09 +0400 | [diff] [blame] | 595 | struct create_durable { |
| 596 | struct create_context ccontext; |
| 597 | __u8 Name[8]; |
Pavel Shilovsky | 9cbc0b7 | 2013-07-09 18:40:58 +0400 | [diff] [blame] | 598 | union { |
| 599 | __u8 Reserved[16]; |
| 600 | struct { |
| 601 | __u64 PersistentFileId; |
| 602 | __u64 VolatileFileId; |
| 603 | } Fid; |
| 604 | } Data; |
Pavel Shilovsky | 63eb3de | 2013-07-04 18:41:09 +0400 | [diff] [blame] | 605 | } __packed; |
| 606 | |
Steve French | b56eae4 | 2015-11-03 09:26:27 -0600 | [diff] [blame] | 607 | /* See MS-SMB2 2.2.13.2.11 */ |
| 608 | /* Flags */ |
| 609 | #define SMB2_DHANDLE_FLAG_PERSISTENT 0x00000002 |
| 610 | struct durable_context_v2 { |
| 611 | __le32 Timeout; |
| 612 | __le32 Flags; |
| 613 | __u64 Reserved; |
| 614 | __u8 CreateGuid[16]; |
| 615 | } __packed; |
| 616 | |
| 617 | struct create_durable_v2 { |
| 618 | struct create_context ccontext; |
| 619 | __u8 Name[8]; |
| 620 | struct durable_context_v2 dcontext; |
| 621 | } __packed; |
| 622 | |
| 623 | /* See MS-SMB2 2.2.13.2.12 */ |
| 624 | struct durable_reconnect_context_v2 { |
| 625 | struct { |
| 626 | __u64 PersistentFileId; |
| 627 | __u64 VolatileFileId; |
| 628 | } Fid; |
| 629 | __u8 CreateGuid[16]; |
| 630 | __le32 Flags; /* see above DHANDLE_FLAG_PERSISTENT */ |
| 631 | } __packed; |
| 632 | |
| 633 | /* See MS-SMB2 2.2.14.2.12 */ |
| 634 | struct durable_reconnect_context_v2_rsp { |
| 635 | __le32 Timeout; |
| 636 | __le32 Flags; /* see above DHANDLE_FLAG_PERSISTENT */ |
| 637 | } __packed; |
| 638 | |
| 639 | struct create_durable_handle_reconnect_v2 { |
| 640 | struct create_context ccontext; |
| 641 | __u8 Name[8]; |
| 642 | struct durable_reconnect_context_v2 dcontext; |
| 643 | } __packed; |
| 644 | |
Steve French | 41c1358 | 2013-11-14 00:05:36 -0600 | [diff] [blame] | 645 | #define COPY_CHUNK_RES_KEY_SIZE 24 |
| 646 | struct resume_key_req { |
| 647 | char ResumeKey[COPY_CHUNK_RES_KEY_SIZE]; |
| 648 | __le32 ContextLength; /* MBZ */ |
| 649 | char Context[0]; /* ignored, Windows sets to 4 bytes of zero */ |
| 650 | } __packed; |
| 651 | |
Steve French | be7457d | 2013-06-19 17:41:10 -0500 | [diff] [blame] | 652 | /* this goes in the ioctl buffer when doing a copychunk request */ |
| 653 | struct copychunk_ioctl { |
Steve French | 41c1358 | 2013-11-14 00:05:36 -0600 | [diff] [blame] | 654 | char SourceKey[COPY_CHUNK_RES_KEY_SIZE]; |
Steve French | be7457d | 2013-06-19 17:41:10 -0500 | [diff] [blame] | 655 | __le32 ChunkCount; /* we are only sending 1 */ |
| 656 | __le32 Reserved; |
| 657 | /* array will only be one chunk long for us */ |
| 658 | __le64 SourceOffset; |
| 659 | __le64 TargetOffset; |
Steve French | c866473 | 2013-06-21 15:35:45 -0500 | [diff] [blame] | 660 | __le32 Length; /* how many bytes to copy */ |
Steve French | be7457d | 2013-06-19 17:41:10 -0500 | [diff] [blame] | 661 | __u32 Reserved2; |
| 662 | } __packed; |
| 663 | |
Steve French | 31742c5 | 2014-08-17 08:38:47 -0500 | [diff] [blame] | 664 | /* this goes in the ioctl buffer when doing FSCTL_SET_ZERO_DATA */ |
| 665 | struct file_zero_data_information { |
| 666 | __le64 FileOffset; |
| 667 | __le64 BeyondFinalZero; |
| 668 | } __packed; |
| 669 | |
Steve French | 41c1358 | 2013-11-14 00:05:36 -0600 | [diff] [blame] | 670 | struct copychunk_ioctl_rsp { |
| 671 | __le32 ChunksWritten; |
| 672 | __le32 ChunkBytesWritten; |
| 673 | __le32 TotalBytesWritten; |
| 674 | } __packed; |
| 675 | |
Steve French | 9d1b066 | 2015-06-24 02:12:19 -0500 | [diff] [blame] | 676 | struct fsctl_set_integrity_information_req { |
| 677 | __le16 ChecksumAlgorithm; |
| 678 | __le16 Reserved; |
| 679 | __le32 Flags; |
| 680 | } __packed; |
| 681 | |
| 682 | struct fsctl_get_integrity_information_rsp { |
| 683 | __le16 ChecksumAlgorithm; |
| 684 | __le16 Reserved; |
| 685 | __le32 Flags; |
| 686 | __le32 ChecksumChunkSizeInBytes; |
| 687 | __le32 ClusterSizeInBytes; |
| 688 | } __packed; |
| 689 | |
| 690 | /* Integrity ChecksumAlgorithm choices for above */ |
| 691 | #define CHECKSUM_TYPE_NONE 0x0000 |
| 692 | #define CHECKSUM_TYPE_CRC64 0x0002 |
Steve French | b3152e2 | 2015-06-24 03:17:02 -0500 | [diff] [blame] | 693 | #define CHECKSUM_TYPE_UNCHANGED 0xFFFF /* set only */ |
Steve French | 9d1b066 | 2015-06-24 02:12:19 -0500 | [diff] [blame] | 694 | |
| 695 | /* Integrity flags for above */ |
| 696 | #define FSCTL_INTEGRITY_FLAG_CHECKSUM_ENFORCEMENT_OFF 0x00000001 |
| 697 | |
Aurelien Aptel | 9d49640 | 2017-02-13 16:16:49 +0100 | [diff] [blame] | 698 | /* See MS-DFSC 2.2.2 */ |
| 699 | struct fsctl_get_dfs_referral_req { |
| 700 | __le16 MaxReferralLevel; |
| 701 | __u8 RequestFileName[]; |
| 702 | } __packed; |
| 703 | |
| 704 | /* DFS response is struct get_dfs_refer_rsp */ |
| 705 | |
Steve French | b56eae4 | 2015-11-03 09:26:27 -0600 | [diff] [blame] | 706 | /* See MS-SMB2 2.2.31.3 */ |
| 707 | struct network_resiliency_req { |
| 708 | __le32 Timeout; |
| 709 | __le32 Reserved; |
| 710 | } __packed; |
| 711 | /* There is no buffer for the response ie no struct network_resiliency_rsp */ |
| 712 | |
Steve French | 9d1b066 | 2015-06-24 02:12:19 -0500 | [diff] [blame] | 713 | |
Steve French | ff1c038 | 2013-11-19 23:44:46 -0600 | [diff] [blame] | 714 | struct validate_negotiate_info_req { |
Steve French | 4a72daf | 2013-06-25 00:20:49 -0500 | [diff] [blame] | 715 | __le32 Capabilities; |
| 716 | __u8 Guid[SMB2_CLIENT_GUID_SIZE]; |
| 717 | __le16 SecurityMode; |
| 718 | __le16 DialectCount; |
Steve French | 9764c02 | 2017-09-17 10:41:35 -0500 | [diff] [blame] | 719 | __le16 Dialects[3]; /* BB expand this if autonegotiate > 3 dialects */ |
Steve French | ff1c038 | 2013-11-19 23:44:46 -0600 | [diff] [blame] | 720 | } __packed; |
| 721 | |
| 722 | struct validate_negotiate_info_rsp { |
| 723 | __le32 Capabilities; |
| 724 | __u8 Guid[SMB2_CLIENT_GUID_SIZE]; |
| 725 | __le16 SecurityMode; |
| 726 | __le16 Dialect; /* Dialect in use for the connection */ |
Steve French | 4a72daf | 2013-06-25 00:20:49 -0500 | [diff] [blame] | 727 | } __packed; |
| 728 | |
| 729 | #define RSS_CAPABLE 0x00000001 |
| 730 | #define RDMA_CAPABLE 0x00000002 |
| 731 | |
| 732 | struct network_interface_info_ioctl_rsp { |
| 733 | __le32 Next; /* next interface. zero if this is last one */ |
| 734 | __le32 IfIndex; |
| 735 | __le32 Capability; /* RSS or RDMA Capable */ |
| 736 | __le32 Reserved; |
| 737 | __le64 LinkSpeed; |
| 738 | char SockAddr_Storage[128]; |
| 739 | } __packed; |
| 740 | |
| 741 | #define NO_FILE_ID 0xFFFFFFFFFFFFFFFFULL /* general ioctls to srv not to file */ |
| 742 | |
Steve French | 64a5cfa | 2013-10-14 15:31:32 -0500 | [diff] [blame] | 743 | struct compress_ioctl { |
Steve French | c7f508a | 2013-10-14 15:27:32 -0500 | [diff] [blame] | 744 | __le16 CompressionState; /* See cifspdu.h for possible flag values */ |
Steve French | 64a5cfa | 2013-10-14 15:31:32 -0500 | [diff] [blame] | 745 | } __packed; |
| 746 | |
Steve French | 02b1666 | 2015-06-27 21:18:36 -0700 | [diff] [blame] | 747 | struct duplicate_extents_to_file { |
| 748 | __u64 PersistentFileHandle; /* source file handle, opaque endianness */ |
| 749 | __u64 VolatileFileHandle; |
| 750 | __le64 SourceFileOffset; |
| 751 | __le64 TargetFileOffset; |
| 752 | __le64 ByteCount; /* Bytes to be copied */ |
| 753 | } __packed; |
| 754 | |
Steve French | be7457d | 2013-06-19 17:41:10 -0500 | [diff] [blame] | 755 | struct smb2_ioctl_req { |
| 756 | struct smb2_hdr hdr; |
| 757 | __le16 StructureSize; /* Must be 57 */ |
| 758 | __u16 Reserved; |
| 759 | __le32 CtlCode; |
| 760 | __u64 PersistentFileId; /* opaque endianness */ |
| 761 | __u64 VolatileFileId; /* opaque endianness */ |
| 762 | __le32 InputOffset; |
| 763 | __le32 InputCount; |
| 764 | __le32 MaxInputResponse; |
| 765 | __le32 OutputOffset; |
| 766 | __le32 OutputCount; |
| 767 | __le32 MaxOutputResponse; |
| 768 | __le32 Flags; |
| 769 | __u32 Reserved2; |
Steve French | 64a5cfa | 2013-10-14 15:31:32 -0500 | [diff] [blame] | 770 | __u8 Buffer[0]; |
Steve French | be7457d | 2013-06-19 17:41:10 -0500 | [diff] [blame] | 771 | } __packed; |
| 772 | |
| 773 | struct smb2_ioctl_rsp { |
| 774 | struct smb2_hdr hdr; |
| 775 | __le16 StructureSize; /* Must be 57 */ |
| 776 | __u16 Reserved; |
| 777 | __le32 CtlCode; |
| 778 | __u64 PersistentFileId; /* opaque endianness */ |
| 779 | __u64 VolatileFileId; /* opaque endianness */ |
| 780 | __le32 InputOffset; |
| 781 | __le32 InputCount; |
| 782 | __le32 OutputOffset; |
| 783 | __le32 OutputCount; |
| 784 | __le32 Flags; |
| 785 | __u32 Reserved2; |
| 786 | /* char * buffer[] */ |
| 787 | } __packed; |
| 788 | |
Pavel Shilovsky | 2503a0d | 2011-12-26 22:58:46 +0400 | [diff] [blame] | 789 | /* Currently defined values for close flags */ |
| 790 | #define SMB2_CLOSE_FLAG_POSTQUERY_ATTRIB cpu_to_le16(0x0001) |
| 791 | struct smb2_close_req { |
| 792 | struct smb2_hdr hdr; |
| 793 | __le16 StructureSize; /* Must be 24 */ |
| 794 | __le16 Flags; |
| 795 | __le32 Reserved; |
| 796 | __u64 PersistentFileId; /* opaque endianness */ |
| 797 | __u64 VolatileFileId; /* opaque endianness */ |
| 798 | } __packed; |
| 799 | |
| 800 | struct smb2_close_rsp { |
| 801 | struct smb2_hdr hdr; |
| 802 | __le16 StructureSize; /* 60 */ |
| 803 | __le16 Flags; |
| 804 | __le32 Reserved; |
| 805 | __le64 CreationTime; |
| 806 | __le64 LastAccessTime; |
| 807 | __le64 LastWriteTime; |
| 808 | __le64 ChangeTime; |
| 809 | __le64 AllocationSize; /* Beginning of FILE_STANDARD_INFO equivalent */ |
| 810 | __le64 EndOfFile; |
| 811 | __le32 Attributes; |
| 812 | } __packed; |
| 813 | |
Pavel Shilovsky | 7a5cfb1 | 2012-09-18 16:20:28 -0700 | [diff] [blame] | 814 | struct smb2_flush_req { |
| 815 | struct smb2_hdr hdr; |
| 816 | __le16 StructureSize; /* Must be 24 */ |
| 817 | __le16 Reserved1; |
| 818 | __le32 Reserved2; |
| 819 | __u64 PersistentFileId; /* opaque endianness */ |
| 820 | __u64 VolatileFileId; /* opaque endianness */ |
| 821 | } __packed; |
| 822 | |
| 823 | struct smb2_flush_rsp { |
| 824 | struct smb2_hdr hdr; |
| 825 | __le16 StructureSize; |
| 826 | __le16 Reserved; |
| 827 | } __packed; |
| 828 | |
Steve French | 2b5dc28 | 2013-06-13 10:51:10 -0500 | [diff] [blame] | 829 | /* For read request Flags field below, following flag is defined for SMB3.02 */ |
| 830 | #define SMB2_READFLAG_READ_UNBUFFERED 0x01 |
| 831 | |
| 832 | /* Channel field for read and write: exactly one of following flags can be set*/ |
| 833 | #define SMB2_CHANNEL_NONE 0x00000000 |
| 834 | #define SMB2_CHANNEL_RDMA_V1 0x00000001 /* SMB3 or later */ |
| 835 | #define SMB2_CHANNEL_RDMA_V1_INVALIDATE 0x00000001 /* SMB3.02 or later */ |
| 836 | |
Pavel Shilovsky | b8f57ee | 2016-11-23 15:31:54 -0800 | [diff] [blame] | 837 | /* SMB2 read request without RFC1001 length at the beginning */ |
| 838 | struct smb2_read_plain_req { |
| 839 | struct smb2_sync_hdr sync_hdr; |
Pavel Shilovsky | 09a4707 | 2012-09-18 16:20:29 -0700 | [diff] [blame] | 840 | __le16 StructureSize; /* Must be 49 */ |
| 841 | __u8 Padding; /* offset from start of SMB2 header to place read */ |
Steve French | 2b5dc28 | 2013-06-13 10:51:10 -0500 | [diff] [blame] | 842 | __u8 Flags; /* MBZ unless SMB3.02 or later */ |
Pavel Shilovsky | 09a4707 | 2012-09-18 16:20:29 -0700 | [diff] [blame] | 843 | __le32 Length; |
| 844 | __le64 Offset; |
| 845 | __u64 PersistentFileId; /* opaque endianness */ |
| 846 | __u64 VolatileFileId; /* opaque endianness */ |
| 847 | __le32 MinimumCount; |
Steve French | 2b5dc28 | 2013-06-13 10:51:10 -0500 | [diff] [blame] | 848 | __le32 Channel; /* MBZ except for SMB3 or later */ |
Pavel Shilovsky | 09a4707 | 2012-09-18 16:20:29 -0700 | [diff] [blame] | 849 | __le32 RemainingBytes; |
| 850 | __le16 ReadChannelInfoOffset; /* Reserved MBZ */ |
| 851 | __le16 ReadChannelInfoLength; /* Reserved MBZ */ |
| 852 | __u8 Buffer[1]; |
| 853 | } __packed; |
| 854 | |
| 855 | struct smb2_read_rsp { |
| 856 | struct smb2_hdr hdr; |
| 857 | __le16 StructureSize; /* Must be 17 */ |
| 858 | __u8 DataOffset; |
| 859 | __u8 Reserved; |
| 860 | __le32 DataLength; |
| 861 | __le32 DataRemaining; |
| 862 | __u32 Reserved2; |
| 863 | __u8 Buffer[1]; |
| 864 | } __packed; |
| 865 | |
Steve French | 2b5dc28 | 2013-06-13 10:51:10 -0500 | [diff] [blame] | 866 | /* For write request Flags field below the following flags are defined: */ |
| 867 | #define SMB2_WRITEFLAG_WRITE_THROUGH 0x00000001 /* SMB2.1 or later */ |
| 868 | #define SMB2_WRITEFLAG_WRITE_UNBUFFERED 0x00000002 /* SMB3.02 or later */ |
Pavel Shilovsky | 3331914 | 2012-09-18 16:20:29 -0700 | [diff] [blame] | 869 | |
| 870 | struct smb2_write_req { |
| 871 | struct smb2_hdr hdr; |
| 872 | __le16 StructureSize; /* Must be 49 */ |
| 873 | __le16 DataOffset; /* offset from start of SMB2 header to write data */ |
| 874 | __le32 Length; |
| 875 | __le64 Offset; |
| 876 | __u64 PersistentFileId; /* opaque endianness */ |
| 877 | __u64 VolatileFileId; /* opaque endianness */ |
| 878 | __le32 Channel; /* Reserved MBZ */ |
| 879 | __le32 RemainingBytes; |
| 880 | __le16 WriteChannelInfoOffset; /* Reserved MBZ */ |
| 881 | __le16 WriteChannelInfoLength; /* Reserved MBZ */ |
| 882 | __le32 Flags; |
| 883 | __u8 Buffer[1]; |
| 884 | } __packed; |
| 885 | |
| 886 | struct smb2_write_rsp { |
| 887 | struct smb2_hdr hdr; |
| 888 | __le16 StructureSize; /* Must be 17 */ |
| 889 | __u8 DataOffset; |
| 890 | __u8 Reserved; |
| 891 | __le32 DataLength; |
| 892 | __le32 DataRemaining; |
| 893 | __u32 Reserved2; |
| 894 | __u8 Buffer[1]; |
| 895 | } __packed; |
| 896 | |
Pavel Shilovsky | 027e8ee | 2012-09-19 06:22:43 -0700 | [diff] [blame] | 897 | #define SMB2_LOCKFLAG_SHARED_LOCK 0x0001 |
| 898 | #define SMB2_LOCKFLAG_EXCLUSIVE_LOCK 0x0002 |
| 899 | #define SMB2_LOCKFLAG_UNLOCK 0x0004 |
| 900 | #define SMB2_LOCKFLAG_FAIL_IMMEDIATELY 0x0010 |
| 901 | |
Pavel Shilovsky | f7ba7fe | 2012-09-19 06:22:43 -0700 | [diff] [blame] | 902 | struct smb2_lock_element { |
| 903 | __le64 Offset; |
| 904 | __le64 Length; |
| 905 | __le32 Flags; |
| 906 | __le32 Reserved; |
| 907 | } __packed; |
| 908 | |
| 909 | struct smb2_lock_req { |
| 910 | struct smb2_hdr hdr; |
| 911 | __le16 StructureSize; /* Must be 48 */ |
| 912 | __le16 LockCount; |
| 913 | __le32 Reserved; |
| 914 | __u64 PersistentFileId; /* opaque endianness */ |
| 915 | __u64 VolatileFileId; /* opaque endianness */ |
| 916 | /* Followed by at least one */ |
| 917 | struct smb2_lock_element locks[1]; |
| 918 | } __packed; |
| 919 | |
| 920 | struct smb2_lock_rsp { |
| 921 | struct smb2_hdr hdr; |
| 922 | __le16 StructureSize; /* Must be 4 */ |
| 923 | __le16 Reserved; |
| 924 | } __packed; |
| 925 | |
Pavel Shilovsky | 9094fad | 2012-07-12 18:30:44 +0400 | [diff] [blame] | 926 | struct smb2_echo_req { |
| 927 | struct smb2_hdr hdr; |
| 928 | __le16 StructureSize; /* Must be 4 */ |
| 929 | __u16 Reserved; |
| 930 | } __packed; |
| 931 | |
| 932 | struct smb2_echo_rsp { |
| 933 | struct smb2_hdr hdr; |
| 934 | __le16 StructureSize; /* Must be 4 */ |
| 935 | __u16 Reserved; |
| 936 | } __packed; |
| 937 | |
Pavel Shilovsky | d324f08d | 2012-09-18 16:20:33 -0700 | [diff] [blame] | 938 | /* search (query_directory) Flags field */ |
| 939 | #define SMB2_RESTART_SCANS 0x01 |
| 940 | #define SMB2_RETURN_SINGLE_ENTRY 0x02 |
| 941 | #define SMB2_INDEX_SPECIFIED 0x04 |
| 942 | #define SMB2_REOPEN 0x10 |
| 943 | |
| 944 | struct smb2_query_directory_req { |
| 945 | struct smb2_hdr hdr; |
| 946 | __le16 StructureSize; /* Must be 33 */ |
| 947 | __u8 FileInformationClass; |
| 948 | __u8 Flags; |
| 949 | __le32 FileIndex; |
| 950 | __u64 PersistentFileId; /* opaque endianness */ |
| 951 | __u64 VolatileFileId; /* opaque endianness */ |
| 952 | __le16 FileNameOffset; |
| 953 | __le16 FileNameLength; |
| 954 | __le32 OutputBufferLength; |
| 955 | __u8 Buffer[1]; |
| 956 | } __packed; |
| 957 | |
| 958 | struct smb2_query_directory_rsp { |
| 959 | struct smb2_hdr hdr; |
| 960 | __le16 StructureSize; /* Must be 9 */ |
| 961 | __le16 OutputBufferOffset; |
| 962 | __le32 OutputBufferLength; |
| 963 | __u8 Buffer[1]; |
| 964 | } __packed; |
| 965 | |
Pavel Shilovsky | be4cb9e | 2011-12-29 17:06:33 +0400 | [diff] [blame] | 966 | /* Possible InfoType values */ |
| 967 | #define SMB2_O_INFO_FILE 0x01 |
| 968 | #define SMB2_O_INFO_FILESYSTEM 0x02 |
| 969 | #define SMB2_O_INFO_SECURITY 0x03 |
| 970 | #define SMB2_O_INFO_QUOTA 0x04 |
| 971 | |
Steve French | 911a8df | 2014-10-19 19:18:05 -0500 | [diff] [blame] | 972 | /* Security info type additionalinfo flags. See MS-SMB2 (2.2.37) or MS-DTYP */ |
| 973 | #define OWNER_SECINFO 0x00000001 |
| 974 | #define GROUP_SECINFO 0x00000002 |
| 975 | #define DACL_SECINFO 0x00000004 |
| 976 | #define SACL_SECINFO 0x00000008 |
| 977 | #define LABEL_SECINFO 0x00000010 |
| 978 | #define ATTRIBUTE_SECINFO 0x00000020 |
| 979 | #define SCOPE_SECINFO 0x00000040 |
| 980 | #define BACKUP_SECINFO 0x00010000 |
| 981 | #define UNPROTECTED_SACL_SECINFO 0x10000000 |
| 982 | #define UNPROTECTED_DACL_SECINFO 0x20000000 |
| 983 | #define PROTECTED_SACL_SECINFO 0x40000000 |
| 984 | #define PROTECTED_DACL_SECINFO 0x80000000 |
| 985 | |
| 986 | /* Flags used for FileFullEAinfo */ |
| 987 | #define SL_RESTART_SCAN 0x00000001 |
| 988 | #define SL_RETURN_SINGLE_ENTRY 0x00000002 |
| 989 | #define SL_INDEX_SPECIFIED 0x00000004 |
| 990 | |
Pavel Shilovsky | be4cb9e | 2011-12-29 17:06:33 +0400 | [diff] [blame] | 991 | struct smb2_query_info_req { |
| 992 | struct smb2_hdr hdr; |
| 993 | __le16 StructureSize; /* Must be 41 */ |
| 994 | __u8 InfoType; |
| 995 | __u8 FileInfoClass; |
| 996 | __le32 OutputBufferLength; |
| 997 | __le16 InputBufferOffset; |
| 998 | __u16 Reserved; |
| 999 | __le32 InputBufferLength; |
| 1000 | __le32 AdditionalInformation; |
| 1001 | __le32 Flags; |
| 1002 | __u64 PersistentFileId; /* opaque endianness */ |
| 1003 | __u64 VolatileFileId; /* opaque endianness */ |
| 1004 | __u8 Buffer[1]; |
| 1005 | } __packed; |
| 1006 | |
| 1007 | struct smb2_query_info_rsp { |
| 1008 | struct smb2_hdr hdr; |
| 1009 | __le16 StructureSize; /* Must be 9 */ |
| 1010 | __le16 OutputBufferOffset; |
| 1011 | __le32 OutputBufferLength; |
| 1012 | __u8 Buffer[1]; |
| 1013 | } __packed; |
| 1014 | |
Pavel Shilovsky | 35143eb | 2012-09-18 16:20:31 -0700 | [diff] [blame] | 1015 | struct smb2_set_info_req { |
| 1016 | struct smb2_hdr hdr; |
| 1017 | __le16 StructureSize; /* Must be 33 */ |
| 1018 | __u8 InfoType; |
| 1019 | __u8 FileInfoClass; |
| 1020 | __le32 BufferLength; |
| 1021 | __le16 BufferOffset; |
| 1022 | __u16 Reserved; |
| 1023 | __le32 AdditionalInformation; |
| 1024 | __u64 PersistentFileId; /* opaque endianness */ |
| 1025 | __u64 VolatileFileId; /* opaque endianness */ |
| 1026 | __u8 Buffer[1]; |
| 1027 | } __packed; |
| 1028 | |
| 1029 | struct smb2_set_info_rsp { |
| 1030 | struct smb2_hdr hdr; |
| 1031 | __le16 StructureSize; /* Must be 2 */ |
| 1032 | } __packed; |
| 1033 | |
Pavel Shilovsky | 983c88a | 2012-09-18 16:20:33 -0700 | [diff] [blame] | 1034 | struct smb2_oplock_break { |
| 1035 | struct smb2_hdr hdr; |
| 1036 | __le16 StructureSize; /* Must be 24 */ |
| 1037 | __u8 OplockLevel; |
| 1038 | __u8 Reserved; |
| 1039 | __le32 Reserved2; |
| 1040 | __u64 PersistentFid; |
| 1041 | __u64 VolatileFid; |
| 1042 | } __packed; |
| 1043 | |
Pavel Shilovsky | 0822f51 | 2012-09-19 06:22:45 -0700 | [diff] [blame] | 1044 | #define SMB2_NOTIFY_BREAK_LEASE_FLAG_ACK_REQUIRED cpu_to_le32(0x01) |
| 1045 | |
| 1046 | struct smb2_lease_break { |
| 1047 | struct smb2_hdr hdr; |
| 1048 | __le16 StructureSize; /* Must be 44 */ |
| 1049 | __le16 Reserved; |
| 1050 | __le32 Flags; |
| 1051 | __u8 LeaseKey[16]; |
| 1052 | __le32 CurrentLeaseState; |
| 1053 | __le32 NewLeaseState; |
| 1054 | __le32 BreakReason; |
| 1055 | __le32 AccessMaskHint; |
| 1056 | __le32 ShareMaskHint; |
| 1057 | } __packed; |
| 1058 | |
| 1059 | struct smb2_lease_ack { |
| 1060 | struct smb2_hdr hdr; |
| 1061 | __le16 StructureSize; /* Must be 36 */ |
| 1062 | __le16 Reserved; |
| 1063 | __le32 Flags; |
| 1064 | __u8 LeaseKey[16]; |
| 1065 | __le32 LeaseState; |
| 1066 | __le64 LeaseDuration; |
| 1067 | } __packed; |
| 1068 | |
Pavel Shilovsky | be4cb9e | 2011-12-29 17:06:33 +0400 | [diff] [blame] | 1069 | /* |
| 1070 | * PDU infolevel structure definitions |
| 1071 | * BB consider moving to a different header |
| 1072 | */ |
| 1073 | |
Pavel Shilovsky | 6fc05c2 | 2012-09-18 16:20:34 -0700 | [diff] [blame] | 1074 | /* File System Information Classes */ |
| 1075 | #define FS_VOLUME_INFORMATION 1 /* Query */ |
Steven French | af6a12e | 2013-10-09 20:55:53 -0500 | [diff] [blame] | 1076 | #define FS_LABEL_INFORMATION 2 /* Local only */ |
Pavel Shilovsky | 6fc05c2 | 2012-09-18 16:20:34 -0700 | [diff] [blame] | 1077 | #define FS_SIZE_INFORMATION 3 /* Query */ |
| 1078 | #define FS_DEVICE_INFORMATION 4 /* Query */ |
| 1079 | #define FS_ATTRIBUTE_INFORMATION 5 /* Query */ |
| 1080 | #define FS_CONTROL_INFORMATION 6 /* Query, Set */ |
| 1081 | #define FS_FULL_SIZE_INFORMATION 7 /* Query */ |
| 1082 | #define FS_OBJECT_ID_INFORMATION 8 /* Query, Set */ |
Steven French | af6a12e | 2013-10-09 20:55:53 -0500 | [diff] [blame] | 1083 | #define FS_DRIVER_PATH_INFORMATION 9 /* Local only */ |
| 1084 | #define FS_VOLUME_FLAGS_INFORMATION 10 /* Local only */ |
| 1085 | #define FS_SECTOR_SIZE_INFORMATION 11 /* SMB3 or later. Query */ |
Pavel Shilovsky | 6fc05c2 | 2012-09-18 16:20:34 -0700 | [diff] [blame] | 1086 | |
| 1087 | struct smb2_fs_full_size_info { |
| 1088 | __le64 TotalAllocationUnits; |
| 1089 | __le64 CallerAvailableAllocationUnits; |
| 1090 | __le64 ActualAvailableAllocationUnits; |
| 1091 | __le32 SectorsPerAllocationUnit; |
| 1092 | __le32 BytesPerSector; |
| 1093 | } __packed; |
| 1094 | |
Steven French | af6a12e | 2013-10-09 20:55:53 -0500 | [diff] [blame] | 1095 | #define SSINFO_FLAGS_ALIGNED_DEVICE 0x00000001 |
| 1096 | #define SSINFO_FLAGS_PARTITION_ALIGNED_ON_DEVICE 0x00000002 |
| 1097 | #define SSINFO_FLAGS_NO_SEEK_PENALTY 0x00000004 |
| 1098 | #define SSINFO_FLAGS_TRIM_ENABLED 0x00000008 |
| 1099 | |
| 1100 | /* sector size info struct */ |
| 1101 | struct smb3_fs_ss_info { |
| 1102 | __le32 LogicalBytesPerSector; |
| 1103 | __le32 PhysicalBytesPerSectorForAtomicity; |
| 1104 | __le32 PhysicalBytesPerSectorForPerf; |
| 1105 | __le32 FileSystemEffectivePhysicalBytesPerSectorForAtomicity; |
| 1106 | __le32 Flags; |
| 1107 | __le32 ByteOffsetForSectorAlignment; |
| 1108 | __le32 ByteOffsetForPartitionAlignment; |
| 1109 | } __packed; |
| 1110 | |
Pavel Shilovsky | be4cb9e | 2011-12-29 17:06:33 +0400 | [diff] [blame] | 1111 | /* partial list of QUERY INFO levels */ |
| 1112 | #define FILE_DIRECTORY_INFORMATION 1 |
| 1113 | #define FILE_FULL_DIRECTORY_INFORMATION 2 |
| 1114 | #define FILE_BOTH_DIRECTORY_INFORMATION 3 |
| 1115 | #define FILE_BASIC_INFORMATION 4 |
| 1116 | #define FILE_STANDARD_INFORMATION 5 |
| 1117 | #define FILE_INTERNAL_INFORMATION 6 |
| 1118 | #define FILE_EA_INFORMATION 7 |
| 1119 | #define FILE_ACCESS_INFORMATION 8 |
| 1120 | #define FILE_NAME_INFORMATION 9 |
| 1121 | #define FILE_RENAME_INFORMATION 10 |
| 1122 | #define FILE_LINK_INFORMATION 11 |
| 1123 | #define FILE_NAMES_INFORMATION 12 |
| 1124 | #define FILE_DISPOSITION_INFORMATION 13 |
| 1125 | #define FILE_POSITION_INFORMATION 14 |
| 1126 | #define FILE_FULL_EA_INFORMATION 15 |
| 1127 | #define FILE_MODE_INFORMATION 16 |
| 1128 | #define FILE_ALIGNMENT_INFORMATION 17 |
| 1129 | #define FILE_ALL_INFORMATION 18 |
| 1130 | #define FILE_ALLOCATION_INFORMATION 19 |
| 1131 | #define FILE_END_OF_FILE_INFORMATION 20 |
| 1132 | #define FILE_ALTERNATE_NAME_INFORMATION 21 |
| 1133 | #define FILE_STREAM_INFORMATION 22 |
| 1134 | #define FILE_PIPE_INFORMATION 23 |
| 1135 | #define FILE_PIPE_LOCAL_INFORMATION 24 |
| 1136 | #define FILE_PIPE_REMOTE_INFORMATION 25 |
| 1137 | #define FILE_MAILSLOT_QUERY_INFORMATION 26 |
| 1138 | #define FILE_MAILSLOT_SET_INFORMATION 27 |
| 1139 | #define FILE_COMPRESSION_INFORMATION 28 |
| 1140 | #define FILE_OBJECT_ID_INFORMATION 29 |
| 1141 | /* Number 30 not defined in documents */ |
| 1142 | #define FILE_MOVE_CLUSTER_INFORMATION 31 |
| 1143 | #define FILE_QUOTA_INFORMATION 32 |
| 1144 | #define FILE_REPARSE_POINT_INFORMATION 33 |
| 1145 | #define FILE_NETWORK_OPEN_INFORMATION 34 |
| 1146 | #define FILE_ATTRIBUTE_TAG_INFORMATION 35 |
| 1147 | #define FILE_TRACKING_INFORMATION 36 |
| 1148 | #define FILEID_BOTH_DIRECTORY_INFORMATION 37 |
| 1149 | #define FILEID_FULL_DIRECTORY_INFORMATION 38 |
| 1150 | #define FILE_VALID_DATA_LENGTH_INFORMATION 39 |
| 1151 | #define FILE_SHORT_NAME_INFORMATION 40 |
| 1152 | #define FILE_SFIO_RESERVE_INFORMATION 44 |
| 1153 | #define FILE_SFIO_VOLUME_INFORMATION 45 |
| 1154 | #define FILE_HARD_LINK_INFORMATION 46 |
| 1155 | #define FILE_NORMALIZED_NAME_INFORMATION 48 |
| 1156 | #define FILEID_GLOBAL_TX_DIRECTORY_INFORMATION 50 |
| 1157 | #define FILE_STANDARD_LINK_INFORMATION 54 |
| 1158 | |
Pavel Shilovsky | f0df737 | 2012-09-18 16:20:26 -0700 | [diff] [blame] | 1159 | struct smb2_file_internal_info { |
| 1160 | __le64 IndexNumber; |
| 1161 | } __packed; /* level 6 Query */ |
| 1162 | |
Pavel Shilovsky | 35143eb | 2012-09-18 16:20:31 -0700 | [diff] [blame] | 1163 | struct smb2_file_rename_info { /* encoding of request for level 10 */ |
| 1164 | __u8 ReplaceIfExists; /* 1 = replace existing target with new */ |
| 1165 | /* 0 = fail if target already exists */ |
| 1166 | __u8 Reserved[7]; |
| 1167 | __u64 RootDirectory; /* MBZ for network operations (why says spec?) */ |
| 1168 | __le32 FileNameLength; |
| 1169 | char FileName[0]; /* New name to be assigned */ |
| 1170 | } __packed; /* level 10 Set */ |
| 1171 | |
Pavel Shilovsky | 568798c | 2012-09-18 16:20:31 -0700 | [diff] [blame] | 1172 | struct smb2_file_link_info { /* encoding of request for level 11 */ |
| 1173 | __u8 ReplaceIfExists; /* 1 = replace existing link with new */ |
| 1174 | /* 0 = fail if link already exists */ |
| 1175 | __u8 Reserved[7]; |
| 1176 | __u64 RootDirectory; /* MBZ for network operations (why says spec?) */ |
| 1177 | __le32 FileNameLength; |
| 1178 | char FileName[0]; /* Name to be assigned to new link */ |
| 1179 | } __packed; /* level 11 Set */ |
| 1180 | |
Ronnie Sahlberg | 95907fe | 2017-08-24 11:24:55 +1000 | [diff] [blame] | 1181 | #define SMB2_MAX_EA_BUF 2048 |
| 1182 | |
| 1183 | struct smb2_file_full_ea_info { /* encoding of response for level 15 */ |
| 1184 | __le32 next_entry_offset; |
| 1185 | __u8 flags; |
| 1186 | __u8 ea_name_length; |
| 1187 | __le16 ea_value_length; |
| 1188 | char ea_data[0]; /* \0 terminated name plus value */ |
| 1189 | } __packed; /* level 15 Set */ |
| 1190 | |
Pavel Shilovsky | be4cb9e | 2011-12-29 17:06:33 +0400 | [diff] [blame] | 1191 | /* |
| 1192 | * This level 18, although with struct with same name is different from cifs |
| 1193 | * level 0x107. Level 0x107 has an extra u64 between AccessFlags and |
| 1194 | * CurrentByteOffset. |
| 1195 | */ |
| 1196 | struct smb2_file_all_info { /* data block encoding of response to level 18 */ |
| 1197 | __le64 CreationTime; /* Beginning of FILE_BASIC_INFO equivalent */ |
| 1198 | __le64 LastAccessTime; |
| 1199 | __le64 LastWriteTime; |
| 1200 | __le64 ChangeTime; |
| 1201 | __le32 Attributes; |
| 1202 | __u32 Pad1; /* End of FILE_BASIC_INFO_INFO equivalent */ |
| 1203 | __le64 AllocationSize; /* Beginning of FILE_STANDARD_INFO equivalent */ |
| 1204 | __le64 EndOfFile; /* size ie offset to first free byte in file */ |
| 1205 | __le32 NumberOfLinks; /* hard links */ |
| 1206 | __u8 DeletePending; |
| 1207 | __u8 Directory; |
| 1208 | __u16 Pad2; /* End of FILE_STANDARD_INFO equivalent */ |
| 1209 | __le64 IndexNumber; |
| 1210 | __le32 EASize; |
| 1211 | __le32 AccessFlags; |
| 1212 | __le64 CurrentByteOffset; |
| 1213 | __le32 Mode; |
| 1214 | __le32 AlignmentRequirement; |
| 1215 | __le32 FileNameLength; |
| 1216 | char FileName[1]; |
| 1217 | } __packed; /* level 18 Query */ |
| 1218 | |
Pavel Shilovsky | c839ff2 | 2012-09-18 16:20:32 -0700 | [diff] [blame] | 1219 | struct smb2_file_eof_info { /* encoding of request for level 10 */ |
| 1220 | __le64 EndOfFile; /* new end of file value */ |
| 1221 | } __packed; /* level 20 Set */ |
| 1222 | |
Steve French | ddfbefb | 2011-03-15 02:08:48 +0000 | [diff] [blame] | 1223 | #endif /* _SMB2PDU_H */ |