blob: 853e5a707276a8df1b70c1849af1c9c061104929 [file] [log] [blame]
Steve Frenchddfbefb2011-03-15 02:08:48 +00001/*
2 * fs/cifs/smb2pdu.h
3 *
Steve Frenchbe7457d2013-06-19 17:41:10 -05004 * Copyright (c) International Business Machines Corp., 2009, 2013
Steve Frenchddfbefb2011-03-15 02:08:48 +00005 * 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 Shilovsky2dc7e1c2011-12-26 22:53:34 +040030 * 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 Shilovsky96a988f2016-11-29 11:31:23 -080083#define SMB2_INTERNAL_CMD cpu_to_le16(0xFFFF)
84
Pavel Shilovsky2dc7e1c2011-12-26 22:53:34 +040085#define NUMBER_OF_SMB2_COMMANDS 0x0013
86
Pavel Shilovsky9e37b172017-08-24 15:16:40 -070087/* 4 len + 52 transform hdr + 64 hdr + 56 create rsp */
88#define MAX_SMB2_HDR_SIZE 0x00b0
Pavel Shilovsky2dc7e1c2011-12-26 22:53:34 +040089
Fabian Frederickbc09d142014-12-10 15:41:15 -080090#define SMB2_PROTO_NUMBER cpu_to_le32(0x424d53fe)
Steve French373512e2015-12-18 13:05:30 -060091#define SMB2_TRANSFORM_PROTO_NUM cpu_to_le32(0x424d53fd)
Pavel Shilovsky093b2bd2011-06-08 15:51:07 +040092
Pavel Shilovsky2dc7e1c2011-12-26 22:53:34 +040093/*
Steve Frenchddfbefb2011-03-15 02:08:48 +000094 * 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 Shilovsky74112862012-07-27 01:20:41 +0400101
Fabian Frederickbc09d142014-12-10 15:41:15 -0800102#define SMB2_HEADER_STRUCTURE_SIZE cpu_to_le16(64)
Pavel Shilovsky74112862012-07-27 01:20:41 +0400103
Pavel Shilovsky31473fc2016-10-24 15:33:04 -0700104struct smb2_sync_hdr {
Steve French373512e2015-12-18 13:05:30 -0600105 __le32 ProtocolId; /* 0xFE 'S' 'M' 'B' */
Steve Frenchddfbefb2011-03-15 02:08:48 +0000106 __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 Prabhu9235d092014-12-09 17:37:00 +0000113 __le64 MessageId;
Steve Frenchddfbefb2011-03-15 02:08:48 +0000114 __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 Shilovskycb200bd2016-10-24 16:59:57 -0700120struct smb2_sync_pdu {
121 struct smb2_sync_hdr sync_hdr;
122 __le16 StructureSize2; /* size of wct area (varies, request specific) */
123} __packed;
124
Pavel Shilovsky31473fc2016-10-24 15:33:04 -0700125struct 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 Shilovsky093b2bd2011-06-08 15:51:07 +0400132struct smb2_pdu {
133 struct smb2_hdr hdr;
134 __le16 StructureSize2; /* size of wct area (varies, request specific) */
135} __packed;
136
Pavel Shilovsky026e93d2016-11-03 16:47:37 -0700137#define SMB3_AES128CMM_NONCE 11
138#define SMB3_AES128GCM_NONCE 12
139
Steve French0cbaa532013-11-15 23:50:24 -0600140struct 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 Shilovsky026e93d2016-11-03 16:47:37 -0700144 __le32 ProtocolId; /* 0xFD 'S' 'M' 'B' */
Steve French0cbaa532013-11-15 23:50:24 -0600145 __u8 Signature[16];
Steve French373512e2015-12-18 13:05:30 -0600146 __u8 Nonce[16];
Steve French0cbaa532013-11-15 23:50:24 -0600147 __le32 OriginalMessageSize;
148 __u16 Reserved1;
Steve French373512e2015-12-18 13:05:30 -0600149 __le16 Flags; /* EncryptionAlgorithm */
Steve French0cbaa532013-11-15 23:50:24 -0600150 __u64 SessionId;
151} __packed;
152
Pavel Shilovsky093b2bd2011-06-08 15:51:07 +0400153/*
154 * SMB2 flag definitions
155 */
Fabian Frederickbc09d142014-12-10 15:41:15 -0800156#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 Shilovsky093b2bd2011-06-08 15:51:07 +0400161
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 Shilovsky74112862012-07-27 01:20:41 +0400170
Fabian Frederickbc09d142014-12-10 15:41:15 -0800171#define SMB2_ERROR_STRUCTURE_SIZE2 cpu_to_le16(9)
Pavel Shilovsky74112862012-07-27 01:20:41 +0400172
Pavel Shilovsky093b2bd2011-06-08 15:51:07 +0400173struct 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 Shilovskyb42bf882013-08-14 19:25:21 +0400181struct 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
Steve French5f60a562018-02-05 14:46:18 -0600195/* SMB 3.1.1 and later dialects. See MS-SMB2 section 2.2.2.1 */
196struct smb2_error_context_rsp {
197 __le32 ErrorDataLength;
198 __le32 ErrorId;
199 __u8 ErrorContextData; /* ErrorDataLength long array */
200} __packed;
201
202/* Defines for Type field below (see MS-SMB2 2.2.2.2.2.1) */
203#define MOVE_DST_IPADDR_V4 cpu_to_le32(0x00000001)
204#define MOVE_DST_IPADDR_V6 cpu_to_le32(0x00000002)
205
206struct move_dst_ipaddr {
207 __le32 Type;
208 __u32 Reserved;
209 __u8 address[16]; /* IPv4 followed by 12 bytes rsvd or IPv6 address */
210} __packed;
211
212struct share_redirect_error_context_rsp {
213 __le32 StructureSize;
214 __le32 NotificationType;
215 __le32 ResourceNameOffset;
216 __le32 ResourceNameLength;
217 __le16 Flags;
218 __le16 TargetType;
219 __le32 IPAddrCount;
220 struct move_dst_ipaddr IpAddrMoveList[0];
221 /* __u8 ResourceName[] */ /* Name of share as counted Unicode string */
222} __packed;
223
Pavel Shilovskyb8c32db2012-09-19 06:22:44 -0700224#define SMB2_CLIENT_GUID_SIZE 16
225
Pavel Shilovskyec2e4522011-12-27 16:12:43 +0400226struct smb2_negotiate_req {
Ronnie Sahlberg13cacea2017-11-20 11:24:30 +1100227 struct smb2_sync_hdr sync_hdr;
Pavel Shilovskyec2e4522011-12-27 16:12:43 +0400228 __le16 StructureSize; /* Must be 36 */
229 __le16 DialectCount;
230 __le16 SecurityMode;
231 __le16 Reserved; /* MBZ */
232 __le32 Capabilities;
Pavel Shilovskyb8c32db2012-09-19 06:22:44 -0700233 __u8 ClientGUID[SMB2_CLIENT_GUID_SIZE];
Steve French5f7fbf72014-12-17 22:52:58 -0600234 /* In SMB3.02 and earlier next three were MBZ le64 ClientStartTime */
235 __le32 NegotiateContextOffset; /* SMB3.1.1 only. MBZ earlier */
236 __le16 NegotiateContextCount; /* SMB3.1.1 only. MBZ earlier */
237 __le16 Reserved2;
Steve Frenche4aa25e2012-10-01 12:26:22 -0500238 __le16 Dialects[1]; /* One dialect (vers=) at a time for now */
Pavel Shilovskyec2e4522011-12-27 16:12:43 +0400239} __packed;
240
Steve Frenche4aa25e2012-10-01 12:26:22 -0500241/* Dialects */
242#define SMB20_PROT_ID 0x0202
243#define SMB21_PROT_ID 0x0210
244#define SMB30_PROT_ID 0x0300
Steve French20b6d8b2013-06-12 22:48:41 -0500245#define SMB302_PROT_ID 0x0302
Steve French5f7fbf72014-12-17 22:52:58 -0600246#define SMB311_PROT_ID 0x0311
Steve Frenche4aa25e2012-10-01 12:26:22 -0500247#define BAD_PROT_ID 0xFFFF
248
Pavel Shilovskyec2e4522011-12-27 16:12:43 +0400249/* SecurityMode flags */
250#define SMB2_NEGOTIATE_SIGNING_ENABLED 0x0001
251#define SMB2_NEGOTIATE_SIGNING_REQUIRED 0x0002
Steve French07108d02018-04-01 20:15:55 -0500252#define SMB2_SEC_MODE_FLAGS_ALL 0x0003
253
Pavel Shilovskyec2e4522011-12-27 16:12:43 +0400254/* Capabilities flags */
255#define SMB2_GLOBAL_CAP_DFS 0x00000001
256#define SMB2_GLOBAL_CAP_LEASING 0x00000002 /* Resp only New to SMB2.1 */
257#define SMB2_GLOBAL_CAP_LARGE_MTU 0X00000004 /* Resp only New to SMB2.1 */
Steve Frenche4aa25e2012-10-01 12:26:22 -0500258#define SMB2_GLOBAL_CAP_MULTI_CHANNEL 0x00000008 /* New to SMB3 */
259#define SMB2_GLOBAL_CAP_PERSISTENT_HANDLES 0x00000010 /* New to SMB3 */
260#define SMB2_GLOBAL_CAP_DIRECTORY_LEASING 0x00000020 /* New to SMB3 */
261#define SMB2_GLOBAL_CAP_ENCRYPTION 0x00000040 /* New to SMB3 */
Pavel Shilovsky29e20f92012-07-13 13:58:14 +0400262/* Internal types */
263#define SMB2_NT_FIND 0x00100000
264#define SMB2_LARGE_FILES 0x00200000
Pavel Shilovskyec2e4522011-12-27 16:12:43 +0400265
Steve French136ff1b2018-04-08 16:14:31 -0500266struct smb2_neg_context {
267 __le16 ContextType;
268 __le16 DataLength;
269 __le32 Reserved;
270 /* Followed by array of data */
271} __packed;
272
Steve Frencheed0e172015-02-06 00:03:52 -0600273#define SMB311_SALT_SIZE 32
274/* Hash Algorithm Types */
Steve Frenchebb3a9d2015-06-18 04:49:47 -0500275#define SMB2_PREAUTH_INTEGRITY_SHA512 cpu_to_le16(0x0001)
Aurelien Aptel8bd68c62018-02-16 19:19:29 +0100276#define SMB2_PREAUTH_HASH_SIZE 64
Steve Frencheed0e172015-02-06 00:03:52 -0600277
Steve French5100d8a2018-04-09 10:47:14 -0500278#define MIN_PREAUTH_CTXT_DATA_LEN (SMB311_SALT_SIZE + 6)
Steve Frencheed0e172015-02-06 00:03:52 -0600279struct smb2_preauth_neg_context {
280 __le16 ContextType; /* 1 */
281 __le16 DataLength;
282 __le32 Reserved;
283 __le16 HashAlgorithmCount; /* 1 */
284 __le16 SaltLength;
285 __le16 HashAlgorithms; /* HashAlgorithms[0] since only one defined */
286 __u8 Salt[SMB311_SALT_SIZE];
287} __packed;
288
289/* Encryption Algorithms Ciphers */
290#define SMB2_ENCRYPTION_AES128_CCM cpu_to_le16(0x0001)
291#define SMB2_ENCRYPTION_AES128_GCM cpu_to_le16(0x0002)
292
Steve French5100d8a2018-04-09 10:47:14 -0500293/* Min encrypt context data is one cipher so 2 bytes + 2 byte count field */
294#define MIN_ENCRYPT_CTXT_DATA_LEN 4
Steve Frencheed0e172015-02-06 00:03:52 -0600295struct smb2_encryption_neg_context {
296 __le16 ContextType; /* 2 */
297 __le16 DataLength;
298 __le32 Reserved;
Steve Frenchebb3a9d2015-06-18 04:49:47 -0500299 __le16 CipherCount; /* AES-128-GCM and AES-128-CCM */
Steve French23657ad2018-04-22 15:14:58 -0500300 __le16 Ciphers[1]; /* Ciphers[0] since only one used now */
Steve Frencheed0e172015-02-06 00:03:52 -0600301} __packed;
302
Steve Frenchfcef0db2018-05-19 20:45:27 -0500303#define POSIX_CTXT_DATA_LEN 8
304struct smb2_posix_neg_context {
305 __le16 ContextType; /* 0x100 */
306 __le16 DataLength;
307 __le32 Reserved;
308 __le64 Reserved1; /* In case needed for future (eg version or caps) */
309} __packed;
310
Pavel Shilovskyec2e4522011-12-27 16:12:43 +0400311struct smb2_negotiate_rsp {
312 struct smb2_hdr hdr;
313 __le16 StructureSize; /* Must be 65 */
314 __le16 SecurityMode;
315 __le16 DialectRevision;
Steve French5f7fbf72014-12-17 22:52:58 -0600316 __le16 NegotiateContextCount; /* Prior to SMB3.1.1 was Reserved & MBZ */
Pavel Shilovskyec2e4522011-12-27 16:12:43 +0400317 __u8 ServerGUID[16];
318 __le32 Capabilities;
319 __le32 MaxTransactSize;
320 __le32 MaxReadSize;
321 __le32 MaxWriteSize;
322 __le64 SystemTime; /* MBZ */
323 __le64 ServerStartTime;
324 __le16 SecurityBufferOffset;
325 __le16 SecurityBufferLength;
Steve French5f7fbf72014-12-17 22:52:58 -0600326 __le32 NegotiateContextOffset; /* Pre:SMB3.1.1 was reserved/ignored */
Pavel Shilovskyec2e4522011-12-27 16:12:43 +0400327 __u8 Buffer[1]; /* variable length GSS security buffer */
328} __packed;
329
Steve Frencheed0e172015-02-06 00:03:52 -0600330/* Flags */
331#define SMB2_SESSION_REQ_FLAG_BINDING 0x01
332#define SMB2_SESSION_REQ_FLAG_ENCRYPT_DATA 0x04
333
Pavel Shilovsky5478f9b2011-12-27 16:22:00 +0400334struct smb2_sess_setup_req {
Ronnie Sahlberg88ea5cb2017-11-20 11:24:36 +1100335 struct smb2_sync_hdr sync_hdr;
Pavel Shilovsky5478f9b2011-12-27 16:22:00 +0400336 __le16 StructureSize; /* Must be 25 */
Steve Frencheed0e172015-02-06 00:03:52 -0600337 __u8 Flags;
Pavel Shilovsky5478f9b2011-12-27 16:22:00 +0400338 __u8 SecurityMode;
339 __le32 Capabilities;
340 __le32 Channel;
341 __le16 SecurityBufferOffset;
342 __le16 SecurityBufferLength;
Steve Frenchc2afb812016-09-20 22:56:13 -0500343 __u64 PreviousSessionId;
Pavel Shilovsky5478f9b2011-12-27 16:22:00 +0400344 __u8 Buffer[1]; /* variable length GSS security buffer */
345} __packed;
346
347/* Currently defined SessionFlags */
348#define SMB2_SESSION_FLAG_IS_GUEST 0x0001
349#define SMB2_SESSION_FLAG_IS_NULL 0x0002
Steve French0cbaa532013-11-15 23:50:24 -0600350#define SMB2_SESSION_FLAG_ENCRYPT_DATA 0x0004
Pavel Shilovsky5478f9b2011-12-27 16:22:00 +0400351struct smb2_sess_setup_rsp {
352 struct smb2_hdr hdr;
353 __le16 StructureSize; /* Must be 9 */
354 __le16 SessionFlags;
355 __le16 SecurityBufferOffset;
356 __le16 SecurityBufferLength;
357 __u8 Buffer[1]; /* variable length GSS security buffer */
358} __packed;
359
360struct smb2_logoff_req {
Ronnie Sahlberg45305ed2017-11-09 12:14:17 +1100361 struct smb2_sync_hdr sync_hdr;
Pavel Shilovsky5478f9b2011-12-27 16:22:00 +0400362 __le16 StructureSize; /* Must be 4 */
363 __le16 Reserved;
364} __packed;
365
366struct smb2_logoff_rsp {
367 struct smb2_hdr hdr;
368 __le16 StructureSize; /* Must be 4 */
369 __le16 Reserved;
370} __packed;
371
Steve Frencheed0e172015-02-06 00:03:52 -0600372/* Flags/Reserved for SMB3.1.1 */
Steve French5f60a562018-02-05 14:46:18 -0600373#define SMB2_TREE_CONNECT_FLAG_CLUSTER_RECONNECT cpu_to_le16(0x0001)
374#define SMB2_TREE_CONNECT_FLAG_REDIRECT_TO_OWNER cpu_to_le16(0x0002)
375#define SMB2_TREE_CONNECT_FLAG_EXTENSION_PRESENT cpu_to_le16(0x0004)
Steve Frencheed0e172015-02-06 00:03:52 -0600376
Pavel Shilovskyfaaf9462011-12-27 16:04:00 +0400377struct smb2_tree_connect_req {
Ronnie Sahlberg661bb9432017-11-09 12:14:23 +1100378 struct smb2_sync_hdr sync_hdr;
Pavel Shilovskyfaaf9462011-12-27 16:04:00 +0400379 __le16 StructureSize; /* Must be 9 */
Steve Frencheed0e172015-02-06 00:03:52 -0600380 __le16 Reserved; /* Flags in SMB3.1.1 */
Pavel Shilovskyfaaf9462011-12-27 16:04:00 +0400381 __le16 PathOffset;
382 __le16 PathLength;
383 __u8 Buffer[1]; /* variable length */
384} __packed;
385
Steve French5f60a562018-02-05 14:46:18 -0600386/* See MS-SMB2 section 2.2.9.2 */
387/* Context Types */
388#define SMB2_RESERVED_TREE_CONNECT_CONTEXT_ID 0x0000
389#define SMB2_REMOTED_IDENTITY_TREE_CONNECT_CONTEXT_ID cpu_to_le16(0x0001)
390
391struct tree_connect_contexts {
392 __le16 ContextType;
393 __le16 DataLength;
394 __le32 Reserved;
395 __u8 Data[0];
396} __packed;
397
398/* Remoted identity tree connect context structures - see MS-SMB2 2.2.9.2.1 */
399struct smb3_blob_data {
400 __le16 BlobSize;
401 __u8 BlobData[0];
402} __packed;
403
404/* Valid values for Attr */
405#define SE_GROUP_MANDATORY 0x00000001
406#define SE_GROUP_ENABLED_BY_DEFAULT 0x00000002
407#define SE_GROUP_ENABLED 0x00000004
408#define SE_GROUP_OWNER 0x00000008
409#define SE_GROUP_USE_FOR_DENY_ONLY 0x00000010
410#define SE_GROUP_INTEGRITY 0x00000020
411#define SE_GROUP_INTEGRITY_ENABLED 0x00000040
412#define SE_GROUP_RESOURCE 0x20000000
413#define SE_GROUP_LOGON_ID 0xC0000000
414
415/* struct sid_attr_data is SidData array in BlobData format then le32 Attr */
416
417struct sid_array_data {
418 __le16 SidAttrCount;
419 /* SidAttrList - array of sid_attr_data structs */
420} __packed;
421
422struct luid_attr_data {
423
424} __packed;
425
426/*
427 * struct privilege_data is the same as BLOB_DATA - see MS-SMB2 2.2.9.2.1.5
428 * but with size of LUID_ATTR_DATA struct and BlobData set to LUID_ATTR DATA
429 */
430
431struct privilege_array_data {
432 __le16 PrivilegeCount;
433 /* array of privilege_data structs */
434} __packed;
435
436struct remoted_identity_tcon_context {
437 __le16 TicketType; /* must be 0x0001 */
438 __le16 TicketSize; /* total size of this struct */
439 __le16 User; /* offset to SID_ATTR_DATA struct with user info */
440 __le16 UserName; /* offset to null terminated Unicode username string */
441 __le16 Domain; /* offset to null terminated Unicode domain name */
442 __le16 Groups; /* offset to SID_ARRAY_DATA struct with group info */
443 __le16 RestrictedGroups; /* similar to above */
444 __le16 Privileges; /* offset to PRIVILEGE_ARRAY_DATA struct */
445 __le16 PrimaryGroup; /* offset to SID_ARRAY_DATA struct */
446 __le16 Owner; /* offset to BLOB_DATA struct */
447 __le16 DefaultDacl; /* offset to BLOB_DATA struct */
448 __le16 DeviceGroups; /* offset to SID_ARRAY_DATA struct */
449 __le16 UserClaims; /* offset to BLOB_DATA struct */
450 __le16 DeviceClaims; /* offset to BLOB_DATA struct */
451 __u8 TicketInfo[0]; /* variable length buf - remoted identity data */
452} __packed;
453
454struct smb2_tree_connect_req_extension {
455 __le32 TreeConnectContextOffset;
456 __le16 TreeConnectContextCount;
457 __u8 Reserved[10];
458 __u8 PathName[0]; /* variable sized array */
459 /* followed by array of TreeConnectContexts */
460} __packed;
461
Pavel Shilovskyfaaf9462011-12-27 16:04:00 +0400462struct smb2_tree_connect_rsp {
463 struct smb2_hdr hdr;
464 __le16 StructureSize; /* Must be 16 */
465 __u8 ShareType; /* see below */
466 __u8 Reserved;
467 __le32 ShareFlags; /* see below */
468 __le32 Capabilities; /* see below */
469 __le32 MaximalAccess;
470} __packed;
471
472/* Possible ShareType values */
473#define SMB2_SHARE_TYPE_DISK 0x01
474#define SMB2_SHARE_TYPE_PIPE 0x02
475#define SMB2_SHARE_TYPE_PRINT 0x03
476
477/*
478 * Possible ShareFlags - exactly one and only one of the first 4 caching flags
479 * must be set (any of the remaining, SHI1005, flags may be set individually
480 * or in combination.
481 */
482#define SMB2_SHAREFLAG_MANUAL_CACHING 0x00000000
483#define SMB2_SHAREFLAG_AUTO_CACHING 0x00000010
484#define SMB2_SHAREFLAG_VDO_CACHING 0x00000020
485#define SMB2_SHAREFLAG_NO_CACHING 0x00000030
486#define SHI1005_FLAGS_DFS 0x00000001
487#define SHI1005_FLAGS_DFS_ROOT 0x00000002
488#define SHI1005_FLAGS_RESTRICT_EXCLUSIVE_OPENS 0x00000100
489#define SHI1005_FLAGS_FORCE_SHARED_DELETE 0x00000200
490#define SHI1005_FLAGS_ALLOW_NAMESPACE_CACHING 0x00000400
491#define SHI1005_FLAGS_ACCESS_BASED_DIRECTORY_ENUM 0x00000800
492#define SHI1005_FLAGS_FORCE_LEVELII_OPLOCK 0x00001000
Steve Frenchc8664732013-06-21 15:35:45 -0500493#define SHI1005_FLAGS_ENABLE_HASH_V1 0x00002000
494#define SHI1005_FLAGS_ENABLE_HASH_V2 0x00004000
495#define SHI1005_FLAGS_ENCRYPT_DATA 0x00008000
Steve French5f60a562018-02-05 14:46:18 -0600496#define SMB2_SHAREFLAG_IDENTITY_REMOTING 0x00040000 /* 3.1.1 */
497#define SHI1005_FLAGS_ALL 0x0004FF33
Pavel Shilovskyfaaf9462011-12-27 16:04:00 +0400498
499/* Possible share capabilities */
Steve French2b5dc282013-06-13 10:51:10 -0500500#define SMB2_SHARE_CAP_DFS cpu_to_le32(0x00000008) /* all dialects */
501#define SMB2_SHARE_CAP_CONTINUOUS_AVAILABILITY cpu_to_le32(0x00000010) /* 3.0 */
502#define SMB2_SHARE_CAP_SCALEOUT cpu_to_le32(0x00000020) /* 3.0 */
503#define SMB2_SHARE_CAP_CLUSTER cpu_to_le32(0x00000040) /* 3.0 */
504#define SMB2_SHARE_CAP_ASYMMETRIC cpu_to_le32(0x00000080) /* 3.02 */
Steve French5f60a562018-02-05 14:46:18 -0600505#define SMB2_SHARE_CAP_REDIRECT_TO_OWNER cpu_to_le32(0x00000100) /* 3.1.1 */
Pavel Shilovskyfaaf9462011-12-27 16:04:00 +0400506
507struct smb2_tree_disconnect_req {
Ronnie Sahlberg4eecf4c2017-11-09 12:14:18 +1100508 struct smb2_sync_hdr sync_hdr;
Pavel Shilovskyfaaf9462011-12-27 16:04:00 +0400509 __le16 StructureSize; /* Must be 4 */
510 __le16 Reserved;
511} __packed;
512
513struct smb2_tree_disconnect_rsp {
514 struct smb2_hdr hdr;
515 __le16 StructureSize; /* Must be 4 */
516 __le16 Reserved;
517} __packed;
518
Pavel Shilovsky2503a0d2011-12-26 22:58:46 +0400519/* File Attrubutes */
520#define FILE_ATTRIBUTE_READONLY 0x00000001
521#define FILE_ATTRIBUTE_HIDDEN 0x00000002
522#define FILE_ATTRIBUTE_SYSTEM 0x00000004
523#define FILE_ATTRIBUTE_DIRECTORY 0x00000010
524#define FILE_ATTRIBUTE_ARCHIVE 0x00000020
525#define FILE_ATTRIBUTE_NORMAL 0x00000080
526#define FILE_ATTRIBUTE_TEMPORARY 0x00000100
527#define FILE_ATTRIBUTE_SPARSE_FILE 0x00000200
528#define FILE_ATTRIBUTE_REPARSE_POINT 0x00000400
529#define FILE_ATTRIBUTE_COMPRESSED 0x00000800
530#define FILE_ATTRIBUTE_OFFLINE 0x00001000
531#define FILE_ATTRIBUTE_NOT_CONTENT_INDEXED 0x00002000
532#define FILE_ATTRIBUTE_ENCRYPTED 0x00004000
Steve French73322972014-09-23 19:25:42 -0500533#define FILE_ATTRIBUTE_INTEGRITY_STREAM 0x00008000
534#define FILE_ATTRIBUTE_NO_SCRUB_DATA 0x00020000
Pavel Shilovsky2503a0d2011-12-26 22:58:46 +0400535
536/* Oplock levels */
537#define SMB2_OPLOCK_LEVEL_NONE 0x00
538#define SMB2_OPLOCK_LEVEL_II 0x01
539#define SMB2_OPLOCK_LEVEL_EXCLUSIVE 0x08
540#define SMB2_OPLOCK_LEVEL_BATCH 0x09
541#define SMB2_OPLOCK_LEVEL_LEASE 0xFF
Pavel Shilovskyb8c32db2012-09-19 06:22:44 -0700542/* Non-spec internal type */
543#define SMB2_OPLOCK_LEVEL_NOCHANGE 0x99
Pavel Shilovsky2503a0d2011-12-26 22:58:46 +0400544
545/* Desired Access Flags */
546#define FILE_READ_DATA_LE cpu_to_le32(0x00000001)
547#define FILE_WRITE_DATA_LE cpu_to_le32(0x00000002)
548#define FILE_APPEND_DATA_LE cpu_to_le32(0x00000004)
549#define FILE_READ_EA_LE cpu_to_le32(0x00000008)
550#define FILE_WRITE_EA_LE cpu_to_le32(0x00000010)
551#define FILE_EXECUTE_LE cpu_to_le32(0x00000020)
552#define FILE_READ_ATTRIBUTES_LE cpu_to_le32(0x00000080)
553#define FILE_WRITE_ATTRIBUTES_LE cpu_to_le32(0x00000100)
554#define FILE_DELETE_LE cpu_to_le32(0x00010000)
555#define FILE_READ_CONTROL_LE cpu_to_le32(0x00020000)
556#define FILE_WRITE_DAC_LE cpu_to_le32(0x00040000)
557#define FILE_WRITE_OWNER_LE cpu_to_le32(0x00080000)
558#define FILE_SYNCHRONIZE_LE cpu_to_le32(0x00100000)
559#define FILE_ACCESS_SYSTEM_SECURITY_LE cpu_to_le32(0x01000000)
560#define FILE_MAXIMAL_ACCESS_LE cpu_to_le32(0x02000000)
561#define FILE_GENERIC_ALL_LE cpu_to_le32(0x10000000)
562#define FILE_GENERIC_EXECUTE_LE cpu_to_le32(0x20000000)
563#define FILE_GENERIC_WRITE_LE cpu_to_le32(0x40000000)
564#define FILE_GENERIC_READ_LE cpu_to_le32(0x80000000)
565
566/* ShareAccess Flags */
567#define FILE_SHARE_READ_LE cpu_to_le32(0x00000001)
568#define FILE_SHARE_WRITE_LE cpu_to_le32(0x00000002)
569#define FILE_SHARE_DELETE_LE cpu_to_le32(0x00000004)
570#define FILE_SHARE_ALL_LE cpu_to_le32(0x00000007)
571
572/* CreateDisposition Flags */
573#define FILE_SUPERSEDE_LE cpu_to_le32(0x00000000)
574#define FILE_OPEN_LE cpu_to_le32(0x00000001)
575#define FILE_CREATE_LE cpu_to_le32(0x00000002)
576#define FILE_OPEN_IF_LE cpu_to_le32(0x00000003)
577#define FILE_OVERWRITE_LE cpu_to_le32(0x00000004)
578#define FILE_OVERWRITE_IF_LE cpu_to_le32(0x00000005)
579
580/* CreateOptions Flags */
581#define FILE_DIRECTORY_FILE_LE cpu_to_le32(0x00000001)
582/* same as #define CREATE_NOT_FILE_LE cpu_to_le32(0x00000001) */
583#define FILE_WRITE_THROUGH_LE cpu_to_le32(0x00000002)
584#define FILE_SEQUENTIAL_ONLY_LE cpu_to_le32(0x00000004)
585#define FILE_NO_INTERMEDIATE_BUFFERRING_LE cpu_to_le32(0x00000008)
586#define FILE_SYNCHRONOUS_IO_ALERT_LE cpu_to_le32(0x00000010)
587#define FILE_SYNCHRONOUS_IO_NON_ALERT_LE cpu_to_le32(0x00000020)
588#define FILE_NON_DIRECTORY_FILE_LE cpu_to_le32(0x00000040)
589#define FILE_COMPLETE_IF_OPLOCKED_LE cpu_to_le32(0x00000100)
590#define FILE_NO_EA_KNOWLEDGE_LE cpu_to_le32(0x00000200)
591#define FILE_RANDOM_ACCESS_LE cpu_to_le32(0x00000800)
592#define FILE_DELETE_ON_CLOSE_LE cpu_to_le32(0x00001000)
593#define FILE_OPEN_BY_FILE_ID_LE cpu_to_le32(0x00002000)
594#define FILE_OPEN_FOR_BACKUP_INTENT_LE cpu_to_le32(0x00004000)
595#define FILE_NO_COMPRESSION_LE cpu_to_le32(0x00008000)
596#define FILE_RESERVE_OPFILTER_LE cpu_to_le32(0x00100000)
597#define FILE_OPEN_REPARSE_POINT_LE cpu_to_le32(0x00200000)
598#define FILE_OPEN_NO_RECALL_LE cpu_to_le32(0x00400000)
599#define FILE_OPEN_FOR_FREE_SPACE_QUERY_LE cpu_to_le32(0x00800000)
600
601#define FILE_READ_RIGHTS_LE (FILE_READ_DATA_LE | FILE_READ_EA_LE \
602 | FILE_READ_ATTRIBUTES_LE)
603#define FILE_WRITE_RIGHTS_LE (FILE_WRITE_DATA_LE | FILE_APPEND_DATA_LE \
604 | FILE_WRITE_EA_LE | FILE_WRITE_ATTRIBUTES_LE)
605#define FILE_EXEC_RIGHTS_LE (FILE_EXECUTE_LE)
606
607/* Impersonation Levels */
608#define IL_ANONYMOUS cpu_to_le32(0x00000000)
609#define IL_IDENTIFICATION cpu_to_le32(0x00000001)
610#define IL_IMPERSONATION cpu_to_le32(0x00000002)
611#define IL_DELEGATE cpu_to_le32(0x00000003)
612
613/* Create Context Values */
614#define SMB2_CREATE_EA_BUFFER "ExtA" /* extended attributes */
615#define SMB2_CREATE_SD_BUFFER "SecD" /* security descriptor */
616#define SMB2_CREATE_DURABLE_HANDLE_REQUEST "DHnQ"
617#define SMB2_CREATE_DURABLE_HANDLE_RECONNECT "DHnC"
Steve French12197a72014-05-14 05:29:40 -0700618#define SMB2_CREATE_ALLOCATION_SIZE "AISi"
Pavel Shilovsky2503a0d2011-12-26 22:58:46 +0400619#define SMB2_CREATE_QUERY_MAXIMAL_ACCESS_REQUEST "MxAc"
620#define SMB2_CREATE_TIMEWARP_REQUEST "TWrp"
621#define SMB2_CREATE_QUERY_ON_DISK_ID "QFid"
622#define SMB2_CREATE_REQUEST_LEASE "RqLs"
Steve French12197a72014-05-14 05:29:40 -0700623#define SMB2_CREATE_DURABLE_HANDLE_REQUEST_V2 "DH2Q"
624#define SMB2_CREATE_DURABLE_HANDLE_RECONNECT_V2 "DH2C"
625#define SMB2_CREATE_APP_INSTANCE_ID 0x45BCA66AEFA7F74A9008FA462E144D74
626#define SVHDX_OPEN_DEVICE_CONTEXT 0x83CE6F1AD851E0986E34401CC9BCFCE9
Pavel Shilovsky2503a0d2011-12-26 22:58:46 +0400627
628struct smb2_create_req {
Ronnie Sahlberg4f33bc32017-11-20 11:24:38 +1100629 struct smb2_sync_hdr sync_hdr;
Pavel Shilovsky2503a0d2011-12-26 22:58:46 +0400630 __le16 StructureSize; /* Must be 57 */
631 __u8 SecurityFlags;
632 __u8 RequestedOplockLevel;
633 __le32 ImpersonationLevel;
634 __le64 SmbCreateFlags;
635 __le64 Reserved;
636 __le32 DesiredAccess;
637 __le32 FileAttributes;
638 __le32 ShareAccess;
639 __le32 CreateDisposition;
640 __le32 CreateOptions;
641 __le16 NameOffset;
642 __le16 NameLength;
643 __le32 CreateContextsOffset;
644 __le32 CreateContextsLength;
Pavel Shilovsky59aa3712013-07-04 19:41:24 +0400645 __u8 Buffer[0];
Pavel Shilovsky2503a0d2011-12-26 22:58:46 +0400646} __packed;
647
648struct smb2_create_rsp {
649 struct smb2_hdr hdr;
650 __le16 StructureSize; /* Must be 89 */
651 __u8 OplockLevel;
652 __u8 Reserved;
653 __le32 CreateAction;
654 __le64 CreationTime;
655 __le64 LastAccessTime;
656 __le64 LastWriteTime;
657 __le64 ChangeTime;
658 __le64 AllocationSize;
659 __le64 EndofFile;
660 __le32 FileAttributes;
661 __le32 Reserved2;
662 __u64 PersistentFileId; /* opaque endianness */
663 __u64 VolatileFileId; /* opaque endianness */
664 __le32 CreateContextsOffset;
665 __le32 CreateContextsLength;
666 __u8 Buffer[1];
667} __packed;
668
Pavel Shilovskyb8c32db2012-09-19 06:22:44 -0700669struct create_context {
670 __le32 Next;
671 __le16 NameOffset;
672 __le16 NameLength;
673 __le16 Reserved;
674 __le16 DataOffset;
675 __le32 DataLength;
676 __u8 Buffer[0];
677} __packed;
678
Pavel Shilovsky53ef1012013-09-05 16:11:28 +0400679#define SMB2_LEASE_READ_CACHING_HE 0x01
680#define SMB2_LEASE_HANDLE_CACHING_HE 0x02
681#define SMB2_LEASE_WRITE_CACHING_HE 0x04
682
Fabian Frederickbc09d142014-12-10 15:41:15 -0800683#define SMB2_LEASE_NONE cpu_to_le32(0x00)
684#define SMB2_LEASE_READ_CACHING cpu_to_le32(0x01)
685#define SMB2_LEASE_HANDLE_CACHING cpu_to_le32(0x02)
686#define SMB2_LEASE_WRITE_CACHING cpu_to_le32(0x04)
Pavel Shilovskyb8c32db2012-09-19 06:22:44 -0700687
Fabian Frederickbc09d142014-12-10 15:41:15 -0800688#define SMB2_LEASE_FLAG_BREAK_IN_PROGRESS cpu_to_le32(0x02)
Steve French5f60a562018-02-05 14:46:18 -0600689#define SMB2_LEASE_FLAG_PARENT_LEASE_KEY_SET cpu_to_le32(0x00000004)
Pavel Shilovskyb8c32db2012-09-19 06:22:44 -0700690
691#define SMB2_LEASE_KEY_SIZE 16
692
693struct lease_context {
694 __le64 LeaseKeyLow;
695 __le64 LeaseKeyHigh;
696 __le32 LeaseState;
697 __le32 LeaseFlags;
698 __le64 LeaseDuration;
699} __packed;
700
Pavel Shilovskyf0473902013-09-04 13:44:05 +0400701struct lease_context_v2 {
702 __le64 LeaseKeyLow;
703 __le64 LeaseKeyHigh;
704 __le32 LeaseState;
705 __le32 LeaseFlags;
706 __le64 LeaseDuration;
707 __le64 ParentLeaseKeyLow;
708 __le64 ParentLeaseKeyHigh;
709 __le16 Epoch;
710 __le16 Reserved;
711} __packed;
712
Pavel Shilovskyb8c32db2012-09-19 06:22:44 -0700713struct create_lease {
714 struct create_context ccontext;
715 __u8 Name[8];
716 struct lease_context lcontext;
717} __packed;
718
Pavel Shilovskyf0473902013-09-04 13:44:05 +0400719struct create_lease_v2 {
720 struct create_context ccontext;
721 __u8 Name[8];
722 struct lease_context_v2 lcontext;
723 __u8 Pad[4];
724} __packed;
725
Pavel Shilovsky63eb3de2013-07-04 18:41:09 +0400726struct create_durable {
727 struct create_context ccontext;
728 __u8 Name[8];
Pavel Shilovsky9cbc0b72013-07-09 18:40:58 +0400729 union {
730 __u8 Reserved[16];
731 struct {
732 __u64 PersistentFileId;
733 __u64 VolatileFileId;
734 } Fid;
735 } Data;
Pavel Shilovsky63eb3de2013-07-04 18:41:09 +0400736} __packed;
737
Steve Frenchb56eae42015-11-03 09:26:27 -0600738/* See MS-SMB2 2.2.13.2.11 */
739/* Flags */
740#define SMB2_DHANDLE_FLAG_PERSISTENT 0x00000002
741struct durable_context_v2 {
742 __le32 Timeout;
743 __le32 Flags;
744 __u64 Reserved;
745 __u8 CreateGuid[16];
746} __packed;
747
748struct create_durable_v2 {
749 struct create_context ccontext;
750 __u8 Name[8];
751 struct durable_context_v2 dcontext;
752} __packed;
753
754/* See MS-SMB2 2.2.13.2.12 */
755struct durable_reconnect_context_v2 {
756 struct {
757 __u64 PersistentFileId;
758 __u64 VolatileFileId;
759 } Fid;
760 __u8 CreateGuid[16];
761 __le32 Flags; /* see above DHANDLE_FLAG_PERSISTENT */
762} __packed;
763
764/* See MS-SMB2 2.2.14.2.12 */
765struct durable_reconnect_context_v2_rsp {
766 __le32 Timeout;
767 __le32 Flags; /* see above DHANDLE_FLAG_PERSISTENT */
768} __packed;
769
770struct create_durable_handle_reconnect_v2 {
771 struct create_context ccontext;
772 __u8 Name[8];
773 struct durable_reconnect_context_v2 dcontext;
774} __packed;
775
Steve French41c13582013-11-14 00:05:36 -0600776#define COPY_CHUNK_RES_KEY_SIZE 24
777struct resume_key_req {
778 char ResumeKey[COPY_CHUNK_RES_KEY_SIZE];
779 __le32 ContextLength; /* MBZ */
780 char Context[0]; /* ignored, Windows sets to 4 bytes of zero */
781} __packed;
782
Steve Frenchbe7457d2013-06-19 17:41:10 -0500783/* this goes in the ioctl buffer when doing a copychunk request */
784struct copychunk_ioctl {
Steve French41c13582013-11-14 00:05:36 -0600785 char SourceKey[COPY_CHUNK_RES_KEY_SIZE];
Steve Frenchbe7457d2013-06-19 17:41:10 -0500786 __le32 ChunkCount; /* we are only sending 1 */
787 __le32 Reserved;
788 /* array will only be one chunk long for us */
789 __le64 SourceOffset;
790 __le64 TargetOffset;
Steve Frenchc8664732013-06-21 15:35:45 -0500791 __le32 Length; /* how many bytes to copy */
Steve Frenchbe7457d2013-06-19 17:41:10 -0500792 __u32 Reserved2;
793} __packed;
794
Steve French31742c52014-08-17 08:38:47 -0500795/* this goes in the ioctl buffer when doing FSCTL_SET_ZERO_DATA */
796struct file_zero_data_information {
797 __le64 FileOffset;
798 __le64 BeyondFinalZero;
799} __packed;
800
Steve French41c13582013-11-14 00:05:36 -0600801struct copychunk_ioctl_rsp {
802 __le32 ChunksWritten;
803 __le32 ChunkBytesWritten;
804 __le32 TotalBytesWritten;
805} __packed;
806
Steve French9d1b0662015-06-24 02:12:19 -0500807struct fsctl_set_integrity_information_req {
808 __le16 ChecksumAlgorithm;
809 __le16 Reserved;
810 __le32 Flags;
811} __packed;
812
813struct fsctl_get_integrity_information_rsp {
814 __le16 ChecksumAlgorithm;
815 __le16 Reserved;
816 __le32 Flags;
817 __le32 ChecksumChunkSizeInBytes;
818 __le32 ClusterSizeInBytes;
819} __packed;
820
821/* Integrity ChecksumAlgorithm choices for above */
822#define CHECKSUM_TYPE_NONE 0x0000
823#define CHECKSUM_TYPE_CRC64 0x0002
Steve Frenchb3152e22015-06-24 03:17:02 -0500824#define CHECKSUM_TYPE_UNCHANGED 0xFFFF /* set only */
Steve French9d1b0662015-06-24 02:12:19 -0500825
826/* Integrity flags for above */
827#define FSCTL_INTEGRITY_FLAG_CHECKSUM_ENFORCEMENT_OFF 0x00000001
828
Aurelien Aptel9d496402017-02-13 16:16:49 +0100829/* See MS-DFSC 2.2.2 */
830struct fsctl_get_dfs_referral_req {
831 __le16 MaxReferralLevel;
832 __u8 RequestFileName[];
833} __packed;
834
835/* DFS response is struct get_dfs_refer_rsp */
836
Steve Frenchb56eae42015-11-03 09:26:27 -0600837/* See MS-SMB2 2.2.31.3 */
838struct network_resiliency_req {
839 __le32 Timeout;
840 __le32 Reserved;
841} __packed;
842/* There is no buffer for the response ie no struct network_resiliency_rsp */
843
Steve French9d1b0662015-06-24 02:12:19 -0500844
Steve Frenchff1c0382013-11-19 23:44:46 -0600845struct validate_negotiate_info_req {
Steve French4a72daf2013-06-25 00:20:49 -0500846 __le32 Capabilities;
847 __u8 Guid[SMB2_CLIENT_GUID_SIZE];
848 __le16 SecurityMode;
849 __le16 DialectCount;
Steve French9764c022017-09-17 10:41:35 -0500850 __le16 Dialects[3]; /* BB expand this if autonegotiate > 3 dialects */
Steve Frenchff1c0382013-11-19 23:44:46 -0600851} __packed;
852
853struct validate_negotiate_info_rsp {
854 __le32 Capabilities;
855 __u8 Guid[SMB2_CLIENT_GUID_SIZE];
856 __le16 SecurityMode;
857 __le16 Dialect; /* Dialect in use for the connection */
Steve French4a72daf2013-06-25 00:20:49 -0500858} __packed;
859
860#define RSS_CAPABLE 0x00000001
861#define RDMA_CAPABLE 0x00000002
862
863struct network_interface_info_ioctl_rsp {
864 __le32 Next; /* next interface. zero if this is last one */
865 __le32 IfIndex;
866 __le32 Capability; /* RSS or RDMA Capable */
867 __le32 Reserved;
868 __le64 LinkSpeed;
869 char SockAddr_Storage[128];
870} __packed;
871
872#define NO_FILE_ID 0xFFFFFFFFFFFFFFFFULL /* general ioctls to srv not to file */
873
Steve French64a5cfa2013-10-14 15:31:32 -0500874struct compress_ioctl {
Steve Frenchc7f508a2013-10-14 15:27:32 -0500875 __le16 CompressionState; /* See cifspdu.h for possible flag values */
Steve French64a5cfa2013-10-14 15:31:32 -0500876} __packed;
877
Steve French02b16662015-06-27 21:18:36 -0700878struct duplicate_extents_to_file {
879 __u64 PersistentFileHandle; /* source file handle, opaque endianness */
880 __u64 VolatileFileHandle;
881 __le64 SourceFileOffset;
882 __le64 TargetFileOffset;
883 __le64 ByteCount; /* Bytes to be copied */
884} __packed;
885
Steve Frenchbe7457d2013-06-19 17:41:10 -0500886struct smb2_ioctl_req {
Ronnie Sahlberg97754682017-11-09 12:14:20 +1100887 struct smb2_sync_hdr sync_hdr;
Steve Frenchbe7457d2013-06-19 17:41:10 -0500888 __le16 StructureSize; /* Must be 57 */
889 __u16 Reserved;
890 __le32 CtlCode;
891 __u64 PersistentFileId; /* opaque endianness */
892 __u64 VolatileFileId; /* opaque endianness */
893 __le32 InputOffset;
894 __le32 InputCount;
895 __le32 MaxInputResponse;
896 __le32 OutputOffset;
897 __le32 OutputCount;
898 __le32 MaxOutputResponse;
899 __le32 Flags;
900 __u32 Reserved2;
Steve French64a5cfa2013-10-14 15:31:32 -0500901 __u8 Buffer[0];
Steve Frenchbe7457d2013-06-19 17:41:10 -0500902} __packed;
903
904struct smb2_ioctl_rsp {
905 struct smb2_hdr hdr;
906 __le16 StructureSize; /* Must be 57 */
907 __u16 Reserved;
908 __le32 CtlCode;
909 __u64 PersistentFileId; /* opaque endianness */
910 __u64 VolatileFileId; /* opaque endianness */
911 __le32 InputOffset;
912 __le32 InputCount;
913 __le32 OutputOffset;
914 __le32 OutputCount;
915 __le32 Flags;
916 __u32 Reserved2;
917 /* char * buffer[] */
918} __packed;
919
Pavel Shilovsky2503a0d2011-12-26 22:58:46 +0400920/* Currently defined values for close flags */
921#define SMB2_CLOSE_FLAG_POSTQUERY_ATTRIB cpu_to_le16(0x0001)
922struct smb2_close_req {
Ronnie Sahlbergafcccef2017-11-09 12:14:19 +1100923 struct smb2_sync_hdr sync_hdr;
Pavel Shilovsky2503a0d2011-12-26 22:58:46 +0400924 __le16 StructureSize; /* Must be 24 */
925 __le16 Flags;
926 __le32 Reserved;
927 __u64 PersistentFileId; /* opaque endianness */
928 __u64 VolatileFileId; /* opaque endianness */
929} __packed;
930
931struct smb2_close_rsp {
932 struct smb2_hdr hdr;
933 __le16 StructureSize; /* 60 */
934 __le16 Flags;
935 __le32 Reserved;
936 __le64 CreationTime;
937 __le64 LastAccessTime;
938 __le64 LastWriteTime;
939 __le64 ChangeTime;
940 __le64 AllocationSize; /* Beginning of FILE_STANDARD_INFO equivalent */
941 __le64 EndOfFile;
942 __le32 Attributes;
943} __packed;
944
Pavel Shilovsky7a5cfb12012-09-18 16:20:28 -0700945struct smb2_flush_req {
Ronnie Sahlberg1f444e42017-11-20 11:24:39 +1100946 struct smb2_sync_hdr sync_hdr;
Pavel Shilovsky7a5cfb12012-09-18 16:20:28 -0700947 __le16 StructureSize; /* Must be 24 */
948 __le16 Reserved1;
949 __le32 Reserved2;
950 __u64 PersistentFileId; /* opaque endianness */
951 __u64 VolatileFileId; /* opaque endianness */
952} __packed;
953
954struct smb2_flush_rsp {
955 struct smb2_hdr hdr;
956 __le16 StructureSize;
957 __le16 Reserved;
958} __packed;
959
Steve French2b5dc282013-06-13 10:51:10 -0500960/* For read request Flags field below, following flag is defined for SMB3.02 */
961#define SMB2_READFLAG_READ_UNBUFFERED 0x01
962
963/* Channel field for read and write: exactly one of following flags can be set*/
Steve French2026b062018-01-24 23:07:41 -0600964#define SMB2_CHANNEL_NONE cpu_to_le32(0x00000000)
965#define SMB2_CHANNEL_RDMA_V1 cpu_to_le32(0x00000001) /* SMB3 or later */
966#define SMB2_CHANNEL_RDMA_V1_INVALIDATE cpu_to_le32(0x00000002) /* >= SMB3.02 */
Steve French2b5dc282013-06-13 10:51:10 -0500967
Pavel Shilovskyb8f57ee2016-11-23 15:31:54 -0800968/* SMB2 read request without RFC1001 length at the beginning */
969struct smb2_read_plain_req {
970 struct smb2_sync_hdr sync_hdr;
Pavel Shilovsky09a47072012-09-18 16:20:29 -0700971 __le16 StructureSize; /* Must be 49 */
972 __u8 Padding; /* offset from start of SMB2 header to place read */
Steve French2b5dc282013-06-13 10:51:10 -0500973 __u8 Flags; /* MBZ unless SMB3.02 or later */
Pavel Shilovsky09a47072012-09-18 16:20:29 -0700974 __le32 Length;
975 __le64 Offset;
976 __u64 PersistentFileId; /* opaque endianness */
977 __u64 VolatileFileId; /* opaque endianness */
978 __le32 MinimumCount;
Steve French2b5dc282013-06-13 10:51:10 -0500979 __le32 Channel; /* MBZ except for SMB3 or later */
Pavel Shilovsky09a47072012-09-18 16:20:29 -0700980 __le32 RemainingBytes;
Steve French2026b062018-01-24 23:07:41 -0600981 __le16 ReadChannelInfoOffset;
982 __le16 ReadChannelInfoLength;
Pavel Shilovsky09a47072012-09-18 16:20:29 -0700983 __u8 Buffer[1];
984} __packed;
985
986struct smb2_read_rsp {
987 struct smb2_hdr hdr;
988 __le16 StructureSize; /* Must be 17 */
989 __u8 DataOffset;
990 __u8 Reserved;
991 __le32 DataLength;
992 __le32 DataRemaining;
993 __u32 Reserved2;
994 __u8 Buffer[1];
995} __packed;
996
Steve French2b5dc282013-06-13 10:51:10 -0500997/* For write request Flags field below the following flags are defined: */
998#define SMB2_WRITEFLAG_WRITE_THROUGH 0x00000001 /* SMB2.1 or later */
999#define SMB2_WRITEFLAG_WRITE_UNBUFFERED 0x00000002 /* SMB3.02 or later */
Pavel Shilovsky33319142012-09-18 16:20:29 -07001000
1001struct smb2_write_req {
Ronnie Sahlbergf5688a62017-11-20 11:24:41 +11001002 struct smb2_sync_hdr sync_hdr;
Pavel Shilovsky33319142012-09-18 16:20:29 -07001003 __le16 StructureSize; /* Must be 49 */
1004 __le16 DataOffset; /* offset from start of SMB2 header to write data */
1005 __le32 Length;
1006 __le64 Offset;
1007 __u64 PersistentFileId; /* opaque endianness */
1008 __u64 VolatileFileId; /* opaque endianness */
1009 __le32 Channel; /* Reserved MBZ */
1010 __le32 RemainingBytes;
Steve French2026b062018-01-24 23:07:41 -06001011 __le16 WriteChannelInfoOffset;
1012 __le16 WriteChannelInfoLength;
Pavel Shilovsky33319142012-09-18 16:20:29 -07001013 __le32 Flags;
1014 __u8 Buffer[1];
1015} __packed;
1016
1017struct smb2_write_rsp {
1018 struct smb2_hdr hdr;
1019 __le16 StructureSize; /* Must be 17 */
1020 __u8 DataOffset;
1021 __u8 Reserved;
1022 __le32 DataLength;
1023 __le32 DataRemaining;
1024 __u32 Reserved2;
1025 __u8 Buffer[1];
1026} __packed;
1027
Pavel Shilovsky027e8ee2012-09-19 06:22:43 -07001028#define SMB2_LOCKFLAG_SHARED_LOCK 0x0001
1029#define SMB2_LOCKFLAG_EXCLUSIVE_LOCK 0x0002
1030#define SMB2_LOCKFLAG_UNLOCK 0x0004
1031#define SMB2_LOCKFLAG_FAIL_IMMEDIATELY 0x0010
1032
Pavel Shilovskyf7ba7fe2012-09-19 06:22:43 -07001033struct smb2_lock_element {
1034 __le64 Offset;
1035 __le64 Length;
1036 __le32 Flags;
1037 __le32 Reserved;
1038} __packed;
1039
1040struct smb2_lock_req {
Ronnie Sahlbergced93672017-11-21 10:07:27 +11001041 struct smb2_sync_hdr sync_hdr;
Pavel Shilovskyf7ba7fe2012-09-19 06:22:43 -07001042 __le16 StructureSize; /* Must be 48 */
1043 __le16 LockCount;
1044 __le32 Reserved;
1045 __u64 PersistentFileId; /* opaque endianness */
1046 __u64 VolatileFileId; /* opaque endianness */
1047 /* Followed by at least one */
1048 struct smb2_lock_element locks[1];
1049} __packed;
1050
1051struct smb2_lock_rsp {
1052 struct smb2_hdr hdr;
1053 __le16 StructureSize; /* Must be 4 */
1054 __le16 Reserved;
1055} __packed;
1056
Pavel Shilovsky9094fad2012-07-12 18:30:44 +04001057struct smb2_echo_req {
Ronnie Sahlberg7f7ae752017-11-09 12:14:21 +11001058 struct smb2_sync_hdr sync_hdr;
Pavel Shilovsky9094fad2012-07-12 18:30:44 +04001059 __le16 StructureSize; /* Must be 4 */
1060 __u16 Reserved;
1061} __packed;
1062
1063struct smb2_echo_rsp {
1064 struct smb2_hdr hdr;
1065 __le16 StructureSize; /* Must be 4 */
1066 __u16 Reserved;
1067} __packed;
1068
Pavel Shilovskyd324f08d2012-09-18 16:20:33 -07001069/* search (query_directory) Flags field */
1070#define SMB2_RESTART_SCANS 0x01
1071#define SMB2_RETURN_SINGLE_ENTRY 0x02
1072#define SMB2_INDEX_SPECIFIED 0x04
1073#define SMB2_REOPEN 0x10
1074
1075struct smb2_query_directory_req {
Ronnie Sahlberg7c00c3a2017-11-20 11:24:45 +11001076 struct smb2_sync_hdr sync_hdr;
Pavel Shilovskyd324f08d2012-09-18 16:20:33 -07001077 __le16 StructureSize; /* Must be 33 */
1078 __u8 FileInformationClass;
1079 __u8 Flags;
1080 __le32 FileIndex;
1081 __u64 PersistentFileId; /* opaque endianness */
1082 __u64 VolatileFileId; /* opaque endianness */
1083 __le16 FileNameOffset;
1084 __le16 FileNameLength;
1085 __le32 OutputBufferLength;
1086 __u8 Buffer[1];
1087} __packed;
1088
1089struct smb2_query_directory_rsp {
1090 struct smb2_hdr hdr;
1091 __le16 StructureSize; /* Must be 9 */
1092 __le16 OutputBufferOffset;
1093 __le32 OutputBufferLength;
1094 __u8 Buffer[1];
1095} __packed;
1096
Pavel Shilovskybe4cb9e2011-12-29 17:06:33 +04001097/* Possible InfoType values */
1098#define SMB2_O_INFO_FILE 0x01
1099#define SMB2_O_INFO_FILESYSTEM 0x02
1100#define SMB2_O_INFO_SECURITY 0x03
1101#define SMB2_O_INFO_QUOTA 0x04
1102
Steve French911a8df2014-10-19 19:18:05 -05001103/* Security info type additionalinfo flags. See MS-SMB2 (2.2.37) or MS-DTYP */
1104#define OWNER_SECINFO 0x00000001
1105#define GROUP_SECINFO 0x00000002
1106#define DACL_SECINFO 0x00000004
1107#define SACL_SECINFO 0x00000008
1108#define LABEL_SECINFO 0x00000010
1109#define ATTRIBUTE_SECINFO 0x00000020
1110#define SCOPE_SECINFO 0x00000040
1111#define BACKUP_SECINFO 0x00010000
1112#define UNPROTECTED_SACL_SECINFO 0x10000000
1113#define UNPROTECTED_DACL_SECINFO 0x20000000
1114#define PROTECTED_SACL_SECINFO 0x40000000
1115#define PROTECTED_DACL_SECINFO 0x80000000
1116
1117/* Flags used for FileFullEAinfo */
1118#define SL_RESTART_SCAN 0x00000001
1119#define SL_RETURN_SINGLE_ENTRY 0x00000002
1120#define SL_INDEX_SPECIFIED 0x00000004
1121
Pavel Shilovskybe4cb9e2011-12-29 17:06:33 +04001122struct smb2_query_info_req {
Ronnie Sahlbergb2fb7fe2017-11-20 11:24:46 +11001123 struct smb2_sync_hdr sync_hdr;
Pavel Shilovskybe4cb9e2011-12-29 17:06:33 +04001124 __le16 StructureSize; /* Must be 41 */
1125 __u8 InfoType;
1126 __u8 FileInfoClass;
1127 __le32 OutputBufferLength;
1128 __le16 InputBufferOffset;
1129 __u16 Reserved;
1130 __le32 InputBufferLength;
1131 __le32 AdditionalInformation;
1132 __le32 Flags;
1133 __u64 PersistentFileId; /* opaque endianness */
1134 __u64 VolatileFileId; /* opaque endianness */
1135 __u8 Buffer[1];
1136} __packed;
1137
1138struct smb2_query_info_rsp {
1139 struct smb2_hdr hdr;
1140 __le16 StructureSize; /* Must be 9 */
1141 __le16 OutputBufferOffset;
1142 __le32 OutputBufferLength;
1143 __u8 Buffer[1];
1144} __packed;
1145
Pavel Shilovsky35143eb2012-09-18 16:20:31 -07001146struct smb2_set_info_req {
Ronnie Sahlberg2fc803e2017-11-20 11:24:44 +11001147 struct smb2_sync_hdr sync_hdr;
Pavel Shilovsky35143eb2012-09-18 16:20:31 -07001148 __le16 StructureSize; /* Must be 33 */
1149 __u8 InfoType;
1150 __u8 FileInfoClass;
1151 __le32 BufferLength;
1152 __le16 BufferOffset;
1153 __u16 Reserved;
1154 __le32 AdditionalInformation;
1155 __u64 PersistentFileId; /* opaque endianness */
1156 __u64 VolatileFileId; /* opaque endianness */
1157 __u8 Buffer[1];
1158} __packed;
1159
1160struct smb2_set_info_rsp {
1161 struct smb2_hdr hdr;
1162 __le16 StructureSize; /* Must be 2 */
1163} __packed;
1164
Ronnie Sahlberg21ad9482017-11-20 11:24:43 +11001165/* oplock break without an rfc1002 header */
1166struct smb2_oplock_break_req {
1167 struct smb2_sync_hdr sync_hdr;
1168 __le16 StructureSize; /* Must be 24 */
1169 __u8 OplockLevel;
1170 __u8 Reserved;
1171 __le32 Reserved2;
1172 __u64 PersistentFid;
1173 __u64 VolatileFid;
1174} __packed;
1175
1176/* oplock break with an rfc1002 header */
1177struct smb2_oplock_break_rsp {
Pavel Shilovsky983c88a2012-09-18 16:20:33 -07001178 struct smb2_hdr hdr;
1179 __le16 StructureSize; /* Must be 24 */
1180 __u8 OplockLevel;
1181 __u8 Reserved;
1182 __le32 Reserved2;
1183 __u64 PersistentFid;
1184 __u64 VolatileFid;
1185} __packed;
1186
Pavel Shilovsky0822f512012-09-19 06:22:45 -07001187#define SMB2_NOTIFY_BREAK_LEASE_FLAG_ACK_REQUIRED cpu_to_le32(0x01)
1188
1189struct smb2_lease_break {
1190 struct smb2_hdr hdr;
1191 __le16 StructureSize; /* Must be 44 */
1192 __le16 Reserved;
1193 __le32 Flags;
1194 __u8 LeaseKey[16];
1195 __le32 CurrentLeaseState;
1196 __le32 NewLeaseState;
1197 __le32 BreakReason;
1198 __le32 AccessMaskHint;
1199 __le32 ShareMaskHint;
1200} __packed;
1201
1202struct smb2_lease_ack {
Ronnie Sahlberg8eb79982017-11-21 11:04:37 +11001203 struct smb2_sync_hdr sync_hdr;
Pavel Shilovsky0822f512012-09-19 06:22:45 -07001204 __le16 StructureSize; /* Must be 36 */
1205 __le16 Reserved;
1206 __le32 Flags;
1207 __u8 LeaseKey[16];
1208 __le32 LeaseState;
1209 __le64 LeaseDuration;
1210} __packed;
1211
Pavel Shilovskybe4cb9e2011-12-29 17:06:33 +04001212/*
1213 * PDU infolevel structure definitions
1214 * BB consider moving to a different header
1215 */
1216
Pavel Shilovsky6fc05c22012-09-18 16:20:34 -07001217/* File System Information Classes */
1218#define FS_VOLUME_INFORMATION 1 /* Query */
Steven Frenchaf6a12e2013-10-09 20:55:53 -05001219#define FS_LABEL_INFORMATION 2 /* Local only */
Pavel Shilovsky6fc05c22012-09-18 16:20:34 -07001220#define FS_SIZE_INFORMATION 3 /* Query */
1221#define FS_DEVICE_INFORMATION 4 /* Query */
1222#define FS_ATTRIBUTE_INFORMATION 5 /* Query */
1223#define FS_CONTROL_INFORMATION 6 /* Query, Set */
1224#define FS_FULL_SIZE_INFORMATION 7 /* Query */
1225#define FS_OBJECT_ID_INFORMATION 8 /* Query, Set */
Steven Frenchaf6a12e2013-10-09 20:55:53 -05001226#define FS_DRIVER_PATH_INFORMATION 9 /* Local only */
1227#define FS_VOLUME_FLAGS_INFORMATION 10 /* Local only */
1228#define FS_SECTOR_SIZE_INFORMATION 11 /* SMB3 or later. Query */
Pavel Shilovsky6fc05c22012-09-18 16:20:34 -07001229
1230struct smb2_fs_full_size_info {
1231 __le64 TotalAllocationUnits;
1232 __le64 CallerAvailableAllocationUnits;
1233 __le64 ActualAvailableAllocationUnits;
1234 __le32 SectorsPerAllocationUnit;
1235 __le32 BytesPerSector;
1236} __packed;
1237
Steven Frenchaf6a12e2013-10-09 20:55:53 -05001238#define SSINFO_FLAGS_ALIGNED_DEVICE 0x00000001
1239#define SSINFO_FLAGS_PARTITION_ALIGNED_ON_DEVICE 0x00000002
1240#define SSINFO_FLAGS_NO_SEEK_PENALTY 0x00000004
1241#define SSINFO_FLAGS_TRIM_ENABLED 0x00000008
1242
1243/* sector size info struct */
1244struct smb3_fs_ss_info {
1245 __le32 LogicalBytesPerSector;
1246 __le32 PhysicalBytesPerSectorForAtomicity;
1247 __le32 PhysicalBytesPerSectorForPerf;
1248 __le32 FileSystemEffectivePhysicalBytesPerSectorForAtomicity;
1249 __le32 Flags;
1250 __le32 ByteOffsetForSectorAlignment;
1251 __le32 ByteOffsetForPartitionAlignment;
1252} __packed;
1253
Pavel Shilovskybe4cb9e2011-12-29 17:06:33 +04001254/* partial list of QUERY INFO levels */
1255#define FILE_DIRECTORY_INFORMATION 1
1256#define FILE_FULL_DIRECTORY_INFORMATION 2
1257#define FILE_BOTH_DIRECTORY_INFORMATION 3
1258#define FILE_BASIC_INFORMATION 4
1259#define FILE_STANDARD_INFORMATION 5
1260#define FILE_INTERNAL_INFORMATION 6
1261#define FILE_EA_INFORMATION 7
1262#define FILE_ACCESS_INFORMATION 8
1263#define FILE_NAME_INFORMATION 9
1264#define FILE_RENAME_INFORMATION 10
1265#define FILE_LINK_INFORMATION 11
1266#define FILE_NAMES_INFORMATION 12
1267#define FILE_DISPOSITION_INFORMATION 13
1268#define FILE_POSITION_INFORMATION 14
1269#define FILE_FULL_EA_INFORMATION 15
1270#define FILE_MODE_INFORMATION 16
1271#define FILE_ALIGNMENT_INFORMATION 17
1272#define FILE_ALL_INFORMATION 18
1273#define FILE_ALLOCATION_INFORMATION 19
1274#define FILE_END_OF_FILE_INFORMATION 20
1275#define FILE_ALTERNATE_NAME_INFORMATION 21
1276#define FILE_STREAM_INFORMATION 22
1277#define FILE_PIPE_INFORMATION 23
1278#define FILE_PIPE_LOCAL_INFORMATION 24
1279#define FILE_PIPE_REMOTE_INFORMATION 25
1280#define FILE_MAILSLOT_QUERY_INFORMATION 26
1281#define FILE_MAILSLOT_SET_INFORMATION 27
1282#define FILE_COMPRESSION_INFORMATION 28
1283#define FILE_OBJECT_ID_INFORMATION 29
1284/* Number 30 not defined in documents */
1285#define FILE_MOVE_CLUSTER_INFORMATION 31
1286#define FILE_QUOTA_INFORMATION 32
1287#define FILE_REPARSE_POINT_INFORMATION 33
1288#define FILE_NETWORK_OPEN_INFORMATION 34
1289#define FILE_ATTRIBUTE_TAG_INFORMATION 35
1290#define FILE_TRACKING_INFORMATION 36
1291#define FILEID_BOTH_DIRECTORY_INFORMATION 37
1292#define FILEID_FULL_DIRECTORY_INFORMATION 38
1293#define FILE_VALID_DATA_LENGTH_INFORMATION 39
1294#define FILE_SHORT_NAME_INFORMATION 40
1295#define FILE_SFIO_RESERVE_INFORMATION 44
1296#define FILE_SFIO_VOLUME_INFORMATION 45
1297#define FILE_HARD_LINK_INFORMATION 46
1298#define FILE_NORMALIZED_NAME_INFORMATION 48
1299#define FILEID_GLOBAL_TX_DIRECTORY_INFORMATION 50
1300#define FILE_STANDARD_LINK_INFORMATION 54
1301
Pavel Shilovskyf0df7372012-09-18 16:20:26 -07001302struct smb2_file_internal_info {
1303 __le64 IndexNumber;
1304} __packed; /* level 6 Query */
1305
Pavel Shilovsky35143eb2012-09-18 16:20:31 -07001306struct smb2_file_rename_info { /* encoding of request for level 10 */
1307 __u8 ReplaceIfExists; /* 1 = replace existing target with new */
1308 /* 0 = fail if target already exists */
1309 __u8 Reserved[7];
1310 __u64 RootDirectory; /* MBZ for network operations (why says spec?) */
1311 __le32 FileNameLength;
1312 char FileName[0]; /* New name to be assigned */
1313} __packed; /* level 10 Set */
1314
Pavel Shilovsky568798c2012-09-18 16:20:31 -07001315struct smb2_file_link_info { /* encoding of request for level 11 */
1316 __u8 ReplaceIfExists; /* 1 = replace existing link with new */
1317 /* 0 = fail if link already exists */
1318 __u8 Reserved[7];
1319 __u64 RootDirectory; /* MBZ for network operations (why says spec?) */
1320 __le32 FileNameLength;
1321 char FileName[0]; /* Name to be assigned to new link */
1322} __packed; /* level 11 Set */
1323
Ronnie Sahlberg7cb3def2017-09-28 09:39:58 +10001324#define SMB2_MIN_EA_BUF 2048
1325#define SMB2_MAX_EA_BUF 65536
Ronnie Sahlberg95907fe2017-08-24 11:24:55 +10001326
1327struct smb2_file_full_ea_info { /* encoding of response for level 15 */
1328 __le32 next_entry_offset;
1329 __u8 flags;
1330 __u8 ea_name_length;
1331 __le16 ea_value_length;
1332 char ea_data[0]; /* \0 terminated name plus value */
1333} __packed; /* level 15 Set */
1334
Pavel Shilovskybe4cb9e2011-12-29 17:06:33 +04001335/*
1336 * This level 18, although with struct with same name is different from cifs
1337 * level 0x107. Level 0x107 has an extra u64 between AccessFlags and
1338 * CurrentByteOffset.
1339 */
1340struct smb2_file_all_info { /* data block encoding of response to level 18 */
1341 __le64 CreationTime; /* Beginning of FILE_BASIC_INFO equivalent */
1342 __le64 LastAccessTime;
1343 __le64 LastWriteTime;
1344 __le64 ChangeTime;
1345 __le32 Attributes;
1346 __u32 Pad1; /* End of FILE_BASIC_INFO_INFO equivalent */
1347 __le64 AllocationSize; /* Beginning of FILE_STANDARD_INFO equivalent */
1348 __le64 EndOfFile; /* size ie offset to first free byte in file */
1349 __le32 NumberOfLinks; /* hard links */
1350 __u8 DeletePending;
1351 __u8 Directory;
1352 __u16 Pad2; /* End of FILE_STANDARD_INFO equivalent */
1353 __le64 IndexNumber;
1354 __le32 EASize;
1355 __le32 AccessFlags;
1356 __le64 CurrentByteOffset;
1357 __le32 Mode;
1358 __le32 AlignmentRequirement;
1359 __le32 FileNameLength;
1360 char FileName[1];
1361} __packed; /* level 18 Query */
1362
Pavel Shilovskyc839ff22012-09-18 16:20:32 -07001363struct smb2_file_eof_info { /* encoding of request for level 10 */
1364 __le64 EndOfFile; /* new end of file value */
1365} __packed; /* level 20 Set */
1366
Steve Frenchddfbefb2011-03-15 02:08:48 +00001367#endif /* _SMB2PDU_H */