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