blob: 4a7d154fffae640ec4f03bb2bcf1f8aaa9e7294d [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>
Steve Frenchfdef6652019-12-06 02:02:38 -060028#include <cifsacl.h>
Steve Frenchddfbefb2011-03-15 02:08:48 +000029
30/*
Pavel Shilovsky2dc7e1c2011-12-26 22:53:34 +040031 * Note that, due to trying to use names similar to the protocol specifications,
32 * there are many mixed case field names in the structures below. Although
33 * this does not match typical Linux kernel style, it is necessary to be
34 * be able to match against the protocol specfication.
35 *
36 * SMB2 commands
37 * Some commands have minimal (wct=0,bcc=0), or uninteresting, responses
38 * (ie no useful data other than the SMB error code itself) and are marked such.
39 * Knowing this helps avoid response buffer allocations and copy in some cases.
40 */
41
42/* List of commands in host endian */
43#define SMB2_NEGOTIATE_HE 0x0000
44#define SMB2_SESSION_SETUP_HE 0x0001
45#define SMB2_LOGOFF_HE 0x0002 /* trivial request/resp */
46#define SMB2_TREE_CONNECT_HE 0x0003
47#define SMB2_TREE_DISCONNECT_HE 0x0004 /* trivial req/resp */
48#define SMB2_CREATE_HE 0x0005
49#define SMB2_CLOSE_HE 0x0006
50#define SMB2_FLUSH_HE 0x0007 /* trivial resp */
51#define SMB2_READ_HE 0x0008
52#define SMB2_WRITE_HE 0x0009
53#define SMB2_LOCK_HE 0x000A
54#define SMB2_IOCTL_HE 0x000B
55#define SMB2_CANCEL_HE 0x000C
56#define SMB2_ECHO_HE 0x000D
57#define SMB2_QUERY_DIRECTORY_HE 0x000E
58#define SMB2_CHANGE_NOTIFY_HE 0x000F
59#define SMB2_QUERY_INFO_HE 0x0010
60#define SMB2_SET_INFO_HE 0x0011
61#define SMB2_OPLOCK_BREAK_HE 0x0012
62
63/* The same list in little endian */
64#define SMB2_NEGOTIATE cpu_to_le16(SMB2_NEGOTIATE_HE)
65#define SMB2_SESSION_SETUP cpu_to_le16(SMB2_SESSION_SETUP_HE)
66#define SMB2_LOGOFF cpu_to_le16(SMB2_LOGOFF_HE)
67#define SMB2_TREE_CONNECT cpu_to_le16(SMB2_TREE_CONNECT_HE)
68#define SMB2_TREE_DISCONNECT cpu_to_le16(SMB2_TREE_DISCONNECT_HE)
69#define SMB2_CREATE cpu_to_le16(SMB2_CREATE_HE)
70#define SMB2_CLOSE cpu_to_le16(SMB2_CLOSE_HE)
71#define SMB2_FLUSH cpu_to_le16(SMB2_FLUSH_HE)
72#define SMB2_READ cpu_to_le16(SMB2_READ_HE)
73#define SMB2_WRITE cpu_to_le16(SMB2_WRITE_HE)
74#define SMB2_LOCK cpu_to_le16(SMB2_LOCK_HE)
75#define SMB2_IOCTL cpu_to_le16(SMB2_IOCTL_HE)
76#define SMB2_CANCEL cpu_to_le16(SMB2_CANCEL_HE)
77#define SMB2_ECHO cpu_to_le16(SMB2_ECHO_HE)
78#define SMB2_QUERY_DIRECTORY cpu_to_le16(SMB2_QUERY_DIRECTORY_HE)
79#define SMB2_CHANGE_NOTIFY cpu_to_le16(SMB2_CHANGE_NOTIFY_HE)
80#define SMB2_QUERY_INFO cpu_to_le16(SMB2_QUERY_INFO_HE)
81#define SMB2_SET_INFO cpu_to_le16(SMB2_SET_INFO_HE)
82#define SMB2_OPLOCK_BREAK cpu_to_le16(SMB2_OPLOCK_BREAK_HE)
83
Pavel Shilovsky96a988f2016-11-29 11:31:23 -080084#define SMB2_INTERNAL_CMD cpu_to_le16(0xFFFF)
85
Pavel Shilovsky2dc7e1c2011-12-26 22:53:34 +040086#define NUMBER_OF_SMB2_COMMANDS 0x0013
87
Ronnie Sahlberg58d15ed2019-01-29 12:46:16 +100088/* 52 transform hdr + 64 hdr + 88 create rsp */
Ronnie Sahlbergc4627e62019-01-29 12:46:17 +100089#define SMB2_TRANSFORM_HEADER_SIZE 52
Ronnie Sahlberg58d15ed2019-01-29 12:46:16 +100090#define MAX_SMB2_HDR_SIZE 204
Pavel Shilovsky2dc7e1c2011-12-26 22:53:34 +040091
Fabian Frederickbc09d142014-12-10 15:41:15 -080092#define SMB2_PROTO_NUMBER cpu_to_le32(0x424d53fe)
Steve French373512e2015-12-18 13:05:30 -060093#define SMB2_TRANSFORM_PROTO_NUM cpu_to_le32(0x424d53fd)
Pavel Shilovsky093b2bd2011-06-08 15:51:07 +040094
Pavel Shilovsky2dc7e1c2011-12-26 22:53:34 +040095/*
Steve Frenchddfbefb2011-03-15 02:08:48 +000096 * SMB2 Header Definition
97 *
98 * "MBZ" : Must be Zero
99 * "BB" : BugBug, Something to check/review/analyze later
100 * "PDU" : "Protocol Data Unit" (ie a network "frame")
101 *
102 */
Pavel Shilovsky74112862012-07-27 01:20:41 +0400103
Fabian Frederickbc09d142014-12-10 15:41:15 -0800104#define SMB2_HEADER_STRUCTURE_SIZE cpu_to_le16(64)
Pavel Shilovsky74112862012-07-27 01:20:41 +0400105
Pavel Shilovsky31473fc2016-10-24 15:33:04 -0700106struct smb2_sync_hdr {
Steve French373512e2015-12-18 13:05:30 -0600107 __le32 ProtocolId; /* 0xFE 'S' 'M' 'B' */
Steve Frenchddfbefb2011-03-15 02:08:48 +0000108 __le16 StructureSize; /* 64 */
109 __le16 CreditCharge; /* MBZ */
110 __le32 Status; /* Error from server */
111 __le16 Command;
112 __le16 CreditRequest; /* CreditResponse */
113 __le32 Flags;
114 __le32 NextCommand;
Sachin Prabhu9235d092014-12-09 17:37:00 +0000115 __le64 MessageId;
Steve Frenchddfbefb2011-03-15 02:08:48 +0000116 __le32 ProcessId;
117 __u32 TreeId; /* opaque - so do not make little endian */
118 __u64 SessionId; /* opaque - so do not make little endian */
119 __u8 Signature[16];
120} __packed;
121
Pavel Shilovskycb200bd2016-10-24 16:59:57 -0700122struct smb2_sync_pdu {
123 struct smb2_sync_hdr sync_hdr;
124 __le16 StructureSize2; /* size of wct area (varies, request specific) */
125} __packed;
126
Steve French9ac63ec2019-06-07 08:59:40 -0500127#define SMB3_AES128CCM_NONCE 11
Pavel Shilovsky026e93d2016-11-03 16:47:37 -0700128#define SMB3_AES128GCM_NONCE 12
129
Steve French0cbaa532013-11-15 23:50:24 -0600130struct smb2_transform_hdr {
Pavel Shilovsky026e93d2016-11-03 16:47:37 -0700131 __le32 ProtocolId; /* 0xFD 'S' 'M' 'B' */
Steve French0cbaa532013-11-15 23:50:24 -0600132 __u8 Signature[16];
Steve French373512e2015-12-18 13:05:30 -0600133 __u8 Nonce[16];
Steve French0cbaa532013-11-15 23:50:24 -0600134 __le32 OriginalMessageSize;
135 __u16 Reserved1;
Steve French373512e2015-12-18 13:05:30 -0600136 __le16 Flags; /* EncryptionAlgorithm */
Steve French0cbaa532013-11-15 23:50:24 -0600137 __u64 SessionId;
138} __packed;
139
Pavel Shilovsky093b2bd2011-06-08 15:51:07 +0400140/*
141 * SMB2 flag definitions
142 */
Fabian Frederickbc09d142014-12-10 15:41:15 -0800143#define SMB2_FLAGS_SERVER_TO_REDIR cpu_to_le32(0x00000001)
144#define SMB2_FLAGS_ASYNC_COMMAND cpu_to_le32(0x00000002)
145#define SMB2_FLAGS_RELATED_OPERATIONS cpu_to_le32(0x00000004)
146#define SMB2_FLAGS_SIGNED cpu_to_le32(0x00000008)
Steve French59519802019-07-25 18:19:42 -0500147#define SMB2_FLAGS_PRIORITY_MASK cpu_to_le32(0x00000070) /* SMB3.1.1 */
Fabian Frederickbc09d142014-12-10 15:41:15 -0800148#define SMB2_FLAGS_DFS_OPERATIONS cpu_to_le32(0x10000000)
Steve French59519802019-07-25 18:19:42 -0500149#define SMB2_FLAGS_REPLAY_OPERATION cpu_to_le32(0x20000000) /* SMB3 & up */
Pavel Shilovsky093b2bd2011-06-08 15:51:07 +0400150
151/*
152 * Definitions for SMB2 Protocol Data Units (network frames)
153 *
154 * See MS-SMB2.PDF specification for protocol details.
155 * The Naming convention is the lower case version of the SMB2
156 * command code name for the struct. Note that structures must be packed.
157 *
158 */
Pavel Shilovsky74112862012-07-27 01:20:41 +0400159
Ronnie Sahlberg730928c2018-08-08 15:07:49 +1000160#define COMPOUND_FID 0xFFFFFFFFFFFFFFFFULL
161
Fabian Frederickbc09d142014-12-10 15:41:15 -0800162#define SMB2_ERROR_STRUCTURE_SIZE2 cpu_to_le16(9)
Pavel Shilovsky74112862012-07-27 01:20:41 +0400163
Pavel Shilovsky093b2bd2011-06-08 15:51:07 +0400164struct smb2_err_rsp {
Ronnie Sahlberg49f466b2018-06-01 10:53:06 +1000165 struct smb2_sync_hdr sync_hdr;
Pavel Shilovsky093b2bd2011-06-08 15:51:07 +0400166 __le16 StructureSize;
167 __le16 Reserved; /* MBZ */
168 __le32 ByteCount; /* even if zero, at least one byte follows */
169 __u8 ErrorData[1]; /* variable length */
170} __packed;
171
Ronnie Sahlbergdf070af2019-07-09 18:41:11 +1000172#define SYMLINK_ERROR_TAG 0x4c4d5953
173
Pavel Shilovskyb42bf882013-08-14 19:25:21 +0400174struct smb2_symlink_err_rsp {
175 __le32 SymLinkLength;
176 __le32 SymLinkErrorTag;
177 __le32 ReparseTag;
178 __le16 ReparseDataLength;
179 __le16 UnparsedPathLength;
180 __le16 SubstituteNameOffset;
181 __le16 SubstituteNameLength;
182 __le16 PrintNameOffset;
183 __le16 PrintNameLength;
184 __le32 Flags;
Gustavo A. R. Silvacff2def2020-03-09 10:44:51 -0500185 __u8 PathBuffer[];
Pavel Shilovskyb42bf882013-08-14 19:25:21 +0400186} __packed;
187
Steve French5f60a562018-02-05 14:46:18 -0600188/* SMB 3.1.1 and later dialects. See MS-SMB2 section 2.2.2.1 */
189struct smb2_error_context_rsp {
190 __le32 ErrorDataLength;
191 __le32 ErrorId;
192 __u8 ErrorContextData; /* ErrorDataLength long array */
193} __packed;
194
195/* Defines for Type field below (see MS-SMB2 2.2.2.2.2.1) */
196#define MOVE_DST_IPADDR_V4 cpu_to_le32(0x00000001)
197#define MOVE_DST_IPADDR_V6 cpu_to_le32(0x00000002)
198
199struct move_dst_ipaddr {
200 __le32 Type;
201 __u32 Reserved;
202 __u8 address[16]; /* IPv4 followed by 12 bytes rsvd or IPv6 address */
203} __packed;
204
205struct share_redirect_error_context_rsp {
206 __le32 StructureSize;
207 __le32 NotificationType;
208 __le32 ResourceNameOffset;
209 __le32 ResourceNameLength;
210 __le16 Flags;
211 __le16 TargetType;
212 __le32 IPAddrCount;
Gustavo A. R. Silvacff2def2020-03-09 10:44:51 -0500213 struct move_dst_ipaddr IpAddrMoveList[];
Steve French5f60a562018-02-05 14:46:18 -0600214 /* __u8 ResourceName[] */ /* Name of share as counted Unicode string */
215} __packed;
216
Pavel Shilovskyb8c32db2012-09-19 06:22:44 -0700217#define SMB2_CLIENT_GUID_SIZE 16
218
Pavel Shilovskyec2e4522011-12-27 16:12:43 +0400219struct smb2_negotiate_req {
Ronnie Sahlberg13cacea2017-11-20 11:24:30 +1100220 struct smb2_sync_hdr sync_hdr;
Pavel Shilovskyec2e4522011-12-27 16:12:43 +0400221 __le16 StructureSize; /* Must be 36 */
222 __le16 DialectCount;
223 __le16 SecurityMode;
224 __le16 Reserved; /* MBZ */
225 __le32 Capabilities;
Pavel Shilovskyb8c32db2012-09-19 06:22:44 -0700226 __u8 ClientGUID[SMB2_CLIENT_GUID_SIZE];
Steve French5f7fbf72014-12-17 22:52:58 -0600227 /* In SMB3.02 and earlier next three were MBZ le64 ClientStartTime */
228 __le32 NegotiateContextOffset; /* SMB3.1.1 only. MBZ earlier */
229 __le16 NegotiateContextCount; /* SMB3.1.1 only. MBZ earlier */
230 __le16 Reserved2;
Steve Frenche4aa25e2012-10-01 12:26:22 -0500231 __le16 Dialects[1]; /* One dialect (vers=) at a time for now */
Pavel Shilovskyec2e4522011-12-27 16:12:43 +0400232} __packed;
233
Steve Frenche4aa25e2012-10-01 12:26:22 -0500234/* Dialects */
Steve French43cdae82019-06-13 14:26:49 -0500235#define SMB10_PROT_ID 0x0000 /* local only, not sent on wire w/CIFS negprot */
Steve Frenche4aa25e2012-10-01 12:26:22 -0500236#define SMB20_PROT_ID 0x0202
237#define SMB21_PROT_ID 0x0210
238#define SMB30_PROT_ID 0x0300
Steve French20b6d8b2013-06-12 22:48:41 -0500239#define SMB302_PROT_ID 0x0302
Steve French5f7fbf72014-12-17 22:52:58 -0600240#define SMB311_PROT_ID 0x0311
Steve Frenche4aa25e2012-10-01 12:26:22 -0500241#define BAD_PROT_ID 0xFFFF
242
Pavel Shilovskyec2e4522011-12-27 16:12:43 +0400243/* SecurityMode flags */
244#define SMB2_NEGOTIATE_SIGNING_ENABLED 0x0001
245#define SMB2_NEGOTIATE_SIGNING_REQUIRED 0x0002
Steve French07108d02018-04-01 20:15:55 -0500246#define SMB2_SEC_MODE_FLAGS_ALL 0x0003
247
Pavel Shilovskyec2e4522011-12-27 16:12:43 +0400248/* Capabilities flags */
249#define SMB2_GLOBAL_CAP_DFS 0x00000001
250#define SMB2_GLOBAL_CAP_LEASING 0x00000002 /* Resp only New to SMB2.1 */
251#define SMB2_GLOBAL_CAP_LARGE_MTU 0X00000004 /* Resp only New to SMB2.1 */
Steve Frenche4aa25e2012-10-01 12:26:22 -0500252#define SMB2_GLOBAL_CAP_MULTI_CHANNEL 0x00000008 /* New to SMB3 */
253#define SMB2_GLOBAL_CAP_PERSISTENT_HANDLES 0x00000010 /* New to SMB3 */
254#define SMB2_GLOBAL_CAP_DIRECTORY_LEASING 0x00000020 /* New to SMB3 */
255#define SMB2_GLOBAL_CAP_ENCRYPTION 0x00000040 /* New to SMB3 */
Pavel Shilovsky29e20f92012-07-13 13:58:14 +0400256/* Internal types */
257#define SMB2_NT_FIND 0x00100000
258#define SMB2_LARGE_FILES 0x00200000
Pavel Shilovskyec2e4522011-12-27 16:12:43 +0400259
Steve Frenchd7bef4c2019-04-18 11:03:58 -0500260
261/* Negotiate Contexts - ContextTypes. See MS-SMB2 section 2.2.3.1 for details */
262#define SMB2_PREAUTH_INTEGRITY_CAPABILITIES cpu_to_le16(1)
263#define SMB2_ENCRYPTION_CAPABILITIES cpu_to_le16(2)
264#define SMB2_COMPRESSION_CAPABILITIES cpu_to_le16(3)
265#define SMB2_NETNAME_NEGOTIATE_CONTEXT_ID cpu_to_le16(5)
266#define SMB2_POSIX_EXTENSIONS_AVAILABLE cpu_to_le16(0x100)
267
Steve French136ff1b2018-04-08 16:14:31 -0500268struct smb2_neg_context {
269 __le16 ContextType;
270 __le16 DataLength;
271 __le32 Reserved;
272 /* Followed by array of data */
273} __packed;
274
Steve Frencheed0e172015-02-06 00:03:52 -0600275#define SMB311_SALT_SIZE 32
276/* Hash Algorithm Types */
Steve Frenchebb3a9d2015-06-18 04:49:47 -0500277#define SMB2_PREAUTH_INTEGRITY_SHA512 cpu_to_le16(0x0001)
Aurelien Aptel8bd68c62018-02-16 19:19:29 +0100278#define SMB2_PREAUTH_HASH_SIZE 64
Steve Frencheed0e172015-02-06 00:03:52 -0600279
Steve French5100d8a2018-04-09 10:47:14 -0500280#define MIN_PREAUTH_CTXT_DATA_LEN (SMB311_SALT_SIZE + 6)
Steve Frencheed0e172015-02-06 00:03:52 -0600281struct smb2_preauth_neg_context {
282 __le16 ContextType; /* 1 */
283 __le16 DataLength;
284 __le32 Reserved;
285 __le16 HashAlgorithmCount; /* 1 */
286 __le16 SaltLength;
287 __le16 HashAlgorithms; /* HashAlgorithms[0] since only one defined */
288 __u8 Salt[SMB311_SALT_SIZE];
289} __packed;
290
291/* Encryption Algorithms Ciphers */
292#define SMB2_ENCRYPTION_AES128_CCM cpu_to_le16(0x0001)
293#define SMB2_ENCRYPTION_AES128_GCM cpu_to_le16(0x0002)
294
Steve French5100d8a2018-04-09 10:47:14 -0500295/* Min encrypt context data is one cipher so 2 bytes + 2 byte count field */
296#define MIN_ENCRYPT_CTXT_DATA_LEN 4
Steve Frencheed0e172015-02-06 00:03:52 -0600297struct smb2_encryption_neg_context {
298 __le16 ContextType; /* 2 */
299 __le16 DataLength;
300 __le32 Reserved;
Steve Frenchebb3a9d2015-06-18 04:49:47 -0500301 __le16 CipherCount; /* AES-128-GCM and AES-128-CCM */
Steve French9ac63ec2019-06-07 08:59:40 -0500302 __le16 Ciphers[2];
Steve Frencheed0e172015-02-06 00:03:52 -0600303} __packed;
304
Steve Frenchd7bef4c2019-04-18 11:03:58 -0500305/* See MS-SMB2 2.2.3.1.3 */
Steve French26ea8882019-04-26 20:36:08 -0700306#define SMB3_COMPRESS_NONE cpu_to_le16(0x0000)
307#define SMB3_COMPRESS_LZNT1 cpu_to_le16(0x0001)
308#define SMB3_COMPRESS_LZ77 cpu_to_le16(0x0002)
309#define SMB3_COMPRESS_LZ77_HUFF cpu_to_le16(0x0003)
Steve French2fe4f622020-03-15 17:42:41 -0500310/* Pattern scanning algorithm See MS-SMB2 3.1.4.4.1 */
311#define SMB3_COMPRESS_PATTERN cpu_to_le16(0x0004)
312
313/* Compression Flags */
314#define SMB2_COMPRESSION_CAPABILITIES_FLAG_NONE cpu_to_le32(0x00000000)
315#define SMB2_COMPRESSION_CAPABILITIES_FLAG_CHAINED cpu_to_le32(0x00000001)
Steve Frenchd7bef4c2019-04-18 11:03:58 -0500316
317struct smb2_compression_capabilities_context {
Steve French26ea8882019-04-26 20:36:08 -0700318 __le16 ContextType; /* 3 */
319 __le16 DataLength;
Steve French2fe4f622020-03-15 17:42:41 -0500320 __u32 Flags;
Steve Frenchd7bef4c2019-04-18 11:03:58 -0500321 __le16 CompressionAlgorithmCount;
322 __u16 Padding;
Steve French26ea8882019-04-26 20:36:08 -0700323 __u32 Reserved1;
324 __le16 CompressionAlgorithms[3];
Steve Frenchd7bef4c2019-04-18 11:03:58 -0500325} __packed;
326
327/*
328 * For smb2_netname_negotiate_context_id See MS-SMB2 2.2.3.1.4.
329 * Its struct simply contains NetName, an array of Unicode characters
330 */
Steve French96d3cca2019-06-25 04:39:51 -0500331struct smb2_netname_neg_context {
332 __le16 ContextType; /* 0x100 */
333 __le16 DataLength;
334 __le32 Reserved;
Gustavo A. R. Silvacff2def2020-03-09 10:44:51 -0500335 __le16 NetName[]; /* hostname of target converted to UCS-2 */
Steve French96d3cca2019-06-25 04:39:51 -0500336} __packed;
Steve Frenchd7bef4c2019-04-18 11:03:58 -0500337
Steve French0d481322019-02-24 17:56:33 -0600338#define POSIX_CTXT_DATA_LEN 16
Steve Frenchfcef0db2018-05-19 20:45:27 -0500339struct smb2_posix_neg_context {
340 __le16 ContextType; /* 0x100 */
341 __le16 DataLength;
342 __le32 Reserved;
Steve French0d481322019-02-24 17:56:33 -0600343 __u8 Name[16]; /* POSIX ctxt GUID 93AD25509CB411E7B42383DE968BCD7C */
Steve Frenchfcef0db2018-05-19 20:45:27 -0500344} __packed;
345
Pavel Shilovskyec2e4522011-12-27 16:12:43 +0400346struct smb2_negotiate_rsp {
Ronnie Sahlberg49f466b2018-06-01 10:53:06 +1000347 struct smb2_sync_hdr sync_hdr;
Pavel Shilovskyec2e4522011-12-27 16:12:43 +0400348 __le16 StructureSize; /* Must be 65 */
349 __le16 SecurityMode;
350 __le16 DialectRevision;
Steve French5f7fbf72014-12-17 22:52:58 -0600351 __le16 NegotiateContextCount; /* Prior to SMB3.1.1 was Reserved & MBZ */
Pavel Shilovskyec2e4522011-12-27 16:12:43 +0400352 __u8 ServerGUID[16];
353 __le32 Capabilities;
354 __le32 MaxTransactSize;
355 __le32 MaxReadSize;
356 __le32 MaxWriteSize;
357 __le64 SystemTime; /* MBZ */
358 __le64 ServerStartTime;
359 __le16 SecurityBufferOffset;
360 __le16 SecurityBufferLength;
Steve French5f7fbf72014-12-17 22:52:58 -0600361 __le32 NegotiateContextOffset; /* Pre:SMB3.1.1 was reserved/ignored */
Pavel Shilovskyec2e4522011-12-27 16:12:43 +0400362 __u8 Buffer[1]; /* variable length GSS security buffer */
363} __packed;
364
Steve Frencheed0e172015-02-06 00:03:52 -0600365/* Flags */
366#define SMB2_SESSION_REQ_FLAG_BINDING 0x01
367#define SMB2_SESSION_REQ_FLAG_ENCRYPT_DATA 0x04
368
Pavel Shilovsky5478f9b2011-12-27 16:22:00 +0400369struct smb2_sess_setup_req {
Ronnie Sahlberg88ea5cb2017-11-20 11:24:36 +1100370 struct smb2_sync_hdr sync_hdr;
Pavel Shilovsky5478f9b2011-12-27 16:22:00 +0400371 __le16 StructureSize; /* Must be 25 */
Steve Frencheed0e172015-02-06 00:03:52 -0600372 __u8 Flags;
Pavel Shilovsky5478f9b2011-12-27 16:22:00 +0400373 __u8 SecurityMode;
374 __le32 Capabilities;
375 __le32 Channel;
376 __le16 SecurityBufferOffset;
377 __le16 SecurityBufferLength;
Steve Frenchc2afb812016-09-20 22:56:13 -0500378 __u64 PreviousSessionId;
Pavel Shilovsky5478f9b2011-12-27 16:22:00 +0400379 __u8 Buffer[1]; /* variable length GSS security buffer */
380} __packed;
381
382/* Currently defined SessionFlags */
383#define SMB2_SESSION_FLAG_IS_GUEST 0x0001
384#define SMB2_SESSION_FLAG_IS_NULL 0x0002
Steve French0cbaa532013-11-15 23:50:24 -0600385#define SMB2_SESSION_FLAG_ENCRYPT_DATA 0x0004
Pavel Shilovsky5478f9b2011-12-27 16:22:00 +0400386struct smb2_sess_setup_rsp {
Ronnie Sahlberg49f466b2018-06-01 10:53:06 +1000387 struct smb2_sync_hdr sync_hdr;
Pavel Shilovsky5478f9b2011-12-27 16:22:00 +0400388 __le16 StructureSize; /* Must be 9 */
389 __le16 SessionFlags;
390 __le16 SecurityBufferOffset;
391 __le16 SecurityBufferLength;
392 __u8 Buffer[1]; /* variable length GSS security buffer */
393} __packed;
394
395struct smb2_logoff_req {
Ronnie Sahlberg45305ed2017-11-09 12:14:17 +1100396 struct smb2_sync_hdr sync_hdr;
Pavel Shilovsky5478f9b2011-12-27 16:22:00 +0400397 __le16 StructureSize; /* Must be 4 */
398 __le16 Reserved;
399} __packed;
400
401struct smb2_logoff_rsp {
Ronnie Sahlberg49f466b2018-06-01 10:53:06 +1000402 struct smb2_sync_hdr sync_hdr;
Pavel Shilovsky5478f9b2011-12-27 16:22:00 +0400403 __le16 StructureSize; /* Must be 4 */
404 __le16 Reserved;
405} __packed;
406
Steve Frencheed0e172015-02-06 00:03:52 -0600407/* Flags/Reserved for SMB3.1.1 */
Steve French5f60a562018-02-05 14:46:18 -0600408#define SMB2_TREE_CONNECT_FLAG_CLUSTER_RECONNECT cpu_to_le16(0x0001)
409#define SMB2_TREE_CONNECT_FLAG_REDIRECT_TO_OWNER cpu_to_le16(0x0002)
410#define SMB2_TREE_CONNECT_FLAG_EXTENSION_PRESENT cpu_to_le16(0x0004)
Steve Frencheed0e172015-02-06 00:03:52 -0600411
Pavel Shilovskyfaaf9462011-12-27 16:04:00 +0400412struct smb2_tree_connect_req {
Ronnie Sahlberg661bb9432017-11-09 12:14:23 +1100413 struct smb2_sync_hdr sync_hdr;
Pavel Shilovskyfaaf9462011-12-27 16:04:00 +0400414 __le16 StructureSize; /* Must be 9 */
Steve Frencheed0e172015-02-06 00:03:52 -0600415 __le16 Reserved; /* Flags in SMB3.1.1 */
Pavel Shilovskyfaaf9462011-12-27 16:04:00 +0400416 __le16 PathOffset;
417 __le16 PathLength;
418 __u8 Buffer[1]; /* variable length */
419} __packed;
420
Steve French5f60a562018-02-05 14:46:18 -0600421/* See MS-SMB2 section 2.2.9.2 */
422/* Context Types */
423#define SMB2_RESERVED_TREE_CONNECT_CONTEXT_ID 0x0000
424#define SMB2_REMOTED_IDENTITY_TREE_CONNECT_CONTEXT_ID cpu_to_le16(0x0001)
425
426struct tree_connect_contexts {
427 __le16 ContextType;
428 __le16 DataLength;
429 __le32 Reserved;
Gustavo A. R. Silvacff2def2020-03-09 10:44:51 -0500430 __u8 Data[];
Steve French5f60a562018-02-05 14:46:18 -0600431} __packed;
432
433/* Remoted identity tree connect context structures - see MS-SMB2 2.2.9.2.1 */
434struct smb3_blob_data {
435 __le16 BlobSize;
Gustavo A. R. Silvacff2def2020-03-09 10:44:51 -0500436 __u8 BlobData[];
Steve French5f60a562018-02-05 14:46:18 -0600437} __packed;
438
439/* Valid values for Attr */
440#define SE_GROUP_MANDATORY 0x00000001
441#define SE_GROUP_ENABLED_BY_DEFAULT 0x00000002
442#define SE_GROUP_ENABLED 0x00000004
443#define SE_GROUP_OWNER 0x00000008
444#define SE_GROUP_USE_FOR_DENY_ONLY 0x00000010
445#define SE_GROUP_INTEGRITY 0x00000020
446#define SE_GROUP_INTEGRITY_ENABLED 0x00000040
447#define SE_GROUP_RESOURCE 0x20000000
448#define SE_GROUP_LOGON_ID 0xC0000000
449
450/* struct sid_attr_data is SidData array in BlobData format then le32 Attr */
451
452struct sid_array_data {
453 __le16 SidAttrCount;
454 /* SidAttrList - array of sid_attr_data structs */
455} __packed;
456
457struct luid_attr_data {
458
459} __packed;
460
461/*
462 * struct privilege_data is the same as BLOB_DATA - see MS-SMB2 2.2.9.2.1.5
463 * but with size of LUID_ATTR_DATA struct and BlobData set to LUID_ATTR DATA
464 */
465
466struct privilege_array_data {
467 __le16 PrivilegeCount;
468 /* array of privilege_data structs */
469} __packed;
470
471struct remoted_identity_tcon_context {
472 __le16 TicketType; /* must be 0x0001 */
473 __le16 TicketSize; /* total size of this struct */
474 __le16 User; /* offset to SID_ATTR_DATA struct with user info */
475 __le16 UserName; /* offset to null terminated Unicode username string */
476 __le16 Domain; /* offset to null terminated Unicode domain name */
477 __le16 Groups; /* offset to SID_ARRAY_DATA struct with group info */
478 __le16 RestrictedGroups; /* similar to above */
479 __le16 Privileges; /* offset to PRIVILEGE_ARRAY_DATA struct */
480 __le16 PrimaryGroup; /* offset to SID_ARRAY_DATA struct */
481 __le16 Owner; /* offset to BLOB_DATA struct */
482 __le16 DefaultDacl; /* offset to BLOB_DATA struct */
483 __le16 DeviceGroups; /* offset to SID_ARRAY_DATA struct */
484 __le16 UserClaims; /* offset to BLOB_DATA struct */
485 __le16 DeviceClaims; /* offset to BLOB_DATA struct */
Gustavo A. R. Silvacff2def2020-03-09 10:44:51 -0500486 __u8 TicketInfo[]; /* variable length buf - remoted identity data */
Steve French5f60a562018-02-05 14:46:18 -0600487} __packed;
488
489struct smb2_tree_connect_req_extension {
490 __le32 TreeConnectContextOffset;
491 __le16 TreeConnectContextCount;
492 __u8 Reserved[10];
Gustavo A. R. Silvacff2def2020-03-09 10:44:51 -0500493 __u8 PathName[]; /* variable sized array */
Steve French5f60a562018-02-05 14:46:18 -0600494 /* followed by array of TreeConnectContexts */
495} __packed;
496
Pavel Shilovskyfaaf9462011-12-27 16:04:00 +0400497struct smb2_tree_connect_rsp {
Ronnie Sahlberg49f466b2018-06-01 10:53:06 +1000498 struct smb2_sync_hdr sync_hdr;
Pavel Shilovskyfaaf9462011-12-27 16:04:00 +0400499 __le16 StructureSize; /* Must be 16 */
500 __u8 ShareType; /* see below */
501 __u8 Reserved;
502 __le32 ShareFlags; /* see below */
503 __le32 Capabilities; /* see below */
504 __le32 MaximalAccess;
505} __packed;
506
507/* Possible ShareType values */
508#define SMB2_SHARE_TYPE_DISK 0x01
509#define SMB2_SHARE_TYPE_PIPE 0x02
510#define SMB2_SHARE_TYPE_PRINT 0x03
511
512/*
513 * Possible ShareFlags - exactly one and only one of the first 4 caching flags
514 * must be set (any of the remaining, SHI1005, flags may be set individually
515 * or in combination.
516 */
517#define SMB2_SHAREFLAG_MANUAL_CACHING 0x00000000
518#define SMB2_SHAREFLAG_AUTO_CACHING 0x00000010
519#define SMB2_SHAREFLAG_VDO_CACHING 0x00000020
520#define SMB2_SHAREFLAG_NO_CACHING 0x00000030
521#define SHI1005_FLAGS_DFS 0x00000001
522#define SHI1005_FLAGS_DFS_ROOT 0x00000002
523#define SHI1005_FLAGS_RESTRICT_EXCLUSIVE_OPENS 0x00000100
524#define SHI1005_FLAGS_FORCE_SHARED_DELETE 0x00000200
525#define SHI1005_FLAGS_ALLOW_NAMESPACE_CACHING 0x00000400
526#define SHI1005_FLAGS_ACCESS_BASED_DIRECTORY_ENUM 0x00000800
527#define SHI1005_FLAGS_FORCE_LEVELII_OPLOCK 0x00001000
Steve Frenchc8664732013-06-21 15:35:45 -0500528#define SHI1005_FLAGS_ENABLE_HASH_V1 0x00002000
529#define SHI1005_FLAGS_ENABLE_HASH_V2 0x00004000
530#define SHI1005_FLAGS_ENCRYPT_DATA 0x00008000
Steve French5f60a562018-02-05 14:46:18 -0600531#define SMB2_SHAREFLAG_IDENTITY_REMOTING 0x00040000 /* 3.1.1 */
532#define SHI1005_FLAGS_ALL 0x0004FF33
Pavel Shilovskyfaaf9462011-12-27 16:04:00 +0400533
534/* Possible share capabilities */
Steve French2b5dc282013-06-13 10:51:10 -0500535#define SMB2_SHARE_CAP_DFS cpu_to_le32(0x00000008) /* all dialects */
536#define SMB2_SHARE_CAP_CONTINUOUS_AVAILABILITY cpu_to_le32(0x00000010) /* 3.0 */
537#define SMB2_SHARE_CAP_SCALEOUT cpu_to_le32(0x00000020) /* 3.0 */
538#define SMB2_SHARE_CAP_CLUSTER cpu_to_le32(0x00000040) /* 3.0 */
539#define SMB2_SHARE_CAP_ASYMMETRIC cpu_to_le32(0x00000080) /* 3.02 */
Steve French5f60a562018-02-05 14:46:18 -0600540#define SMB2_SHARE_CAP_REDIRECT_TO_OWNER cpu_to_le32(0x00000100) /* 3.1.1 */
Pavel Shilovskyfaaf9462011-12-27 16:04:00 +0400541
542struct smb2_tree_disconnect_req {
Ronnie Sahlberg4eecf4c2017-11-09 12:14:18 +1100543 struct smb2_sync_hdr sync_hdr;
Pavel Shilovskyfaaf9462011-12-27 16:04:00 +0400544 __le16 StructureSize; /* Must be 4 */
545 __le16 Reserved;
546} __packed;
547
548struct smb2_tree_disconnect_rsp {
Ronnie Sahlberg49f466b2018-06-01 10:53:06 +1000549 struct smb2_sync_hdr sync_hdr;
Pavel Shilovskyfaaf9462011-12-27 16:04:00 +0400550 __le16 StructureSize; /* Must be 4 */
551 __le16 Reserved;
552} __packed;
553
Pavel Shilovsky2503a0d2011-12-26 22:58:46 +0400554/* File Attrubutes */
555#define FILE_ATTRIBUTE_READONLY 0x00000001
556#define FILE_ATTRIBUTE_HIDDEN 0x00000002
557#define FILE_ATTRIBUTE_SYSTEM 0x00000004
558#define FILE_ATTRIBUTE_DIRECTORY 0x00000010
559#define FILE_ATTRIBUTE_ARCHIVE 0x00000020
560#define FILE_ATTRIBUTE_NORMAL 0x00000080
561#define FILE_ATTRIBUTE_TEMPORARY 0x00000100
562#define FILE_ATTRIBUTE_SPARSE_FILE 0x00000200
563#define FILE_ATTRIBUTE_REPARSE_POINT 0x00000400
564#define FILE_ATTRIBUTE_COMPRESSED 0x00000800
565#define FILE_ATTRIBUTE_OFFLINE 0x00001000
566#define FILE_ATTRIBUTE_NOT_CONTENT_INDEXED 0x00002000
567#define FILE_ATTRIBUTE_ENCRYPTED 0x00004000
Steve French73322972014-09-23 19:25:42 -0500568#define FILE_ATTRIBUTE_INTEGRITY_STREAM 0x00008000
569#define FILE_ATTRIBUTE_NO_SCRUB_DATA 0x00020000
Pavel Shilovsky2503a0d2011-12-26 22:58:46 +0400570
571/* Oplock levels */
572#define SMB2_OPLOCK_LEVEL_NONE 0x00
573#define SMB2_OPLOCK_LEVEL_II 0x01
574#define SMB2_OPLOCK_LEVEL_EXCLUSIVE 0x08
575#define SMB2_OPLOCK_LEVEL_BATCH 0x09
576#define SMB2_OPLOCK_LEVEL_LEASE 0xFF
Pavel Shilovskyb8c32db2012-09-19 06:22:44 -0700577/* Non-spec internal type */
578#define SMB2_OPLOCK_LEVEL_NOCHANGE 0x99
Pavel Shilovsky2503a0d2011-12-26 22:58:46 +0400579
580/* Desired Access Flags */
581#define FILE_READ_DATA_LE cpu_to_le32(0x00000001)
582#define FILE_WRITE_DATA_LE cpu_to_le32(0x00000002)
583#define FILE_APPEND_DATA_LE cpu_to_le32(0x00000004)
584#define FILE_READ_EA_LE cpu_to_le32(0x00000008)
585#define FILE_WRITE_EA_LE cpu_to_le32(0x00000010)
586#define FILE_EXECUTE_LE cpu_to_le32(0x00000020)
587#define FILE_READ_ATTRIBUTES_LE cpu_to_le32(0x00000080)
588#define FILE_WRITE_ATTRIBUTES_LE cpu_to_le32(0x00000100)
589#define FILE_DELETE_LE cpu_to_le32(0x00010000)
590#define FILE_READ_CONTROL_LE cpu_to_le32(0x00020000)
591#define FILE_WRITE_DAC_LE cpu_to_le32(0x00040000)
592#define FILE_WRITE_OWNER_LE cpu_to_le32(0x00080000)
593#define FILE_SYNCHRONIZE_LE cpu_to_le32(0x00100000)
594#define FILE_ACCESS_SYSTEM_SECURITY_LE cpu_to_le32(0x01000000)
595#define FILE_MAXIMAL_ACCESS_LE cpu_to_le32(0x02000000)
596#define FILE_GENERIC_ALL_LE cpu_to_le32(0x10000000)
597#define FILE_GENERIC_EXECUTE_LE cpu_to_le32(0x20000000)
598#define FILE_GENERIC_WRITE_LE cpu_to_le32(0x40000000)
599#define FILE_GENERIC_READ_LE cpu_to_le32(0x80000000)
600
601/* ShareAccess Flags */
602#define FILE_SHARE_READ_LE cpu_to_le32(0x00000001)
603#define FILE_SHARE_WRITE_LE cpu_to_le32(0x00000002)
604#define FILE_SHARE_DELETE_LE cpu_to_le32(0x00000004)
605#define FILE_SHARE_ALL_LE cpu_to_le32(0x00000007)
606
607/* CreateDisposition Flags */
608#define FILE_SUPERSEDE_LE cpu_to_le32(0x00000000)
609#define FILE_OPEN_LE cpu_to_le32(0x00000001)
610#define FILE_CREATE_LE cpu_to_le32(0x00000002)
611#define FILE_OPEN_IF_LE cpu_to_le32(0x00000003)
612#define FILE_OVERWRITE_LE cpu_to_le32(0x00000004)
613#define FILE_OVERWRITE_IF_LE cpu_to_le32(0x00000005)
614
615/* CreateOptions Flags */
616#define FILE_DIRECTORY_FILE_LE cpu_to_le32(0x00000001)
617/* same as #define CREATE_NOT_FILE_LE cpu_to_le32(0x00000001) */
618#define FILE_WRITE_THROUGH_LE cpu_to_le32(0x00000002)
619#define FILE_SEQUENTIAL_ONLY_LE cpu_to_le32(0x00000004)
620#define FILE_NO_INTERMEDIATE_BUFFERRING_LE cpu_to_le32(0x00000008)
621#define FILE_SYNCHRONOUS_IO_ALERT_LE cpu_to_le32(0x00000010)
622#define FILE_SYNCHRONOUS_IO_NON_ALERT_LE cpu_to_le32(0x00000020)
623#define FILE_NON_DIRECTORY_FILE_LE cpu_to_le32(0x00000040)
624#define FILE_COMPLETE_IF_OPLOCKED_LE cpu_to_le32(0x00000100)
625#define FILE_NO_EA_KNOWLEDGE_LE cpu_to_le32(0x00000200)
626#define FILE_RANDOM_ACCESS_LE cpu_to_le32(0x00000800)
627#define FILE_DELETE_ON_CLOSE_LE cpu_to_le32(0x00001000)
628#define FILE_OPEN_BY_FILE_ID_LE cpu_to_le32(0x00002000)
629#define FILE_OPEN_FOR_BACKUP_INTENT_LE cpu_to_le32(0x00004000)
630#define FILE_NO_COMPRESSION_LE cpu_to_le32(0x00008000)
631#define FILE_RESERVE_OPFILTER_LE cpu_to_le32(0x00100000)
632#define FILE_OPEN_REPARSE_POINT_LE cpu_to_le32(0x00200000)
633#define FILE_OPEN_NO_RECALL_LE cpu_to_le32(0x00400000)
634#define FILE_OPEN_FOR_FREE_SPACE_QUERY_LE cpu_to_le32(0x00800000)
635
636#define FILE_READ_RIGHTS_LE (FILE_READ_DATA_LE | FILE_READ_EA_LE \
637 | FILE_READ_ATTRIBUTES_LE)
638#define FILE_WRITE_RIGHTS_LE (FILE_WRITE_DATA_LE | FILE_APPEND_DATA_LE \
639 | FILE_WRITE_EA_LE | FILE_WRITE_ATTRIBUTES_LE)
640#define FILE_EXEC_RIGHTS_LE (FILE_EXECUTE_LE)
641
642/* Impersonation Levels */
643#define IL_ANONYMOUS cpu_to_le32(0x00000000)
644#define IL_IDENTIFICATION cpu_to_le32(0x00000001)
645#define IL_IMPERSONATION cpu_to_le32(0x00000002)
646#define IL_DELEGATE cpu_to_le32(0x00000003)
647
648/* Create Context Values */
649#define SMB2_CREATE_EA_BUFFER "ExtA" /* extended attributes */
650#define SMB2_CREATE_SD_BUFFER "SecD" /* security descriptor */
651#define SMB2_CREATE_DURABLE_HANDLE_REQUEST "DHnQ"
652#define SMB2_CREATE_DURABLE_HANDLE_RECONNECT "DHnC"
Steve French12197a72014-05-14 05:29:40 -0700653#define SMB2_CREATE_ALLOCATION_SIZE "AISi"
Pavel Shilovsky2503a0d2011-12-26 22:58:46 +0400654#define SMB2_CREATE_QUERY_MAXIMAL_ACCESS_REQUEST "MxAc"
655#define SMB2_CREATE_TIMEWARP_REQUEST "TWrp"
656#define SMB2_CREATE_QUERY_ON_DISK_ID "QFid"
657#define SMB2_CREATE_REQUEST_LEASE "RqLs"
Steve French12197a72014-05-14 05:29:40 -0700658#define SMB2_CREATE_DURABLE_HANDLE_REQUEST_V2 "DH2Q"
659#define SMB2_CREATE_DURABLE_HANDLE_RECONNECT_V2 "DH2C"
660#define SMB2_CREATE_APP_INSTANCE_ID 0x45BCA66AEFA7F74A9008FA462E144D74
Steve Frenche7348e32019-06-28 02:35:10 -0500661#define SMB2_CREATE_APP_INSTANCE_VERSION 0xB982D0B73B56074FA07B524A8116A010
Steve Frenchfe048402018-05-30 17:10:25 -0500662#define SVHDX_OPEN_DEVICE_CONTEX 0x9CCBCF9E04C1E643980E158DA1F6EC83
663#define SMB2_CREATE_TAG_POSIX 0x93AD25509CB411E7B42383DE968BCD7C
664
Steve French37e6a702018-09-19 02:02:58 -0500665/* Flag (SMB3 open response) values */
666#define SMB2_CREATE_FLAG_REPARSEPOINT 0x01
Pavel Shilovsky2503a0d2011-12-26 22:58:46 +0400667
Ronnie Sahlberg4d8dfaf2018-08-21 11:49:21 +1000668/*
669 * Maximum number of iovs we need for an open/create request.
670 * [0] : struct smb2_create_req
671 * [1] : path
672 * [2] : lease context
673 * [3] : durable context
674 * [4] : posix context
675 * [5] : time warp context
Steve Frenchff2a09e2019-07-06 14:41:38 -0500676 * [6] : query id context
677 * [7] : compound padding
Ronnie Sahlberg4d8dfaf2018-08-21 11:49:21 +1000678 */
Steve Frenchff2a09e2019-07-06 14:41:38 -0500679#define SMB2_CREATE_IOV_SIZE 8
Ronnie Sahlberg4d8dfaf2018-08-21 11:49:21 +1000680
Pavel Shilovsky2503a0d2011-12-26 22:58:46 +0400681struct smb2_create_req {
Ronnie Sahlberg4f33bc32017-11-20 11:24:38 +1100682 struct smb2_sync_hdr sync_hdr;
Pavel Shilovsky2503a0d2011-12-26 22:58:46 +0400683 __le16 StructureSize; /* Must be 57 */
684 __u8 SecurityFlags;
685 __u8 RequestedOplockLevel;
686 __le32 ImpersonationLevel;
687 __le64 SmbCreateFlags;
688 __le64 Reserved;
689 __le32 DesiredAccess;
690 __le32 FileAttributes;
691 __le32 ShareAccess;
692 __le32 CreateDisposition;
693 __le32 CreateOptions;
694 __le16 NameOffset;
695 __le16 NameLength;
696 __le32 CreateContextsOffset;
697 __le32 CreateContextsLength;
Gustavo A. R. Silvacff2def2020-03-09 10:44:51 -0500698 __u8 Buffer[];
Pavel Shilovsky2503a0d2011-12-26 22:58:46 +0400699} __packed;
700
Ronnie Sahlbergc4627e62019-01-29 12:46:17 +1000701/*
702 * Maximum size of a SMB2_CREATE response is 64 (smb2 header) +
Steve Frenchff2a09e2019-07-06 14:41:38 -0500703 * 88 (fixed part of create response) + 520 (path) + 208 (contexts) +
Ronnie Sahlbergc4627e62019-01-29 12:46:17 +1000704 * 2 bytes of padding.
705 */
Steve Frenchff2a09e2019-07-06 14:41:38 -0500706#define MAX_SMB2_CREATE_RESPONSE_SIZE 880
Ronnie Sahlbergc4627e62019-01-29 12:46:17 +1000707
Pavel Shilovsky2503a0d2011-12-26 22:58:46 +0400708struct smb2_create_rsp {
Ronnie Sahlberg49f466b2018-06-01 10:53:06 +1000709 struct smb2_sync_hdr sync_hdr;
Pavel Shilovsky2503a0d2011-12-26 22:58:46 +0400710 __le16 StructureSize; /* Must be 89 */
711 __u8 OplockLevel;
Steve French37e6a702018-09-19 02:02:58 -0500712 __u8 Flag; /* 0x01 if reparse point */
Pavel Shilovsky2503a0d2011-12-26 22:58:46 +0400713 __le32 CreateAction;
714 __le64 CreationTime;
715 __le64 LastAccessTime;
716 __le64 LastWriteTime;
717 __le64 ChangeTime;
718 __le64 AllocationSize;
719 __le64 EndofFile;
720 __le32 FileAttributes;
721 __le32 Reserved2;
722 __u64 PersistentFileId; /* opaque endianness */
723 __u64 VolatileFileId; /* opaque endianness */
724 __le32 CreateContextsOffset;
725 __le32 CreateContextsLength;
726 __u8 Buffer[1];
727} __packed;
728
Pavel Shilovskyb8c32db2012-09-19 06:22:44 -0700729struct create_context {
730 __le32 Next;
731 __le16 NameOffset;
732 __le16 NameLength;
733 __le16 Reserved;
734 __le16 DataOffset;
735 __le32 DataLength;
Gustavo A. R. Silvacff2def2020-03-09 10:44:51 -0500736 __u8 Buffer[];
Pavel Shilovskyb8c32db2012-09-19 06:22:44 -0700737} __packed;
738
Pavel Shilovsky53ef1012013-09-05 16:11:28 +0400739#define SMB2_LEASE_READ_CACHING_HE 0x01
740#define SMB2_LEASE_HANDLE_CACHING_HE 0x02
741#define SMB2_LEASE_WRITE_CACHING_HE 0x04
742
Fabian Frederickbc09d142014-12-10 15:41:15 -0800743#define SMB2_LEASE_NONE cpu_to_le32(0x00)
744#define SMB2_LEASE_READ_CACHING cpu_to_le32(0x01)
745#define SMB2_LEASE_HANDLE_CACHING cpu_to_le32(0x02)
746#define SMB2_LEASE_WRITE_CACHING cpu_to_le32(0x04)
Pavel Shilovskyb8c32db2012-09-19 06:22:44 -0700747
Fabian Frederickbc09d142014-12-10 15:41:15 -0800748#define SMB2_LEASE_FLAG_BREAK_IN_PROGRESS cpu_to_le32(0x02)
Steve French5f60a562018-02-05 14:46:18 -0600749#define SMB2_LEASE_FLAG_PARENT_LEASE_KEY_SET cpu_to_le32(0x00000004)
Pavel Shilovskyb8c32db2012-09-19 06:22:44 -0700750
751#define SMB2_LEASE_KEY_SIZE 16
752
753struct lease_context {
Stefano Brivio729c0c92018-07-05 15:10:02 +0200754 u8 LeaseKey[SMB2_LEASE_KEY_SIZE];
Pavel Shilovskyb8c32db2012-09-19 06:22:44 -0700755 __le32 LeaseState;
756 __le32 LeaseFlags;
757 __le64 LeaseDuration;
758} __packed;
759
Pavel Shilovskyf0473902013-09-04 13:44:05 +0400760struct lease_context_v2 {
Stefano Brivio729c0c92018-07-05 15:10:02 +0200761 u8 LeaseKey[SMB2_LEASE_KEY_SIZE];
Pavel Shilovskyf0473902013-09-04 13:44:05 +0400762 __le32 LeaseState;
763 __le32 LeaseFlags;
764 __le64 LeaseDuration;
765 __le64 ParentLeaseKeyLow;
766 __le64 ParentLeaseKeyHigh;
767 __le16 Epoch;
768 __le16 Reserved;
769} __packed;
770
Pavel Shilovskyb8c32db2012-09-19 06:22:44 -0700771struct create_lease {
772 struct create_context ccontext;
773 __u8 Name[8];
774 struct lease_context lcontext;
775} __packed;
776
Pavel Shilovskyf0473902013-09-04 13:44:05 +0400777struct create_lease_v2 {
778 struct create_context ccontext;
779 __u8 Name[8];
780 struct lease_context_v2 lcontext;
781 __u8 Pad[4];
782} __packed;
783
Pavel Shilovsky63eb3de2013-07-04 18:41:09 +0400784struct create_durable {
785 struct create_context ccontext;
786 __u8 Name[8];
Pavel Shilovsky9cbc0b72013-07-09 18:40:58 +0400787 union {
788 __u8 Reserved[16];
789 struct {
790 __u64 PersistentFileId;
791 __u64 VolatileFileId;
792 } Fid;
793 } Data;
Pavel Shilovsky63eb3de2013-07-04 18:41:09 +0400794} __packed;
795
Steve Frenchfe048402018-05-30 17:10:25 -0500796struct create_posix {
797 struct create_context ccontext;
798 __u8 Name[16];
799 __le32 Mode;
800 __u32 Reserved;
801} __packed;
802
Steve Frenchb56eae42015-11-03 09:26:27 -0600803/* See MS-SMB2 2.2.13.2.11 */
804/* Flags */
805#define SMB2_DHANDLE_FLAG_PERSISTENT 0x00000002
806struct durable_context_v2 {
807 __le32 Timeout;
808 __le32 Flags;
809 __u64 Reserved;
810 __u8 CreateGuid[16];
811} __packed;
812
813struct create_durable_v2 {
814 struct create_context ccontext;
815 __u8 Name[8];
816 struct durable_context_v2 dcontext;
817} __packed;
818
819/* See MS-SMB2 2.2.13.2.12 */
820struct durable_reconnect_context_v2 {
821 struct {
822 __u64 PersistentFileId;
823 __u64 VolatileFileId;
824 } Fid;
825 __u8 CreateGuid[16];
826 __le32 Flags; /* see above DHANDLE_FLAG_PERSISTENT */
827} __packed;
828
Steve Frenche7348e32019-06-28 02:35:10 -0500829/* See MS-SMB2 2.2.14.2.9 */
Steve French89a5bfa2019-07-18 17:22:18 -0500830struct create_on_disk_id {
831 struct create_context ccontext;
832 __u8 Name[8];
Steve Frenche7348e32019-06-28 02:35:10 -0500833 __le64 DiskFileId;
834 __le64 VolumeId;
Steve Frenchff2a09e2019-07-06 14:41:38 -0500835 __u32 Reserved[4];
Steve Frenche7348e32019-06-28 02:35:10 -0500836} __packed;
837
Steve Frenchb56eae42015-11-03 09:26:27 -0600838/* See MS-SMB2 2.2.14.2.12 */
839struct durable_reconnect_context_v2_rsp {
840 __le32 Timeout;
841 __le32 Flags; /* see above DHANDLE_FLAG_PERSISTENT */
842} __packed;
843
844struct create_durable_handle_reconnect_v2 {
845 struct create_context ccontext;
846 __u8 Name[8];
847 struct durable_reconnect_context_v2 dcontext;
Pavel Shilovskyd243af72019-11-06 13:58:15 -0800848 __u8 Pad[4];
Steve Frenchb56eae42015-11-03 09:26:27 -0600849} __packed;
850
Steve Frenchcdeaf9d2018-08-10 02:25:06 -0500851/* See MS-SMB2 2.2.13.2.5 */
852struct crt_twarp_ctxt {
853 struct create_context ccontext;
854 __u8 Name[8];
855 __le64 Timestamp;
856
857} __packed;
858
Steve Frenchff2a09e2019-07-06 14:41:38 -0500859/* See MS-SMB2 2.2.13.2.9 */
860struct crt_query_id_ctxt {
861 struct create_context ccontext;
862 __u8 Name[8];
863} __packed;
864
Steve Frenchfdef6652019-12-06 02:02:38 -0600865struct crt_sd_ctxt {
866 struct create_context ccontext;
867 __u8 Name[8];
868 struct smb3_sd sd;
869 struct smb3_acl acl;
870 /* Followed by at least 4 ACEs */
871} __packed;
872
873
Steve French41c13582013-11-14 00:05:36 -0600874#define COPY_CHUNK_RES_KEY_SIZE 24
875struct resume_key_req {
876 char ResumeKey[COPY_CHUNK_RES_KEY_SIZE];
877 __le32 ContextLength; /* MBZ */
Gustavo A. R. Silvacff2def2020-03-09 10:44:51 -0500878 char Context[]; /* ignored, Windows sets to 4 bytes of zero */
Steve French41c13582013-11-14 00:05:36 -0600879} __packed;
880
Steve Frenchbe7457d2013-06-19 17:41:10 -0500881/* this goes in the ioctl buffer when doing a copychunk request */
882struct copychunk_ioctl {
Steve French41c13582013-11-14 00:05:36 -0600883 char SourceKey[COPY_CHUNK_RES_KEY_SIZE];
Steve Frenchbe7457d2013-06-19 17:41:10 -0500884 __le32 ChunkCount; /* we are only sending 1 */
885 __le32 Reserved;
886 /* array will only be one chunk long for us */
887 __le64 SourceOffset;
888 __le64 TargetOffset;
Steve Frenchc8664732013-06-21 15:35:45 -0500889 __le32 Length; /* how many bytes to copy */
Steve Frenchbe7457d2013-06-19 17:41:10 -0500890 __u32 Reserved2;
891} __packed;
892
Steve French31742c52014-08-17 08:38:47 -0500893/* this goes in the ioctl buffer when doing FSCTL_SET_ZERO_DATA */
894struct file_zero_data_information {
895 __le64 FileOffset;
896 __le64 BeyondFinalZero;
897} __packed;
898
Steve French41c13582013-11-14 00:05:36 -0600899struct copychunk_ioctl_rsp {
900 __le32 ChunksWritten;
901 __le32 ChunkBytesWritten;
902 __le32 TotalBytesWritten;
903} __packed;
904
Steve French9d1b0662015-06-24 02:12:19 -0500905struct fsctl_set_integrity_information_req {
906 __le16 ChecksumAlgorithm;
907 __le16 Reserved;
908 __le32 Flags;
909} __packed;
910
911struct fsctl_get_integrity_information_rsp {
912 __le16 ChecksumAlgorithm;
913 __le16 Reserved;
914 __le32 Flags;
915 __le32 ChecksumChunkSizeInBytes;
916 __le32 ClusterSizeInBytes;
917} __packed;
918
Ronnie Sahlberg2f3ebab2019-04-25 16:45:29 +1000919struct file_allocated_range_buffer {
920 __le64 file_offset;
921 __le64 length;
922} __packed;
923
Steve French9d1b0662015-06-24 02:12:19 -0500924/* Integrity ChecksumAlgorithm choices for above */
925#define CHECKSUM_TYPE_NONE 0x0000
926#define CHECKSUM_TYPE_CRC64 0x0002
Steve Frenchb3152e22015-06-24 03:17:02 -0500927#define CHECKSUM_TYPE_UNCHANGED 0xFFFF /* set only */
Steve French9d1b0662015-06-24 02:12:19 -0500928
929/* Integrity flags for above */
930#define FSCTL_INTEGRITY_FLAG_CHECKSUM_ENFORCEMENT_OFF 0x00000001
931
Steve French0df444a2018-10-31 11:24:33 -0500932/* Reparse structures - see MS-FSCC 2.1.2 */
933
934/* struct fsctl_reparse_info_req is empty, only response structs (see below) */
935
936struct reparse_data_buffer {
937 __le32 ReparseTag;
938 __le16 ReparseDataLength;
939 __u16 Reserved;
Gustavo A. R. Silvacff2def2020-03-09 10:44:51 -0500940 __u8 DataBuffer[]; /* Variable Length */
Steve French0df444a2018-10-31 11:24:33 -0500941} __packed;
942
943struct reparse_guid_data_buffer {
944 __le32 ReparseTag;
945 __le16 ReparseDataLength;
946 __u16 Reserved;
947 __u8 ReparseGuid[16];
Gustavo A. R. Silvacff2def2020-03-09 10:44:51 -0500948 __u8 DataBuffer[]; /* Variable Length */
Steve French0df444a2018-10-31 11:24:33 -0500949} __packed;
950
951struct reparse_mount_point_data_buffer {
952 __le32 ReparseTag;
953 __le16 ReparseDataLength;
954 __u16 Reserved;
955 __le16 SubstituteNameOffset;
956 __le16 SubstituteNameLength;
957 __le16 PrintNameOffset;
958 __le16 PrintNameLength;
Gustavo A. R. Silvacff2def2020-03-09 10:44:51 -0500959 __u8 PathBuffer[]; /* Variable Length */
Steve French0df444a2018-10-31 11:24:33 -0500960} __packed;
961
Ronnie Sahlberg5de254d2019-06-27 14:57:02 +1000962#define SYMLINK_FLAG_RELATIVE 0x00000001
963
964struct reparse_symlink_data_buffer {
965 __le32 ReparseTag;
966 __le16 ReparseDataLength;
967 __u16 Reserved;
968 __le16 SubstituteNameOffset;
969 __le16 SubstituteNameLength;
970 __le16 PrintNameOffset;
971 __le16 PrintNameLength;
972 __le32 Flags;
Gustavo A. R. Silvacff2def2020-03-09 10:44:51 -0500973 __u8 PathBuffer[]; /* Variable Length */
Ronnie Sahlberg5de254d2019-06-27 14:57:02 +1000974} __packed;
Steve French0df444a2018-10-31 11:24:33 -0500975
976/* See MS-FSCC 2.1.2.6 and cifspdu.h for struct reparse_posix_data */
977
978
Aurelien Aptel9d496402017-02-13 16:16:49 +0100979/* See MS-DFSC 2.2.2 */
980struct fsctl_get_dfs_referral_req {
981 __le16 MaxReferralLevel;
982 __u8 RequestFileName[];
983} __packed;
984
985/* DFS response is struct get_dfs_refer_rsp */
986
Steve Frenchb56eae42015-11-03 09:26:27 -0600987/* See MS-SMB2 2.2.31.3 */
988struct network_resiliency_req {
989 __le32 Timeout;
990 __le32 Reserved;
991} __packed;
992/* There is no buffer for the response ie no struct network_resiliency_rsp */
993
Steve French9d1b0662015-06-24 02:12:19 -0500994
Steve Frenchff1c0382013-11-19 23:44:46 -0600995struct validate_negotiate_info_req {
Steve French4a72daf2013-06-25 00:20:49 -0500996 __le32 Capabilities;
997 __u8 Guid[SMB2_CLIENT_GUID_SIZE];
998 __le16 SecurityMode;
999 __le16 DialectCount;
Steve Frenchd5c70762019-01-03 02:37:21 -06001000 __le16 Dialects[4]; /* BB expand this if autonegotiate > 4 dialects */
Steve Frenchff1c0382013-11-19 23:44:46 -06001001} __packed;
1002
1003struct validate_negotiate_info_rsp {
1004 __le32 Capabilities;
1005 __u8 Guid[SMB2_CLIENT_GUID_SIZE];
1006 __le16 SecurityMode;
1007 __le16 Dialect; /* Dialect in use for the connection */
Steve French4a72daf2013-06-25 00:20:49 -05001008} __packed;
1009
Aurelien Aptelbead0422018-06-14 15:43:17 +02001010#define RSS_CAPABLE cpu_to_le32(0x00000001)
1011#define RDMA_CAPABLE cpu_to_le32(0x00000002)
1012
1013#define INTERNETWORK cpu_to_le16(0x0002)
1014#define INTERNETWORKV6 cpu_to_le16(0x0017)
Steve French4a72daf2013-06-25 00:20:49 -05001015
1016struct network_interface_info_ioctl_rsp {
1017 __le32 Next; /* next interface. zero if this is last one */
1018 __le32 IfIndex;
1019 __le32 Capability; /* RSS or RDMA Capable */
1020 __le32 Reserved;
1021 __le64 LinkSpeed;
Aurelien Aptelbead0422018-06-14 15:43:17 +02001022 __le16 Family;
1023 __u8 Buffer[126];
1024} __packed;
1025
1026struct iface_info_ipv4 {
1027 __be16 Port;
1028 __be32 IPv4Address;
1029 __be64 Reserved;
1030} __packed;
1031
1032struct iface_info_ipv6 {
1033 __be16 Port;
1034 __be32 FlowInfo;
1035 __u8 IPv6Address[16];
1036 __be32 ScopeId;
Steve French4a72daf2013-06-25 00:20:49 -05001037} __packed;
1038
1039#define NO_FILE_ID 0xFFFFFFFFFFFFFFFFULL /* general ioctls to srv not to file */
1040
Steve French64a5cfa2013-10-14 15:31:32 -05001041struct compress_ioctl {
Steve Frenchc7f508a2013-10-14 15:27:32 -05001042 __le16 CompressionState; /* See cifspdu.h for possible flag values */
Steve French64a5cfa2013-10-14 15:31:32 -05001043} __packed;
1044
Steve French02b16662015-06-27 21:18:36 -07001045struct duplicate_extents_to_file {
1046 __u64 PersistentFileHandle; /* source file handle, opaque endianness */
1047 __u64 VolatileFileHandle;
1048 __le64 SourceFileOffset;
1049 __le64 TargetFileOffset;
1050 __le64 ByteCount; /* Bytes to be copied */
1051} __packed;
1052
Ronnie Sahlberg72c419d2019-03-13 14:37:49 +10001053/*
1054 * Maximum number of iovs we need for an ioctl request.
1055 * [0] : struct smb2_ioctl_req
1056 * [1] : in_data
1057 */
1058#define SMB2_IOCTL_IOV_SIZE 2
1059
Steve Frenchbe7457d2013-06-19 17:41:10 -05001060struct smb2_ioctl_req {
Ronnie Sahlberg97754682017-11-09 12:14:20 +11001061 struct smb2_sync_hdr sync_hdr;
Steve Frenchbe7457d2013-06-19 17:41:10 -05001062 __le16 StructureSize; /* Must be 57 */
1063 __u16 Reserved;
1064 __le32 CtlCode;
1065 __u64 PersistentFileId; /* opaque endianness */
1066 __u64 VolatileFileId; /* opaque endianness */
1067 __le32 InputOffset;
1068 __le32 InputCount;
1069 __le32 MaxInputResponse;
1070 __le32 OutputOffset;
1071 __le32 OutputCount;
1072 __le32 MaxOutputResponse;
1073 __le32 Flags;
1074 __u32 Reserved2;
Gustavo A. R. Silvacff2def2020-03-09 10:44:51 -05001075 __u8 Buffer[];
Steve Frenchbe7457d2013-06-19 17:41:10 -05001076} __packed;
1077
1078struct smb2_ioctl_rsp {
Ronnie Sahlberg49f466b2018-06-01 10:53:06 +10001079 struct smb2_sync_hdr sync_hdr;
Steve Frenchbe7457d2013-06-19 17:41:10 -05001080 __le16 StructureSize; /* Must be 57 */
1081 __u16 Reserved;
1082 __le32 CtlCode;
1083 __u64 PersistentFileId; /* opaque endianness */
1084 __u64 VolatileFileId; /* opaque endianness */
1085 __le32 InputOffset;
1086 __le32 InputCount;
1087 __le32 OutputOffset;
1088 __le32 OutputCount;
1089 __le32 Flags;
1090 __u32 Reserved2;
1091 /* char * buffer[] */
1092} __packed;
1093
Pavel Shilovsky2503a0d2011-12-26 22:58:46 +04001094/* Currently defined values for close flags */
1095#define SMB2_CLOSE_FLAG_POSTQUERY_ATTRIB cpu_to_le16(0x0001)
1096struct smb2_close_req {
Ronnie Sahlbergafcccef2017-11-09 12:14:19 +11001097 struct smb2_sync_hdr sync_hdr;
Pavel Shilovsky2503a0d2011-12-26 22:58:46 +04001098 __le16 StructureSize; /* Must be 24 */
1099 __le16 Flags;
1100 __le32 Reserved;
1101 __u64 PersistentFileId; /* opaque endianness */
1102 __u64 VolatileFileId; /* opaque endianness */
1103} __packed;
1104
Ronnie Sahlbergc4627e62019-01-29 12:46:17 +10001105/*
1106 * Maximum size of a SMB2_CLOSE response is 64 (smb2 header) + 60 (data)
1107 */
1108#define MAX_SMB2_CLOSE_RESPONSE_SIZE 124
1109
Pavel Shilovsky2503a0d2011-12-26 22:58:46 +04001110struct smb2_close_rsp {
Ronnie Sahlberg49f466b2018-06-01 10:53:06 +10001111 struct smb2_sync_hdr sync_hdr;
Pavel Shilovsky2503a0d2011-12-26 22:58:46 +04001112 __le16 StructureSize; /* 60 */
1113 __le16 Flags;
1114 __le32 Reserved;
1115 __le64 CreationTime;
1116 __le64 LastAccessTime;
1117 __le64 LastWriteTime;
1118 __le64 ChangeTime;
1119 __le64 AllocationSize; /* Beginning of FILE_STANDARD_INFO equivalent */
1120 __le64 EndOfFile;
1121 __le32 Attributes;
1122} __packed;
1123
Pavel Shilovsky7a5cfb12012-09-18 16:20:28 -07001124struct smb2_flush_req {
Ronnie Sahlberg1f444e42017-11-20 11:24:39 +11001125 struct smb2_sync_hdr sync_hdr;
Pavel Shilovsky7a5cfb12012-09-18 16:20:28 -07001126 __le16 StructureSize; /* Must be 24 */
1127 __le16 Reserved1;
1128 __le32 Reserved2;
1129 __u64 PersistentFileId; /* opaque endianness */
1130 __u64 VolatileFileId; /* opaque endianness */
1131} __packed;
1132
1133struct smb2_flush_rsp {
Ronnie Sahlberg49f466b2018-06-01 10:53:06 +10001134 struct smb2_sync_hdr sync_hdr;
Pavel Shilovsky7a5cfb12012-09-18 16:20:28 -07001135 __le16 StructureSize;
1136 __le16 Reserved;
1137} __packed;
1138
Steve French2b5dc282013-06-13 10:51:10 -05001139/* For read request Flags field below, following flag is defined for SMB3.02 */
1140#define SMB2_READFLAG_READ_UNBUFFERED 0x01
Steve French0df7edd2019-04-27 02:06:20 -05001141#define SMB2_READFLAG_REQUEST_COMPRESSED 0x02 /* See MS-SMB2 2.2.19 */
Steve French2b5dc282013-06-13 10:51:10 -05001142
1143/* Channel field for read and write: exactly one of following flags can be set*/
Steve French2026b062018-01-24 23:07:41 -06001144#define SMB2_CHANNEL_NONE cpu_to_le32(0x00000000)
1145#define SMB2_CHANNEL_RDMA_V1 cpu_to_le32(0x00000001) /* SMB3 or later */
1146#define SMB2_CHANNEL_RDMA_V1_INVALIDATE cpu_to_le32(0x00000002) /* >= SMB3.02 */
Steve French2b5dc282013-06-13 10:51:10 -05001147
Pavel Shilovskyb8f57ee2016-11-23 15:31:54 -08001148/* SMB2 read request without RFC1001 length at the beginning */
1149struct smb2_read_plain_req {
1150 struct smb2_sync_hdr sync_hdr;
Pavel Shilovsky09a47072012-09-18 16:20:29 -07001151 __le16 StructureSize; /* Must be 49 */
1152 __u8 Padding; /* offset from start of SMB2 header to place read */
Steve French2b5dc282013-06-13 10:51:10 -05001153 __u8 Flags; /* MBZ unless SMB3.02 or later */
Pavel Shilovsky09a47072012-09-18 16:20:29 -07001154 __le32 Length;
1155 __le64 Offset;
1156 __u64 PersistentFileId; /* opaque endianness */
1157 __u64 VolatileFileId; /* opaque endianness */
1158 __le32 MinimumCount;
Steve French2b5dc282013-06-13 10:51:10 -05001159 __le32 Channel; /* MBZ except for SMB3 or later */
Pavel Shilovsky09a47072012-09-18 16:20:29 -07001160 __le32 RemainingBytes;
Steve French2026b062018-01-24 23:07:41 -06001161 __le16 ReadChannelInfoOffset;
1162 __le16 ReadChannelInfoLength;
Pavel Shilovsky09a47072012-09-18 16:20:29 -07001163 __u8 Buffer[1];
1164} __packed;
1165
1166struct smb2_read_rsp {
Ronnie Sahlberg49f466b2018-06-01 10:53:06 +10001167 struct smb2_sync_hdr sync_hdr;
Pavel Shilovsky09a47072012-09-18 16:20:29 -07001168 __le16 StructureSize; /* Must be 17 */
1169 __u8 DataOffset;
1170 __u8 Reserved;
1171 __le32 DataLength;
1172 __le32 DataRemaining;
1173 __u32 Reserved2;
1174 __u8 Buffer[1];
1175} __packed;
1176
Steve French2b5dc282013-06-13 10:51:10 -05001177/* For write request Flags field below the following flags are defined: */
1178#define SMB2_WRITEFLAG_WRITE_THROUGH 0x00000001 /* SMB2.1 or later */
1179#define SMB2_WRITEFLAG_WRITE_UNBUFFERED 0x00000002 /* SMB3.02 or later */
Pavel Shilovsky33319142012-09-18 16:20:29 -07001180
1181struct smb2_write_req {
Ronnie Sahlbergf5688a62017-11-20 11:24:41 +11001182 struct smb2_sync_hdr sync_hdr;
Pavel Shilovsky33319142012-09-18 16:20:29 -07001183 __le16 StructureSize; /* Must be 49 */
1184 __le16 DataOffset; /* offset from start of SMB2 header to write data */
1185 __le32 Length;
1186 __le64 Offset;
1187 __u64 PersistentFileId; /* opaque endianness */
1188 __u64 VolatileFileId; /* opaque endianness */
1189 __le32 Channel; /* Reserved MBZ */
1190 __le32 RemainingBytes;
Steve French2026b062018-01-24 23:07:41 -06001191 __le16 WriteChannelInfoOffset;
1192 __le16 WriteChannelInfoLength;
Pavel Shilovsky33319142012-09-18 16:20:29 -07001193 __le32 Flags;
1194 __u8 Buffer[1];
1195} __packed;
1196
1197struct smb2_write_rsp {
Ronnie Sahlberg49f466b2018-06-01 10:53:06 +10001198 struct smb2_sync_hdr sync_hdr;
Pavel Shilovsky33319142012-09-18 16:20:29 -07001199 __le16 StructureSize; /* Must be 17 */
1200 __u8 DataOffset;
1201 __u8 Reserved;
1202 __le32 DataLength;
1203 __le32 DataRemaining;
1204 __u32 Reserved2;
1205 __u8 Buffer[1];
1206} __packed;
1207
Steve Frenchedf3ef32019-05-05 17:25:12 -05001208/* notify flags */
1209#define SMB2_WATCH_TREE 0x0001
1210
1211/* notify completion filter flags. See MS-FSCC 2.6 and MS-SMB2 2.2.35 */
1212#define FILE_NOTIFY_CHANGE_FILE_NAME 0x00000001
1213#define FILE_NOTIFY_CHANGE_DIR_NAME 0x00000002
1214#define FILE_NOTIFY_CHANGE_ATTRIBUTES 0x00000004
1215#define FILE_NOTIFY_CHANGE_SIZE 0x00000008
1216#define FILE_NOTIFY_CHANGE_LAST_WRITE 0x00000010
1217#define FILE_NOTIFY_CHANGE_LAST_ACCESS 0x00000020
1218#define FILE_NOTIFY_CHANGE_CREATION 0x00000040
1219#define FILE_NOTIFY_CHANGE_EA 0x00000080
1220#define FILE_NOTIFY_CHANGE_SECURITY 0x00000100
1221#define FILE_NOTIFY_CHANGE_STREAM_NAME 0x00000200
1222#define FILE_NOTIFY_CHANGE_STREAM_SIZE 0x00000400
1223#define FILE_NOTIFY_CHANGE_STREAM_WRITE 0x00000800
1224
1225struct smb2_change_notify_req {
1226 struct smb2_sync_hdr sync_hdr;
1227 __le16 StructureSize;
1228 __le16 Flags;
1229 __le32 OutputBufferLength;
1230 __u64 PersistentFileId; /* opaque endianness */
1231 __u64 VolatileFileId; /* opaque endianness */
1232 __le32 CompletionFilter;
1233 __u32 Reserved;
1234} __packed;
1235
1236struct smb2_change_notify_rsp {
1237 struct smb2_sync_hdr sync_hdr;
1238 __le16 StructureSize; /* Must be 9 */
1239 __le16 OutputBufferOffset;
1240 __le32 OutputBufferLength;
1241 __u8 Buffer[1]; /* array of file notify structs */
1242} __packed;
1243
Pavel Shilovsky027e8ee2012-09-19 06:22:43 -07001244#define SMB2_LOCKFLAG_SHARED_LOCK 0x0001
1245#define SMB2_LOCKFLAG_EXCLUSIVE_LOCK 0x0002
1246#define SMB2_LOCKFLAG_UNLOCK 0x0004
1247#define SMB2_LOCKFLAG_FAIL_IMMEDIATELY 0x0010
1248
Pavel Shilovskyf7ba7fe2012-09-19 06:22:43 -07001249struct smb2_lock_element {
1250 __le64 Offset;
1251 __le64 Length;
1252 __le32 Flags;
1253 __le32 Reserved;
1254} __packed;
1255
1256struct smb2_lock_req {
Ronnie Sahlbergced93672017-11-21 10:07:27 +11001257 struct smb2_sync_hdr sync_hdr;
Pavel Shilovskyf7ba7fe2012-09-19 06:22:43 -07001258 __le16 StructureSize; /* Must be 48 */
1259 __le16 LockCount;
1260 __le32 Reserved;
1261 __u64 PersistentFileId; /* opaque endianness */
1262 __u64 VolatileFileId; /* opaque endianness */
1263 /* Followed by at least one */
1264 struct smb2_lock_element locks[1];
1265} __packed;
1266
1267struct smb2_lock_rsp {
Ronnie Sahlberg49f466b2018-06-01 10:53:06 +10001268 struct smb2_sync_hdr sync_hdr;
Pavel Shilovskyf7ba7fe2012-09-19 06:22:43 -07001269 __le16 StructureSize; /* Must be 4 */
1270 __le16 Reserved;
1271} __packed;
1272
Pavel Shilovsky9094fad2012-07-12 18:30:44 +04001273struct smb2_echo_req {
Ronnie Sahlberg7f7ae752017-11-09 12:14:21 +11001274 struct smb2_sync_hdr sync_hdr;
Pavel Shilovsky9094fad2012-07-12 18:30:44 +04001275 __le16 StructureSize; /* Must be 4 */
1276 __u16 Reserved;
1277} __packed;
1278
1279struct smb2_echo_rsp {
Ronnie Sahlberg49f466b2018-06-01 10:53:06 +10001280 struct smb2_sync_hdr sync_hdr;
Pavel Shilovsky9094fad2012-07-12 18:30:44 +04001281 __le16 StructureSize; /* Must be 4 */
1282 __u16 Reserved;
1283} __packed;
1284
Pavel Shilovskyd324f08d2012-09-18 16:20:33 -07001285/* search (query_directory) Flags field */
1286#define SMB2_RESTART_SCANS 0x01
1287#define SMB2_RETURN_SINGLE_ENTRY 0x02
1288#define SMB2_INDEX_SPECIFIED 0x04
1289#define SMB2_REOPEN 0x10
1290
Ronnie Sahlberg0a177992020-01-08 13:08:04 +10001291#define SMB2_QUERY_DIRECTORY_IOV_SIZE 2
1292
Pavel Shilovskyd324f08d2012-09-18 16:20:33 -07001293struct smb2_query_directory_req {
Ronnie Sahlberg7c00c3a2017-11-20 11:24:45 +11001294 struct smb2_sync_hdr sync_hdr;
Pavel Shilovskyd324f08d2012-09-18 16:20:33 -07001295 __le16 StructureSize; /* Must be 33 */
1296 __u8 FileInformationClass;
1297 __u8 Flags;
1298 __le32 FileIndex;
1299 __u64 PersistentFileId; /* opaque endianness */
1300 __u64 VolatileFileId; /* opaque endianness */
1301 __le16 FileNameOffset;
1302 __le16 FileNameLength;
1303 __le32 OutputBufferLength;
1304 __u8 Buffer[1];
1305} __packed;
1306
1307struct smb2_query_directory_rsp {
Ronnie Sahlberg49f466b2018-06-01 10:53:06 +10001308 struct smb2_sync_hdr sync_hdr;
Pavel Shilovskyd324f08d2012-09-18 16:20:33 -07001309 __le16 StructureSize; /* Must be 9 */
1310 __le16 OutputBufferOffset;
1311 __le32 OutputBufferLength;
1312 __u8 Buffer[1];
1313} __packed;
1314
Pavel Shilovskybe4cb9e2011-12-29 17:06:33 +04001315/* Possible InfoType values */
1316#define SMB2_O_INFO_FILE 0x01
1317#define SMB2_O_INFO_FILESYSTEM 0x02
1318#define SMB2_O_INFO_SECURITY 0x03
1319#define SMB2_O_INFO_QUOTA 0x04
1320
Steve French911a8df2014-10-19 19:18:05 -05001321/* Security info type additionalinfo flags. See MS-SMB2 (2.2.37) or MS-DTYP */
1322#define OWNER_SECINFO 0x00000001
1323#define GROUP_SECINFO 0x00000002
1324#define DACL_SECINFO 0x00000004
1325#define SACL_SECINFO 0x00000008
1326#define LABEL_SECINFO 0x00000010
1327#define ATTRIBUTE_SECINFO 0x00000020
1328#define SCOPE_SECINFO 0x00000040
1329#define BACKUP_SECINFO 0x00010000
1330#define UNPROTECTED_SACL_SECINFO 0x10000000
1331#define UNPROTECTED_DACL_SECINFO 0x20000000
1332#define PROTECTED_SACL_SECINFO 0x40000000
1333#define PROTECTED_DACL_SECINFO 0x80000000
1334
1335/* Flags used for FileFullEAinfo */
1336#define SL_RESTART_SCAN 0x00000001
1337#define SL_RETURN_SINGLE_ENTRY 0x00000002
1338#define SL_INDEX_SPECIFIED 0x00000004
1339
Pavel Shilovskybe4cb9e2011-12-29 17:06:33 +04001340struct smb2_query_info_req {
Ronnie Sahlbergb2fb7fe2017-11-20 11:24:46 +11001341 struct smb2_sync_hdr sync_hdr;
Pavel Shilovskybe4cb9e2011-12-29 17:06:33 +04001342 __le16 StructureSize; /* Must be 41 */
1343 __u8 InfoType;
1344 __u8 FileInfoClass;
1345 __le32 OutputBufferLength;
1346 __le16 InputBufferOffset;
1347 __u16 Reserved;
1348 __le32 InputBufferLength;
1349 __le32 AdditionalInformation;
1350 __le32 Flags;
1351 __u64 PersistentFileId; /* opaque endianness */
1352 __u64 VolatileFileId; /* opaque endianness */
1353 __u8 Buffer[1];
1354} __packed;
1355
1356struct smb2_query_info_rsp {
Ronnie Sahlberg49f466b2018-06-01 10:53:06 +10001357 struct smb2_sync_hdr sync_hdr;
Pavel Shilovskybe4cb9e2011-12-29 17:06:33 +04001358 __le16 StructureSize; /* Must be 9 */
1359 __le16 OutputBufferOffset;
1360 __le32 OutputBufferLength;
1361 __u8 Buffer[1];
1362} __packed;
1363
Ronnie Sahlberg14e562a2018-09-03 13:33:50 +10001364/*
1365 * Maximum number of iovs we need for a set-info request.
1366 * The largest one is rename/hardlink
1367 * [0] : struct smb2_set_info_req + smb2_file_[rename|link]_info
1368 * [1] : path
1369 * [2] : compound padding
1370 */
1371#define SMB2_SET_INFO_IOV_SIZE 3
1372
Pavel Shilovsky35143eb2012-09-18 16:20:31 -07001373struct smb2_set_info_req {
Ronnie Sahlberg2fc803e2017-11-20 11:24:44 +11001374 struct smb2_sync_hdr sync_hdr;
Pavel Shilovsky35143eb2012-09-18 16:20:31 -07001375 __le16 StructureSize; /* Must be 33 */
1376 __u8 InfoType;
1377 __u8 FileInfoClass;
1378 __le32 BufferLength;
1379 __le16 BufferOffset;
1380 __u16 Reserved;
1381 __le32 AdditionalInformation;
1382 __u64 PersistentFileId; /* opaque endianness */
1383 __u64 VolatileFileId; /* opaque endianness */
1384 __u8 Buffer[1];
1385} __packed;
1386
1387struct smb2_set_info_rsp {
Ronnie Sahlberg49f466b2018-06-01 10:53:06 +10001388 struct smb2_sync_hdr sync_hdr;
Pavel Shilovsky35143eb2012-09-18 16:20:31 -07001389 __le16 StructureSize; /* Must be 2 */
1390} __packed;
1391
Ronnie Sahlberg0d5a2882018-06-01 10:53:03 +10001392struct smb2_oplock_break {
Ronnie Sahlberg21ad9482017-11-20 11:24:43 +11001393 struct smb2_sync_hdr sync_hdr;
1394 __le16 StructureSize; /* Must be 24 */
1395 __u8 OplockLevel;
1396 __u8 Reserved;
1397 __le32 Reserved2;
1398 __u64 PersistentFid;
1399 __u64 VolatileFid;
1400} __packed;
1401
Pavel Shilovsky0822f512012-09-19 06:22:45 -07001402#define SMB2_NOTIFY_BREAK_LEASE_FLAG_ACK_REQUIRED cpu_to_le32(0x01)
1403
1404struct smb2_lease_break {
Ronnie Sahlberg49f466b2018-06-01 10:53:06 +10001405 struct smb2_sync_hdr sync_hdr;
Pavel Shilovsky0822f512012-09-19 06:22:45 -07001406 __le16 StructureSize; /* Must be 44 */
Pavel Shilovsky9bd45402019-10-29 16:51:19 -07001407 __le16 Epoch;
Pavel Shilovsky0822f512012-09-19 06:22:45 -07001408 __le32 Flags;
1409 __u8 LeaseKey[16];
1410 __le32 CurrentLeaseState;
1411 __le32 NewLeaseState;
1412 __le32 BreakReason;
1413 __le32 AccessMaskHint;
1414 __le32 ShareMaskHint;
1415} __packed;
1416
1417struct smb2_lease_ack {
Ronnie Sahlberg8eb79982017-11-21 11:04:37 +11001418 struct smb2_sync_hdr sync_hdr;
Pavel Shilovsky0822f512012-09-19 06:22:45 -07001419 __le16 StructureSize; /* Must be 36 */
1420 __le16 Reserved;
1421 __le32 Flags;
1422 __u8 LeaseKey[16];
1423 __le32 LeaseState;
1424 __le64 LeaseDuration;
1425} __packed;
1426
Pavel Shilovskybe4cb9e2011-12-29 17:06:33 +04001427/*
1428 * PDU infolevel structure definitions
1429 * BB consider moving to a different header
1430 */
1431
Pavel Shilovsky6fc05c22012-09-18 16:20:34 -07001432/* File System Information Classes */
1433#define FS_VOLUME_INFORMATION 1 /* Query */
Steven Frenchaf6a12e2013-10-09 20:55:53 -05001434#define FS_LABEL_INFORMATION 2 /* Local only */
Pavel Shilovsky6fc05c22012-09-18 16:20:34 -07001435#define FS_SIZE_INFORMATION 3 /* Query */
1436#define FS_DEVICE_INFORMATION 4 /* Query */
1437#define FS_ATTRIBUTE_INFORMATION 5 /* Query */
1438#define FS_CONTROL_INFORMATION 6 /* Query, Set */
1439#define FS_FULL_SIZE_INFORMATION 7 /* Query */
1440#define FS_OBJECT_ID_INFORMATION 8 /* Query, Set */
Steven Frenchaf6a12e2013-10-09 20:55:53 -05001441#define FS_DRIVER_PATH_INFORMATION 9 /* Local only */
1442#define FS_VOLUME_FLAGS_INFORMATION 10 /* Local only */
1443#define FS_SECTOR_SIZE_INFORMATION 11 /* SMB3 or later. Query */
Steve French2d304212018-06-24 23:28:12 -05001444#define FS_POSIX_INFORMATION 100 /* SMB3.1.1 POSIX. Query */
Pavel Shilovsky6fc05c22012-09-18 16:20:34 -07001445
1446struct smb2_fs_full_size_info {
1447 __le64 TotalAllocationUnits;
1448 __le64 CallerAvailableAllocationUnits;
1449 __le64 ActualAvailableAllocationUnits;
1450 __le32 SectorsPerAllocationUnit;
1451 __le32 BytesPerSector;
1452} __packed;
1453
Steven Frenchaf6a12e2013-10-09 20:55:53 -05001454#define SSINFO_FLAGS_ALIGNED_DEVICE 0x00000001
1455#define SSINFO_FLAGS_PARTITION_ALIGNED_ON_DEVICE 0x00000002
1456#define SSINFO_FLAGS_NO_SEEK_PENALTY 0x00000004
1457#define SSINFO_FLAGS_TRIM_ENABLED 0x00000008
1458
1459/* sector size info struct */
1460struct smb3_fs_ss_info {
1461 __le32 LogicalBytesPerSector;
1462 __le32 PhysicalBytesPerSectorForAtomicity;
1463 __le32 PhysicalBytesPerSectorForPerf;
1464 __le32 FileSystemEffectivePhysicalBytesPerSectorForAtomicity;
1465 __le32 Flags;
1466 __le32 ByteOffsetForSectorAlignment;
1467 __le32 ByteOffsetForPartitionAlignment;
1468} __packed;
1469
Steve French21ba3842018-06-24 23:18:52 -05001470/* volume info struct - see MS-FSCC 2.5.9 */
1471#define MAX_VOL_LABEL_LEN 32
1472struct smb3_fs_vol_info {
1473 __le64 VolumeCreationTime;
1474 __u32 VolumeSerialNumber;
1475 __le32 VolumeLabelLength; /* includes trailing null */
1476 __u8 SupportsObjects; /* True if eg like NTFS, supports objects */
1477 __u8 Reserved;
Gustavo A. R. Silvacff2def2020-03-09 10:44:51 -05001478 __u8 VolumeLabel[]; /* variable len */
Steve French21ba3842018-06-24 23:18:52 -05001479} __packed;
1480
Pavel Shilovskybe4cb9e2011-12-29 17:06:33 +04001481/* partial list of QUERY INFO levels */
1482#define FILE_DIRECTORY_INFORMATION 1
1483#define FILE_FULL_DIRECTORY_INFORMATION 2
1484#define FILE_BOTH_DIRECTORY_INFORMATION 3
1485#define FILE_BASIC_INFORMATION 4
1486#define FILE_STANDARD_INFORMATION 5
1487#define FILE_INTERNAL_INFORMATION 6
1488#define FILE_EA_INFORMATION 7
1489#define FILE_ACCESS_INFORMATION 8
1490#define FILE_NAME_INFORMATION 9
1491#define FILE_RENAME_INFORMATION 10
1492#define FILE_LINK_INFORMATION 11
1493#define FILE_NAMES_INFORMATION 12
1494#define FILE_DISPOSITION_INFORMATION 13
1495#define FILE_POSITION_INFORMATION 14
1496#define FILE_FULL_EA_INFORMATION 15
1497#define FILE_MODE_INFORMATION 16
1498#define FILE_ALIGNMENT_INFORMATION 17
1499#define FILE_ALL_INFORMATION 18
1500#define FILE_ALLOCATION_INFORMATION 19
1501#define FILE_END_OF_FILE_INFORMATION 20
1502#define FILE_ALTERNATE_NAME_INFORMATION 21
1503#define FILE_STREAM_INFORMATION 22
1504#define FILE_PIPE_INFORMATION 23
1505#define FILE_PIPE_LOCAL_INFORMATION 24
1506#define FILE_PIPE_REMOTE_INFORMATION 25
1507#define FILE_MAILSLOT_QUERY_INFORMATION 26
1508#define FILE_MAILSLOT_SET_INFORMATION 27
1509#define FILE_COMPRESSION_INFORMATION 28
1510#define FILE_OBJECT_ID_INFORMATION 29
1511/* Number 30 not defined in documents */
1512#define FILE_MOVE_CLUSTER_INFORMATION 31
1513#define FILE_QUOTA_INFORMATION 32
1514#define FILE_REPARSE_POINT_INFORMATION 33
1515#define FILE_NETWORK_OPEN_INFORMATION 34
1516#define FILE_ATTRIBUTE_TAG_INFORMATION 35
1517#define FILE_TRACKING_INFORMATION 36
1518#define FILEID_BOTH_DIRECTORY_INFORMATION 37
1519#define FILEID_FULL_DIRECTORY_INFORMATION 38
1520#define FILE_VALID_DATA_LENGTH_INFORMATION 39
1521#define FILE_SHORT_NAME_INFORMATION 40
1522#define FILE_SFIO_RESERVE_INFORMATION 44
1523#define FILE_SFIO_VOLUME_INFORMATION 45
1524#define FILE_HARD_LINK_INFORMATION 46
1525#define FILE_NORMALIZED_NAME_INFORMATION 48
1526#define FILEID_GLOBAL_TX_DIRECTORY_INFORMATION 50
1527#define FILE_STANDARD_LINK_INFORMATION 54
Steve French51d92d62020-02-06 12:32:03 -06001528#define FILE_ID_INFORMATION 59
Pavel Shilovskybe4cb9e2011-12-29 17:06:33 +04001529
Pavel Shilovskyf0df7372012-09-18 16:20:26 -07001530struct smb2_file_internal_info {
1531 __le64 IndexNumber;
1532} __packed; /* level 6 Query */
1533
Pavel Shilovsky35143eb2012-09-18 16:20:31 -07001534struct smb2_file_rename_info { /* encoding of request for level 10 */
1535 __u8 ReplaceIfExists; /* 1 = replace existing target with new */
1536 /* 0 = fail if target already exists */
1537 __u8 Reserved[7];
1538 __u64 RootDirectory; /* MBZ for network operations (why says spec?) */
1539 __le32 FileNameLength;
Gustavo A. R. Silvacff2def2020-03-09 10:44:51 -05001540 char FileName[]; /* New name to be assigned */
Pavel Shilovsky35143eb2012-09-18 16:20:31 -07001541} __packed; /* level 10 Set */
1542
Pavel Shilovsky568798c2012-09-18 16:20:31 -07001543struct smb2_file_link_info { /* encoding of request for level 11 */
1544 __u8 ReplaceIfExists; /* 1 = replace existing link with new */
1545 /* 0 = fail if link already exists */
1546 __u8 Reserved[7];
1547 __u64 RootDirectory; /* MBZ for network operations (why says spec?) */
1548 __le32 FileNameLength;
Gustavo A. R. Silvacff2def2020-03-09 10:44:51 -05001549 char FileName[]; /* Name to be assigned to new link */
Pavel Shilovsky568798c2012-09-18 16:20:31 -07001550} __packed; /* level 11 Set */
1551
Ronnie Sahlberg95907fe2017-08-24 11:24:55 +10001552struct smb2_file_full_ea_info { /* encoding of response for level 15 */
1553 __le32 next_entry_offset;
1554 __u8 flags;
1555 __u8 ea_name_length;
1556 __le16 ea_value_length;
Gustavo A. R. Silvacff2def2020-03-09 10:44:51 -05001557 char ea_data[]; /* \0 terminated name plus value */
Ronnie Sahlberg95907fe2017-08-24 11:24:55 +10001558} __packed; /* level 15 Set */
1559
Pavel Shilovskybe4cb9e2011-12-29 17:06:33 +04001560/*
1561 * This level 18, although with struct with same name is different from cifs
1562 * level 0x107. Level 0x107 has an extra u64 between AccessFlags and
1563 * CurrentByteOffset.
1564 */
1565struct smb2_file_all_info { /* data block encoding of response to level 18 */
1566 __le64 CreationTime; /* Beginning of FILE_BASIC_INFO equivalent */
1567 __le64 LastAccessTime;
1568 __le64 LastWriteTime;
1569 __le64 ChangeTime;
1570 __le32 Attributes;
1571 __u32 Pad1; /* End of FILE_BASIC_INFO_INFO equivalent */
1572 __le64 AllocationSize; /* Beginning of FILE_STANDARD_INFO equivalent */
1573 __le64 EndOfFile; /* size ie offset to first free byte in file */
1574 __le32 NumberOfLinks; /* hard links */
1575 __u8 DeletePending;
1576 __u8 Directory;
1577 __u16 Pad2; /* End of FILE_STANDARD_INFO equivalent */
1578 __le64 IndexNumber;
1579 __le32 EASize;
1580 __le32 AccessFlags;
1581 __le64 CurrentByteOffset;
1582 __le32 Mode;
1583 __le32 AlignmentRequirement;
1584 __le32 FileNameLength;
1585 char FileName[1];
1586} __packed; /* level 18 Query */
1587
Pavel Shilovskyc839ff22012-09-18 16:20:32 -07001588struct smb2_file_eof_info { /* encoding of request for level 10 */
1589 __le64 EndOfFile; /* new end of file value */
1590} __packed; /* level 20 Set */
1591
Steve French43f8a6a2019-12-02 21:46:54 -06001592struct smb2_file_network_open_info {
1593 __le64 CreationTime;
1594 __le64 LastAccessTime;
1595 __le64 LastWriteTime;
1596 __le64 ChangeTime;
1597 __le64 AllocationSize;
1598 __le64 EndOfFile;
1599 __le32 Attributes;
1600 __le32 Reserved;
1601} __packed; /* level 34 Query also similar returned in close rsp and open rsp */
1602
Steve French51d92d62020-02-06 12:32:03 -06001603/* See MS-FSCC 2.4.43 */
1604struct smb2_file_id_information {
1605 __le64 VolumeSerialNumber;
1606 __u64 PersistentFileId; /* opaque endianness */
1607 __u64 VolatileFileId; /* opaque endianness */
1608} __packed; /* level 59 */
1609
Ronnie Sahlberg730928c2018-08-08 15:07:49 +10001610extern char smb2_padding[7];
1611
Steve Frenchab3459d2020-02-06 17:31:56 -06001612/* equivalent of the contents of SMB3.1.1 POSIX open context response */
Aurelien Aptel2e8af972020-02-08 15:50:56 +01001613struct create_posix_rsp {
Aurelien Aptel69dda302020-03-02 17:53:22 +01001614 u32 nlink;
1615 u32 reparse_tag;
1616 u32 mode;
1617 struct cifs_sid owner; /* var-sized on the wire */
1618 struct cifs_sid group; /* var-sized on the wire */
Aurelien Aptel2e8af972020-02-08 15:50:56 +01001619} __packed;
Aurelien Aptel349e13a2020-02-08 15:50:57 +01001620
1621/*
1622 * SMB2-only POSIX info level
1623 *
1624 * See posix_info_sid_size(), posix_info_extra_size() and
1625 * posix_info_parse() to help with the handling of this struct.
1626 */
1627struct smb2_posix_info {
1628 __le32 NextEntryOffset;
1629 __u32 Ignored;
1630 __le64 CreationTime;
1631 __le64 LastAccessTime;
1632 __le64 LastWriteTime;
1633 __le64 ChangeTime;
1634 __le64 EndOfFile;
1635 __le64 AllocationSize;
1636 __le32 DosAttributes;
1637 __le64 Inode;
1638 __le32 DeviceId;
1639 __le32 Zero;
1640 /* beginning of POSIX Create Context Response */
1641 __le32 HardLinks;
1642 __le32 ReparseTag;
1643 __le32 Mode;
1644 /*
1645 * var sized owner SID
1646 * var sized group SID
1647 * le32 filenamelength
1648 * u8 filename[]
1649 */
1650} __packed;
1651
1652/*
1653 * Parsed version of the above struct. Allows direct access to the
1654 * variable length fields
1655 */
1656struct smb2_posix_info_parsed {
1657 const struct smb2_posix_info *base;
1658 size_t size;
1659 struct cifs_sid owner;
1660 struct cifs_sid group;
1661 int name_len;
1662 const u8 *name;
Steve Frenchab3459d2020-02-06 17:31:56 -06001663};
Aurelien Aptel349e13a2020-02-08 15:50:57 +01001664
Steve Frenchddfbefb2011-03-15 02:08:48 +00001665#endif /* _SMB2PDU_H */