blob: 994b34843c3a9c20cce753a609fca3e2afc94d96 [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
83#define NUMBER_OF_SMB2_COMMANDS 0x0013
84
85/* BB FIXME - analyze following length BB */
86#define MAX_SMB2_HDR_SIZE 0x78 /* 4 len + 64 hdr + (2*24 wct) + 2 bct + 2 pad */
87
Fabian Frederickbc09d142014-12-10 15:41:15 -080088#define SMB2_PROTO_NUMBER cpu_to_le32(0x424d53fe)
Pavel Shilovsky093b2bd2011-06-08 15:51:07 +040089
Pavel Shilovsky2dc7e1c2011-12-26 22:53:34 +040090/*
Steve Frenchddfbefb2011-03-15 02:08:48 +000091 * SMB2 Header Definition
92 *
93 * "MBZ" : Must be Zero
94 * "BB" : BugBug, Something to check/review/analyze later
95 * "PDU" : "Protocol Data Unit" (ie a network "frame")
96 *
97 */
Pavel Shilovsky74112862012-07-27 01:20:41 +040098
Fabian Frederickbc09d142014-12-10 15:41:15 -080099#define SMB2_HEADER_STRUCTURE_SIZE cpu_to_le16(64)
Pavel Shilovsky74112862012-07-27 01:20:41 +0400100
Steve Frenchddfbefb2011-03-15 02:08:48 +0000101struct smb2_hdr {
102 __be32 smb2_buf_length; /* big endian on wire */
103 /* length is only two or three bytes - with
104 one or two byte type preceding it that MBZ */
105 __u8 ProtocolId[4]; /* 0xFE 'S' 'M' 'B' */
106 __le16 StructureSize; /* 64 */
107 __le16 CreditCharge; /* MBZ */
108 __le32 Status; /* Error from server */
109 __le16 Command;
110 __le16 CreditRequest; /* CreditResponse */
111 __le32 Flags;
112 __le32 NextCommand;
Sachin 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 Shilovsky093b2bd2011-06-08 15:51:07 +0400120struct smb2_pdu {
121 struct smb2_hdr hdr;
122 __le16 StructureSize2; /* size of wct area (varies, request specific) */
123} __packed;
124
Steve French0cbaa532013-11-15 23:50:24 -0600125struct smb2_transform_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 __u8 ProtocolId[4]; /* 0xFD 'S' 'M' 'B' */
130 __u8 Signature[16];
131 __u8 Nonce[11];
132 __u8 Reserved[5];
133 __le32 OriginalMessageSize;
134 __u16 Reserved1;
135 __le16 EncryptionAlgorithm;
136 __u64 SessionId;
137} __packed;
138
139/* Encryption Algorithms */
Fabian Frederickbc09d142014-12-10 15:41:15 -0800140#define SMB2_ENCRYPTION_AES128_CCM cpu_to_le16(0x0001)
Steve French0cbaa532013-11-15 23:50:24 -0600141
Pavel Shilovsky093b2bd2011-06-08 15:51:07 +0400142/*
143 * SMB2 flag definitions
144 */
Fabian Frederickbc09d142014-12-10 15:41:15 -0800145#define SMB2_FLAGS_SERVER_TO_REDIR cpu_to_le32(0x00000001)
146#define SMB2_FLAGS_ASYNC_COMMAND cpu_to_le32(0x00000002)
147#define SMB2_FLAGS_RELATED_OPERATIONS cpu_to_le32(0x00000004)
148#define SMB2_FLAGS_SIGNED cpu_to_le32(0x00000008)
149#define SMB2_FLAGS_DFS_OPERATIONS cpu_to_le32(0x10000000)
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
Fabian Frederickbc09d142014-12-10 15:41:15 -0800160#define SMB2_ERROR_STRUCTURE_SIZE2 cpu_to_le16(9)
Pavel Shilovsky74112862012-07-27 01:20:41 +0400161
Pavel Shilovsky093b2bd2011-06-08 15:51:07 +0400162struct smb2_err_rsp {
163 struct smb2_hdr hdr;
164 __le16 StructureSize;
165 __le16 Reserved; /* MBZ */
166 __le32 ByteCount; /* even if zero, at least one byte follows */
167 __u8 ErrorData[1]; /* variable length */
168} __packed;
169
Pavel Shilovskyb42bf882013-08-14 19:25:21 +0400170struct smb2_symlink_err_rsp {
171 __le32 SymLinkLength;
172 __le32 SymLinkErrorTag;
173 __le32 ReparseTag;
174 __le16 ReparseDataLength;
175 __le16 UnparsedPathLength;
176 __le16 SubstituteNameOffset;
177 __le16 SubstituteNameLength;
178 __le16 PrintNameOffset;
179 __le16 PrintNameLength;
180 __le32 Flags;
181 __u8 PathBuffer[0];
182} __packed;
183
Pavel Shilovskyb8c32db2012-09-19 06:22:44 -0700184#define SMB2_CLIENT_GUID_SIZE 16
185
Pavel Shilovskyec2e4522011-12-27 16:12:43 +0400186struct smb2_negotiate_req {
187 struct smb2_hdr hdr;
188 __le16 StructureSize; /* Must be 36 */
189 __le16 DialectCount;
190 __le16 SecurityMode;
191 __le16 Reserved; /* MBZ */
192 __le32 Capabilities;
Pavel Shilovskyb8c32db2012-09-19 06:22:44 -0700193 __u8 ClientGUID[SMB2_CLIENT_GUID_SIZE];
Steve French5f7fbf72014-12-17 22:52:58 -0600194 /* In SMB3.02 and earlier next three were MBZ le64 ClientStartTime */
195 __le32 NegotiateContextOffset; /* SMB3.1.1 only. MBZ earlier */
196 __le16 NegotiateContextCount; /* SMB3.1.1 only. MBZ earlier */
197 __le16 Reserved2;
Steve Frenche4aa25e2012-10-01 12:26:22 -0500198 __le16 Dialects[1]; /* One dialect (vers=) at a time for now */
Pavel Shilovskyec2e4522011-12-27 16:12:43 +0400199} __packed;
200
Steve Frenche4aa25e2012-10-01 12:26:22 -0500201/* Dialects */
202#define SMB20_PROT_ID 0x0202
203#define SMB21_PROT_ID 0x0210
204#define SMB30_PROT_ID 0x0300
Steve French20b6d8b2013-06-12 22:48:41 -0500205#define SMB302_PROT_ID 0x0302
Steve French5f7fbf72014-12-17 22:52:58 -0600206#define SMB311_PROT_ID 0x0311
Steve Frenche4aa25e2012-10-01 12:26:22 -0500207#define BAD_PROT_ID 0xFFFF
208
Pavel Shilovskyec2e4522011-12-27 16:12:43 +0400209/* SecurityMode flags */
210#define SMB2_NEGOTIATE_SIGNING_ENABLED 0x0001
211#define SMB2_NEGOTIATE_SIGNING_REQUIRED 0x0002
212/* Capabilities flags */
213#define SMB2_GLOBAL_CAP_DFS 0x00000001
214#define SMB2_GLOBAL_CAP_LEASING 0x00000002 /* Resp only New to SMB2.1 */
215#define SMB2_GLOBAL_CAP_LARGE_MTU 0X00000004 /* Resp only New to SMB2.1 */
Steve Frenche4aa25e2012-10-01 12:26:22 -0500216#define SMB2_GLOBAL_CAP_MULTI_CHANNEL 0x00000008 /* New to SMB3 */
217#define SMB2_GLOBAL_CAP_PERSISTENT_HANDLES 0x00000010 /* New to SMB3 */
218#define SMB2_GLOBAL_CAP_DIRECTORY_LEASING 0x00000020 /* New to SMB3 */
219#define SMB2_GLOBAL_CAP_ENCRYPTION 0x00000040 /* New to SMB3 */
Pavel Shilovsky29e20f92012-07-13 13:58:14 +0400220/* Internal types */
221#define SMB2_NT_FIND 0x00100000
222#define SMB2_LARGE_FILES 0x00200000
Pavel Shilovskyec2e4522011-12-27 16:12:43 +0400223
224struct smb2_negotiate_rsp {
225 struct smb2_hdr hdr;
226 __le16 StructureSize; /* Must be 65 */
227 __le16 SecurityMode;
228 __le16 DialectRevision;
Steve French5f7fbf72014-12-17 22:52:58 -0600229 __le16 NegotiateContextCount; /* Prior to SMB3.1.1 was Reserved & MBZ */
Pavel Shilovskyec2e4522011-12-27 16:12:43 +0400230 __u8 ServerGUID[16];
231 __le32 Capabilities;
232 __le32 MaxTransactSize;
233 __le32 MaxReadSize;
234 __le32 MaxWriteSize;
235 __le64 SystemTime; /* MBZ */
236 __le64 ServerStartTime;
237 __le16 SecurityBufferOffset;
238 __le16 SecurityBufferLength;
Steve French5f7fbf72014-12-17 22:52:58 -0600239 __le32 NegotiateContextOffset; /* Pre:SMB3.1.1 was reserved/ignored */
Pavel Shilovskyec2e4522011-12-27 16:12:43 +0400240 __u8 Buffer[1]; /* variable length GSS security buffer */
241} __packed;
242
Pavel Shilovsky5478f9b2011-12-27 16:22:00 +0400243struct smb2_sess_setup_req {
244 struct smb2_hdr hdr;
245 __le16 StructureSize; /* Must be 25 */
246 __u8 VcNumber;
247 __u8 SecurityMode;
248 __le32 Capabilities;
249 __le32 Channel;
250 __le16 SecurityBufferOffset;
251 __le16 SecurityBufferLength;
252 __le64 PreviousSessionId;
253 __u8 Buffer[1]; /* variable length GSS security buffer */
254} __packed;
255
256/* Currently defined SessionFlags */
257#define SMB2_SESSION_FLAG_IS_GUEST 0x0001
258#define SMB2_SESSION_FLAG_IS_NULL 0x0002
Steve French0cbaa532013-11-15 23:50:24 -0600259#define SMB2_SESSION_FLAG_ENCRYPT_DATA 0x0004
Pavel Shilovsky5478f9b2011-12-27 16:22:00 +0400260struct smb2_sess_setup_rsp {
261 struct smb2_hdr hdr;
262 __le16 StructureSize; /* Must be 9 */
263 __le16 SessionFlags;
264 __le16 SecurityBufferOffset;
265 __le16 SecurityBufferLength;
266 __u8 Buffer[1]; /* variable length GSS security buffer */
267} __packed;
268
269struct smb2_logoff_req {
270 struct smb2_hdr hdr;
271 __le16 StructureSize; /* Must be 4 */
272 __le16 Reserved;
273} __packed;
274
275struct smb2_logoff_rsp {
276 struct smb2_hdr hdr;
277 __le16 StructureSize; /* Must be 4 */
278 __le16 Reserved;
279} __packed;
280
Pavel Shilovskyfaaf9462011-12-27 16:04:00 +0400281struct smb2_tree_connect_req {
282 struct smb2_hdr hdr;
283 __le16 StructureSize; /* Must be 9 */
284 __le16 Reserved;
285 __le16 PathOffset;
286 __le16 PathLength;
287 __u8 Buffer[1]; /* variable length */
288} __packed;
289
290struct smb2_tree_connect_rsp {
291 struct smb2_hdr hdr;
292 __le16 StructureSize; /* Must be 16 */
293 __u8 ShareType; /* see below */
294 __u8 Reserved;
295 __le32 ShareFlags; /* see below */
296 __le32 Capabilities; /* see below */
297 __le32 MaximalAccess;
298} __packed;
299
300/* Possible ShareType values */
301#define SMB2_SHARE_TYPE_DISK 0x01
302#define SMB2_SHARE_TYPE_PIPE 0x02
303#define SMB2_SHARE_TYPE_PRINT 0x03
304
305/*
306 * Possible ShareFlags - exactly one and only one of the first 4 caching flags
307 * must be set (any of the remaining, SHI1005, flags may be set individually
308 * or in combination.
309 */
310#define SMB2_SHAREFLAG_MANUAL_CACHING 0x00000000
311#define SMB2_SHAREFLAG_AUTO_CACHING 0x00000010
312#define SMB2_SHAREFLAG_VDO_CACHING 0x00000020
313#define SMB2_SHAREFLAG_NO_CACHING 0x00000030
314#define SHI1005_FLAGS_DFS 0x00000001
315#define SHI1005_FLAGS_DFS_ROOT 0x00000002
316#define SHI1005_FLAGS_RESTRICT_EXCLUSIVE_OPENS 0x00000100
317#define SHI1005_FLAGS_FORCE_SHARED_DELETE 0x00000200
318#define SHI1005_FLAGS_ALLOW_NAMESPACE_CACHING 0x00000400
319#define SHI1005_FLAGS_ACCESS_BASED_DIRECTORY_ENUM 0x00000800
320#define SHI1005_FLAGS_FORCE_LEVELII_OPLOCK 0x00001000
Steve Frenchc8664732013-06-21 15:35:45 -0500321#define SHI1005_FLAGS_ENABLE_HASH_V1 0x00002000
322#define SHI1005_FLAGS_ENABLE_HASH_V2 0x00004000
323#define SHI1005_FLAGS_ENCRYPT_DATA 0x00008000
324#define SHI1005_FLAGS_ALL 0x0000FF33
Pavel Shilovskyfaaf9462011-12-27 16:04:00 +0400325
326/* Possible share capabilities */
Steve French2b5dc282013-06-13 10:51:10 -0500327#define SMB2_SHARE_CAP_DFS cpu_to_le32(0x00000008) /* all dialects */
328#define SMB2_SHARE_CAP_CONTINUOUS_AVAILABILITY cpu_to_le32(0x00000010) /* 3.0 */
329#define SMB2_SHARE_CAP_SCALEOUT cpu_to_le32(0x00000020) /* 3.0 */
330#define SMB2_SHARE_CAP_CLUSTER cpu_to_le32(0x00000040) /* 3.0 */
331#define SMB2_SHARE_CAP_ASYMMETRIC cpu_to_le32(0x00000080) /* 3.02 */
Pavel Shilovskyfaaf9462011-12-27 16:04:00 +0400332
333struct smb2_tree_disconnect_req {
334 struct smb2_hdr hdr;
335 __le16 StructureSize; /* Must be 4 */
336 __le16 Reserved;
337} __packed;
338
339struct smb2_tree_disconnect_rsp {
340 struct smb2_hdr hdr;
341 __le16 StructureSize; /* Must be 4 */
342 __le16 Reserved;
343} __packed;
344
Pavel Shilovsky2503a0d2011-12-26 22:58:46 +0400345/* File Attrubutes */
346#define FILE_ATTRIBUTE_READONLY 0x00000001
347#define FILE_ATTRIBUTE_HIDDEN 0x00000002
348#define FILE_ATTRIBUTE_SYSTEM 0x00000004
349#define FILE_ATTRIBUTE_DIRECTORY 0x00000010
350#define FILE_ATTRIBUTE_ARCHIVE 0x00000020
351#define FILE_ATTRIBUTE_NORMAL 0x00000080
352#define FILE_ATTRIBUTE_TEMPORARY 0x00000100
353#define FILE_ATTRIBUTE_SPARSE_FILE 0x00000200
354#define FILE_ATTRIBUTE_REPARSE_POINT 0x00000400
355#define FILE_ATTRIBUTE_COMPRESSED 0x00000800
356#define FILE_ATTRIBUTE_OFFLINE 0x00001000
357#define FILE_ATTRIBUTE_NOT_CONTENT_INDEXED 0x00002000
358#define FILE_ATTRIBUTE_ENCRYPTED 0x00004000
Steve French73322972014-09-23 19:25:42 -0500359#define FILE_ATTRIBUTE_INTEGRITY_STREAM 0x00008000
360#define FILE_ATTRIBUTE_NO_SCRUB_DATA 0x00020000
Pavel Shilovsky2503a0d2011-12-26 22:58:46 +0400361
362/* Oplock levels */
363#define SMB2_OPLOCK_LEVEL_NONE 0x00
364#define SMB2_OPLOCK_LEVEL_II 0x01
365#define SMB2_OPLOCK_LEVEL_EXCLUSIVE 0x08
366#define SMB2_OPLOCK_LEVEL_BATCH 0x09
367#define SMB2_OPLOCK_LEVEL_LEASE 0xFF
Pavel Shilovskyb8c32db2012-09-19 06:22:44 -0700368/* Non-spec internal type */
369#define SMB2_OPLOCK_LEVEL_NOCHANGE 0x99
Pavel Shilovsky2503a0d2011-12-26 22:58:46 +0400370
371/* Desired Access Flags */
372#define FILE_READ_DATA_LE cpu_to_le32(0x00000001)
373#define FILE_WRITE_DATA_LE cpu_to_le32(0x00000002)
374#define FILE_APPEND_DATA_LE cpu_to_le32(0x00000004)
375#define FILE_READ_EA_LE cpu_to_le32(0x00000008)
376#define FILE_WRITE_EA_LE cpu_to_le32(0x00000010)
377#define FILE_EXECUTE_LE cpu_to_le32(0x00000020)
378#define FILE_READ_ATTRIBUTES_LE cpu_to_le32(0x00000080)
379#define FILE_WRITE_ATTRIBUTES_LE cpu_to_le32(0x00000100)
380#define FILE_DELETE_LE cpu_to_le32(0x00010000)
381#define FILE_READ_CONTROL_LE cpu_to_le32(0x00020000)
382#define FILE_WRITE_DAC_LE cpu_to_le32(0x00040000)
383#define FILE_WRITE_OWNER_LE cpu_to_le32(0x00080000)
384#define FILE_SYNCHRONIZE_LE cpu_to_le32(0x00100000)
385#define FILE_ACCESS_SYSTEM_SECURITY_LE cpu_to_le32(0x01000000)
386#define FILE_MAXIMAL_ACCESS_LE cpu_to_le32(0x02000000)
387#define FILE_GENERIC_ALL_LE cpu_to_le32(0x10000000)
388#define FILE_GENERIC_EXECUTE_LE cpu_to_le32(0x20000000)
389#define FILE_GENERIC_WRITE_LE cpu_to_le32(0x40000000)
390#define FILE_GENERIC_READ_LE cpu_to_le32(0x80000000)
391
392/* ShareAccess Flags */
393#define FILE_SHARE_READ_LE cpu_to_le32(0x00000001)
394#define FILE_SHARE_WRITE_LE cpu_to_le32(0x00000002)
395#define FILE_SHARE_DELETE_LE cpu_to_le32(0x00000004)
396#define FILE_SHARE_ALL_LE cpu_to_le32(0x00000007)
397
398/* CreateDisposition Flags */
399#define FILE_SUPERSEDE_LE cpu_to_le32(0x00000000)
400#define FILE_OPEN_LE cpu_to_le32(0x00000001)
401#define FILE_CREATE_LE cpu_to_le32(0x00000002)
402#define FILE_OPEN_IF_LE cpu_to_le32(0x00000003)
403#define FILE_OVERWRITE_LE cpu_to_le32(0x00000004)
404#define FILE_OVERWRITE_IF_LE cpu_to_le32(0x00000005)
405
406/* CreateOptions Flags */
407#define FILE_DIRECTORY_FILE_LE cpu_to_le32(0x00000001)
408/* same as #define CREATE_NOT_FILE_LE cpu_to_le32(0x00000001) */
409#define FILE_WRITE_THROUGH_LE cpu_to_le32(0x00000002)
410#define FILE_SEQUENTIAL_ONLY_LE cpu_to_le32(0x00000004)
411#define FILE_NO_INTERMEDIATE_BUFFERRING_LE cpu_to_le32(0x00000008)
412#define FILE_SYNCHRONOUS_IO_ALERT_LE cpu_to_le32(0x00000010)
413#define FILE_SYNCHRONOUS_IO_NON_ALERT_LE cpu_to_le32(0x00000020)
414#define FILE_NON_DIRECTORY_FILE_LE cpu_to_le32(0x00000040)
415#define FILE_COMPLETE_IF_OPLOCKED_LE cpu_to_le32(0x00000100)
416#define FILE_NO_EA_KNOWLEDGE_LE cpu_to_le32(0x00000200)
417#define FILE_RANDOM_ACCESS_LE cpu_to_le32(0x00000800)
418#define FILE_DELETE_ON_CLOSE_LE cpu_to_le32(0x00001000)
419#define FILE_OPEN_BY_FILE_ID_LE cpu_to_le32(0x00002000)
420#define FILE_OPEN_FOR_BACKUP_INTENT_LE cpu_to_le32(0x00004000)
421#define FILE_NO_COMPRESSION_LE cpu_to_le32(0x00008000)
422#define FILE_RESERVE_OPFILTER_LE cpu_to_le32(0x00100000)
423#define FILE_OPEN_REPARSE_POINT_LE cpu_to_le32(0x00200000)
424#define FILE_OPEN_NO_RECALL_LE cpu_to_le32(0x00400000)
425#define FILE_OPEN_FOR_FREE_SPACE_QUERY_LE cpu_to_le32(0x00800000)
426
427#define FILE_READ_RIGHTS_LE (FILE_READ_DATA_LE | FILE_READ_EA_LE \
428 | FILE_READ_ATTRIBUTES_LE)
429#define FILE_WRITE_RIGHTS_LE (FILE_WRITE_DATA_LE | FILE_APPEND_DATA_LE \
430 | FILE_WRITE_EA_LE | FILE_WRITE_ATTRIBUTES_LE)
431#define FILE_EXEC_RIGHTS_LE (FILE_EXECUTE_LE)
432
433/* Impersonation Levels */
434#define IL_ANONYMOUS cpu_to_le32(0x00000000)
435#define IL_IDENTIFICATION cpu_to_le32(0x00000001)
436#define IL_IMPERSONATION cpu_to_le32(0x00000002)
437#define IL_DELEGATE cpu_to_le32(0x00000003)
438
439/* Create Context Values */
440#define SMB2_CREATE_EA_BUFFER "ExtA" /* extended attributes */
441#define SMB2_CREATE_SD_BUFFER "SecD" /* security descriptor */
442#define SMB2_CREATE_DURABLE_HANDLE_REQUEST "DHnQ"
443#define SMB2_CREATE_DURABLE_HANDLE_RECONNECT "DHnC"
Steve French12197a72014-05-14 05:29:40 -0700444#define SMB2_CREATE_ALLOCATION_SIZE "AISi"
Pavel Shilovsky2503a0d2011-12-26 22:58:46 +0400445#define SMB2_CREATE_QUERY_MAXIMAL_ACCESS_REQUEST "MxAc"
446#define SMB2_CREATE_TIMEWARP_REQUEST "TWrp"
447#define SMB2_CREATE_QUERY_ON_DISK_ID "QFid"
448#define SMB2_CREATE_REQUEST_LEASE "RqLs"
Steve French12197a72014-05-14 05:29:40 -0700449#define SMB2_CREATE_DURABLE_HANDLE_REQUEST_V2 "DH2Q"
450#define SMB2_CREATE_DURABLE_HANDLE_RECONNECT_V2 "DH2C"
451#define SMB2_CREATE_APP_INSTANCE_ID 0x45BCA66AEFA7F74A9008FA462E144D74
452#define SVHDX_OPEN_DEVICE_CONTEXT 0x83CE6F1AD851E0986E34401CC9BCFCE9
Pavel Shilovsky2503a0d2011-12-26 22:58:46 +0400453
454struct smb2_create_req {
455 struct smb2_hdr hdr;
456 __le16 StructureSize; /* Must be 57 */
457 __u8 SecurityFlags;
458 __u8 RequestedOplockLevel;
459 __le32 ImpersonationLevel;
460 __le64 SmbCreateFlags;
461 __le64 Reserved;
462 __le32 DesiredAccess;
463 __le32 FileAttributes;
464 __le32 ShareAccess;
465 __le32 CreateDisposition;
466 __le32 CreateOptions;
467 __le16 NameOffset;
468 __le16 NameLength;
469 __le32 CreateContextsOffset;
470 __le32 CreateContextsLength;
Pavel Shilovsky59aa3712013-07-04 19:41:24 +0400471 __u8 Buffer[0];
Pavel Shilovsky2503a0d2011-12-26 22:58:46 +0400472} __packed;
473
474struct smb2_create_rsp {
475 struct smb2_hdr hdr;
476 __le16 StructureSize; /* Must be 89 */
477 __u8 OplockLevel;
478 __u8 Reserved;
479 __le32 CreateAction;
480 __le64 CreationTime;
481 __le64 LastAccessTime;
482 __le64 LastWriteTime;
483 __le64 ChangeTime;
484 __le64 AllocationSize;
485 __le64 EndofFile;
486 __le32 FileAttributes;
487 __le32 Reserved2;
488 __u64 PersistentFileId; /* opaque endianness */
489 __u64 VolatileFileId; /* opaque endianness */
490 __le32 CreateContextsOffset;
491 __le32 CreateContextsLength;
492 __u8 Buffer[1];
493} __packed;
494
Pavel Shilovskyb8c32db2012-09-19 06:22:44 -0700495struct create_context {
496 __le32 Next;
497 __le16 NameOffset;
498 __le16 NameLength;
499 __le16 Reserved;
500 __le16 DataOffset;
501 __le32 DataLength;
502 __u8 Buffer[0];
503} __packed;
504
Pavel Shilovsky53ef1012013-09-05 16:11:28 +0400505#define SMB2_LEASE_READ_CACHING_HE 0x01
506#define SMB2_LEASE_HANDLE_CACHING_HE 0x02
507#define SMB2_LEASE_WRITE_CACHING_HE 0x04
508
Fabian Frederickbc09d142014-12-10 15:41:15 -0800509#define SMB2_LEASE_NONE cpu_to_le32(0x00)
510#define SMB2_LEASE_READ_CACHING cpu_to_le32(0x01)
511#define SMB2_LEASE_HANDLE_CACHING cpu_to_le32(0x02)
512#define SMB2_LEASE_WRITE_CACHING cpu_to_le32(0x04)
Pavel Shilovskyb8c32db2012-09-19 06:22:44 -0700513
Fabian Frederickbc09d142014-12-10 15:41:15 -0800514#define SMB2_LEASE_FLAG_BREAK_IN_PROGRESS cpu_to_le32(0x02)
Pavel Shilovskyb8c32db2012-09-19 06:22:44 -0700515
516#define SMB2_LEASE_KEY_SIZE 16
517
518struct lease_context {
519 __le64 LeaseKeyLow;
520 __le64 LeaseKeyHigh;
521 __le32 LeaseState;
522 __le32 LeaseFlags;
523 __le64 LeaseDuration;
524} __packed;
525
Pavel Shilovskyf0473902013-09-04 13:44:05 +0400526struct lease_context_v2 {
527 __le64 LeaseKeyLow;
528 __le64 LeaseKeyHigh;
529 __le32 LeaseState;
530 __le32 LeaseFlags;
531 __le64 LeaseDuration;
532 __le64 ParentLeaseKeyLow;
533 __le64 ParentLeaseKeyHigh;
534 __le16 Epoch;
535 __le16 Reserved;
536} __packed;
537
Pavel Shilovskyb8c32db2012-09-19 06:22:44 -0700538struct create_lease {
539 struct create_context ccontext;
540 __u8 Name[8];
541 struct lease_context lcontext;
542} __packed;
543
Pavel Shilovskyf0473902013-09-04 13:44:05 +0400544struct create_lease_v2 {
545 struct create_context ccontext;
546 __u8 Name[8];
547 struct lease_context_v2 lcontext;
548 __u8 Pad[4];
549} __packed;
550
Pavel Shilovsky63eb3de2013-07-04 18:41:09 +0400551struct create_durable {
552 struct create_context ccontext;
553 __u8 Name[8];
Pavel Shilovsky9cbc0b72013-07-09 18:40:58 +0400554 union {
555 __u8 Reserved[16];
556 struct {
557 __u64 PersistentFileId;
558 __u64 VolatileFileId;
559 } Fid;
560 } Data;
Pavel Shilovsky63eb3de2013-07-04 18:41:09 +0400561} __packed;
562
Steve French41c13582013-11-14 00:05:36 -0600563#define COPY_CHUNK_RES_KEY_SIZE 24
564struct resume_key_req {
565 char ResumeKey[COPY_CHUNK_RES_KEY_SIZE];
566 __le32 ContextLength; /* MBZ */
567 char Context[0]; /* ignored, Windows sets to 4 bytes of zero */
568} __packed;
569
Steve Frenchbe7457d2013-06-19 17:41:10 -0500570/* this goes in the ioctl buffer when doing a copychunk request */
571struct copychunk_ioctl {
Steve French41c13582013-11-14 00:05:36 -0600572 char SourceKey[COPY_CHUNK_RES_KEY_SIZE];
Steve Frenchbe7457d2013-06-19 17:41:10 -0500573 __le32 ChunkCount; /* we are only sending 1 */
574 __le32 Reserved;
575 /* array will only be one chunk long for us */
576 __le64 SourceOffset;
577 __le64 TargetOffset;
Steve Frenchc8664732013-06-21 15:35:45 -0500578 __le32 Length; /* how many bytes to copy */
Steve Frenchbe7457d2013-06-19 17:41:10 -0500579 __u32 Reserved2;
580} __packed;
581
Steve French31742c52014-08-17 08:38:47 -0500582/* this goes in the ioctl buffer when doing FSCTL_SET_ZERO_DATA */
583struct file_zero_data_information {
584 __le64 FileOffset;
585 __le64 BeyondFinalZero;
586} __packed;
587
Steve French41c13582013-11-14 00:05:36 -0600588struct copychunk_ioctl_rsp {
589 __le32 ChunksWritten;
590 __le32 ChunkBytesWritten;
591 __le32 TotalBytesWritten;
592} __packed;
593
Steve Frenchff1c0382013-11-19 23:44:46 -0600594struct validate_negotiate_info_req {
Steve French4a72daf2013-06-25 00:20:49 -0500595 __le32 Capabilities;
596 __u8 Guid[SMB2_CLIENT_GUID_SIZE];
597 __le16 SecurityMode;
598 __le16 DialectCount;
Steve Frenchff1c0382013-11-19 23:44:46 -0600599 __le16 Dialects[1]; /* dialect (someday maybe list) client asked for */
600} __packed;
601
602struct validate_negotiate_info_rsp {
603 __le32 Capabilities;
604 __u8 Guid[SMB2_CLIENT_GUID_SIZE];
605 __le16 SecurityMode;
606 __le16 Dialect; /* Dialect in use for the connection */
Steve French4a72daf2013-06-25 00:20:49 -0500607} __packed;
608
609#define RSS_CAPABLE 0x00000001
610#define RDMA_CAPABLE 0x00000002
611
612struct network_interface_info_ioctl_rsp {
613 __le32 Next; /* next interface. zero if this is last one */
614 __le32 IfIndex;
615 __le32 Capability; /* RSS or RDMA Capable */
616 __le32 Reserved;
617 __le64 LinkSpeed;
618 char SockAddr_Storage[128];
619} __packed;
620
621#define NO_FILE_ID 0xFFFFFFFFFFFFFFFFULL /* general ioctls to srv not to file */
622
Steve French64a5cfa2013-10-14 15:31:32 -0500623struct compress_ioctl {
Steve Frenchc7f508a2013-10-14 15:27:32 -0500624 __le16 CompressionState; /* See cifspdu.h for possible flag values */
Steve French64a5cfa2013-10-14 15:31:32 -0500625} __packed;
626
Steve Frenchbe7457d2013-06-19 17:41:10 -0500627struct smb2_ioctl_req {
628 struct smb2_hdr hdr;
629 __le16 StructureSize; /* Must be 57 */
630 __u16 Reserved;
631 __le32 CtlCode;
632 __u64 PersistentFileId; /* opaque endianness */
633 __u64 VolatileFileId; /* opaque endianness */
634 __le32 InputOffset;
635 __le32 InputCount;
636 __le32 MaxInputResponse;
637 __le32 OutputOffset;
638 __le32 OutputCount;
639 __le32 MaxOutputResponse;
640 __le32 Flags;
641 __u32 Reserved2;
Steve French64a5cfa2013-10-14 15:31:32 -0500642 __u8 Buffer[0];
Steve Frenchbe7457d2013-06-19 17:41:10 -0500643} __packed;
644
645struct smb2_ioctl_rsp {
646 struct smb2_hdr hdr;
647 __le16 StructureSize; /* Must be 57 */
648 __u16 Reserved;
649 __le32 CtlCode;
650 __u64 PersistentFileId; /* opaque endianness */
651 __u64 VolatileFileId; /* opaque endianness */
652 __le32 InputOffset;
653 __le32 InputCount;
654 __le32 OutputOffset;
655 __le32 OutputCount;
656 __le32 Flags;
657 __u32 Reserved2;
658 /* char * buffer[] */
659} __packed;
660
Pavel Shilovsky2503a0d2011-12-26 22:58:46 +0400661/* Currently defined values for close flags */
662#define SMB2_CLOSE_FLAG_POSTQUERY_ATTRIB cpu_to_le16(0x0001)
663struct smb2_close_req {
664 struct smb2_hdr hdr;
665 __le16 StructureSize; /* Must be 24 */
666 __le16 Flags;
667 __le32 Reserved;
668 __u64 PersistentFileId; /* opaque endianness */
669 __u64 VolatileFileId; /* opaque endianness */
670} __packed;
671
672struct smb2_close_rsp {
673 struct smb2_hdr hdr;
674 __le16 StructureSize; /* 60 */
675 __le16 Flags;
676 __le32 Reserved;
677 __le64 CreationTime;
678 __le64 LastAccessTime;
679 __le64 LastWriteTime;
680 __le64 ChangeTime;
681 __le64 AllocationSize; /* Beginning of FILE_STANDARD_INFO equivalent */
682 __le64 EndOfFile;
683 __le32 Attributes;
684} __packed;
685
Pavel Shilovsky7a5cfb12012-09-18 16:20:28 -0700686struct smb2_flush_req {
687 struct smb2_hdr hdr;
688 __le16 StructureSize; /* Must be 24 */
689 __le16 Reserved1;
690 __le32 Reserved2;
691 __u64 PersistentFileId; /* opaque endianness */
692 __u64 VolatileFileId; /* opaque endianness */
693} __packed;
694
695struct smb2_flush_rsp {
696 struct smb2_hdr hdr;
697 __le16 StructureSize;
698 __le16 Reserved;
699} __packed;
700
Steve French2b5dc282013-06-13 10:51:10 -0500701/* For read request Flags field below, following flag is defined for SMB3.02 */
702#define SMB2_READFLAG_READ_UNBUFFERED 0x01
703
704/* Channel field for read and write: exactly one of following flags can be set*/
705#define SMB2_CHANNEL_NONE 0x00000000
706#define SMB2_CHANNEL_RDMA_V1 0x00000001 /* SMB3 or later */
707#define SMB2_CHANNEL_RDMA_V1_INVALIDATE 0x00000001 /* SMB3.02 or later */
708
Pavel Shilovsky09a47072012-09-18 16:20:29 -0700709struct smb2_read_req {
710 struct smb2_hdr hdr;
711 __le16 StructureSize; /* Must be 49 */
712 __u8 Padding; /* offset from start of SMB2 header to place read */
Steve French2b5dc282013-06-13 10:51:10 -0500713 __u8 Flags; /* MBZ unless SMB3.02 or later */
Pavel Shilovsky09a47072012-09-18 16:20:29 -0700714 __le32 Length;
715 __le64 Offset;
716 __u64 PersistentFileId; /* opaque endianness */
717 __u64 VolatileFileId; /* opaque endianness */
718 __le32 MinimumCount;
Steve French2b5dc282013-06-13 10:51:10 -0500719 __le32 Channel; /* MBZ except for SMB3 or later */
Pavel Shilovsky09a47072012-09-18 16:20:29 -0700720 __le32 RemainingBytes;
721 __le16 ReadChannelInfoOffset; /* Reserved MBZ */
722 __le16 ReadChannelInfoLength; /* Reserved MBZ */
723 __u8 Buffer[1];
724} __packed;
725
726struct smb2_read_rsp {
727 struct smb2_hdr hdr;
728 __le16 StructureSize; /* Must be 17 */
729 __u8 DataOffset;
730 __u8 Reserved;
731 __le32 DataLength;
732 __le32 DataRemaining;
733 __u32 Reserved2;
734 __u8 Buffer[1];
735} __packed;
736
Steve French2b5dc282013-06-13 10:51:10 -0500737/* For write request Flags field below the following flags are defined: */
738#define SMB2_WRITEFLAG_WRITE_THROUGH 0x00000001 /* SMB2.1 or later */
739#define SMB2_WRITEFLAG_WRITE_UNBUFFERED 0x00000002 /* SMB3.02 or later */
Pavel Shilovsky33319142012-09-18 16:20:29 -0700740
741struct smb2_write_req {
742 struct smb2_hdr hdr;
743 __le16 StructureSize; /* Must be 49 */
744 __le16 DataOffset; /* offset from start of SMB2 header to write data */
745 __le32 Length;
746 __le64 Offset;
747 __u64 PersistentFileId; /* opaque endianness */
748 __u64 VolatileFileId; /* opaque endianness */
749 __le32 Channel; /* Reserved MBZ */
750 __le32 RemainingBytes;
751 __le16 WriteChannelInfoOffset; /* Reserved MBZ */
752 __le16 WriteChannelInfoLength; /* Reserved MBZ */
753 __le32 Flags;
754 __u8 Buffer[1];
755} __packed;
756
757struct smb2_write_rsp {
758 struct smb2_hdr hdr;
759 __le16 StructureSize; /* Must be 17 */
760 __u8 DataOffset;
761 __u8 Reserved;
762 __le32 DataLength;
763 __le32 DataRemaining;
764 __u32 Reserved2;
765 __u8 Buffer[1];
766} __packed;
767
Pavel Shilovsky027e8ee2012-09-19 06:22:43 -0700768#define SMB2_LOCKFLAG_SHARED_LOCK 0x0001
769#define SMB2_LOCKFLAG_EXCLUSIVE_LOCK 0x0002
770#define SMB2_LOCKFLAG_UNLOCK 0x0004
771#define SMB2_LOCKFLAG_FAIL_IMMEDIATELY 0x0010
772
Pavel Shilovskyf7ba7fe2012-09-19 06:22:43 -0700773struct smb2_lock_element {
774 __le64 Offset;
775 __le64 Length;
776 __le32 Flags;
777 __le32 Reserved;
778} __packed;
779
780struct smb2_lock_req {
781 struct smb2_hdr hdr;
782 __le16 StructureSize; /* Must be 48 */
783 __le16 LockCount;
784 __le32 Reserved;
785 __u64 PersistentFileId; /* opaque endianness */
786 __u64 VolatileFileId; /* opaque endianness */
787 /* Followed by at least one */
788 struct smb2_lock_element locks[1];
789} __packed;
790
791struct smb2_lock_rsp {
792 struct smb2_hdr hdr;
793 __le16 StructureSize; /* Must be 4 */
794 __le16 Reserved;
795} __packed;
796
Pavel Shilovsky9094fad2012-07-12 18:30:44 +0400797struct smb2_echo_req {
798 struct smb2_hdr hdr;
799 __le16 StructureSize; /* Must be 4 */
800 __u16 Reserved;
801} __packed;
802
803struct smb2_echo_rsp {
804 struct smb2_hdr hdr;
805 __le16 StructureSize; /* Must be 4 */
806 __u16 Reserved;
807} __packed;
808
Pavel Shilovskyd324f08d2012-09-18 16:20:33 -0700809/* search (query_directory) Flags field */
810#define SMB2_RESTART_SCANS 0x01
811#define SMB2_RETURN_SINGLE_ENTRY 0x02
812#define SMB2_INDEX_SPECIFIED 0x04
813#define SMB2_REOPEN 0x10
814
815struct smb2_query_directory_req {
816 struct smb2_hdr hdr;
817 __le16 StructureSize; /* Must be 33 */
818 __u8 FileInformationClass;
819 __u8 Flags;
820 __le32 FileIndex;
821 __u64 PersistentFileId; /* opaque endianness */
822 __u64 VolatileFileId; /* opaque endianness */
823 __le16 FileNameOffset;
824 __le16 FileNameLength;
825 __le32 OutputBufferLength;
826 __u8 Buffer[1];
827} __packed;
828
829struct smb2_query_directory_rsp {
830 struct smb2_hdr hdr;
831 __le16 StructureSize; /* Must be 9 */
832 __le16 OutputBufferOffset;
833 __le32 OutputBufferLength;
834 __u8 Buffer[1];
835} __packed;
836
Pavel Shilovskybe4cb9e2011-12-29 17:06:33 +0400837/* Possible InfoType values */
838#define SMB2_O_INFO_FILE 0x01
839#define SMB2_O_INFO_FILESYSTEM 0x02
840#define SMB2_O_INFO_SECURITY 0x03
841#define SMB2_O_INFO_QUOTA 0x04
842
Steve French911a8df2014-10-19 19:18:05 -0500843/* Security info type additionalinfo flags. See MS-SMB2 (2.2.37) or MS-DTYP */
844#define OWNER_SECINFO 0x00000001
845#define GROUP_SECINFO 0x00000002
846#define DACL_SECINFO 0x00000004
847#define SACL_SECINFO 0x00000008
848#define LABEL_SECINFO 0x00000010
849#define ATTRIBUTE_SECINFO 0x00000020
850#define SCOPE_SECINFO 0x00000040
851#define BACKUP_SECINFO 0x00010000
852#define UNPROTECTED_SACL_SECINFO 0x10000000
853#define UNPROTECTED_DACL_SECINFO 0x20000000
854#define PROTECTED_SACL_SECINFO 0x40000000
855#define PROTECTED_DACL_SECINFO 0x80000000
856
857/* Flags used for FileFullEAinfo */
858#define SL_RESTART_SCAN 0x00000001
859#define SL_RETURN_SINGLE_ENTRY 0x00000002
860#define SL_INDEX_SPECIFIED 0x00000004
861
Pavel Shilovskybe4cb9e2011-12-29 17:06:33 +0400862struct smb2_query_info_req {
863 struct smb2_hdr hdr;
864 __le16 StructureSize; /* Must be 41 */
865 __u8 InfoType;
866 __u8 FileInfoClass;
867 __le32 OutputBufferLength;
868 __le16 InputBufferOffset;
869 __u16 Reserved;
870 __le32 InputBufferLength;
871 __le32 AdditionalInformation;
872 __le32 Flags;
873 __u64 PersistentFileId; /* opaque endianness */
874 __u64 VolatileFileId; /* opaque endianness */
875 __u8 Buffer[1];
876} __packed;
877
878struct smb2_query_info_rsp {
879 struct smb2_hdr hdr;
880 __le16 StructureSize; /* Must be 9 */
881 __le16 OutputBufferOffset;
882 __le32 OutputBufferLength;
883 __u8 Buffer[1];
884} __packed;
885
Pavel Shilovsky35143eb2012-09-18 16:20:31 -0700886struct smb2_set_info_req {
887 struct smb2_hdr hdr;
888 __le16 StructureSize; /* Must be 33 */
889 __u8 InfoType;
890 __u8 FileInfoClass;
891 __le32 BufferLength;
892 __le16 BufferOffset;
893 __u16 Reserved;
894 __le32 AdditionalInformation;
895 __u64 PersistentFileId; /* opaque endianness */
896 __u64 VolatileFileId; /* opaque endianness */
897 __u8 Buffer[1];
898} __packed;
899
900struct smb2_set_info_rsp {
901 struct smb2_hdr hdr;
902 __le16 StructureSize; /* Must be 2 */
903} __packed;
904
Pavel Shilovsky983c88a2012-09-18 16:20:33 -0700905struct smb2_oplock_break {
906 struct smb2_hdr hdr;
907 __le16 StructureSize; /* Must be 24 */
908 __u8 OplockLevel;
909 __u8 Reserved;
910 __le32 Reserved2;
911 __u64 PersistentFid;
912 __u64 VolatileFid;
913} __packed;
914
Pavel Shilovsky0822f512012-09-19 06:22:45 -0700915#define SMB2_NOTIFY_BREAK_LEASE_FLAG_ACK_REQUIRED cpu_to_le32(0x01)
916
917struct smb2_lease_break {
918 struct smb2_hdr hdr;
919 __le16 StructureSize; /* Must be 44 */
920 __le16 Reserved;
921 __le32 Flags;
922 __u8 LeaseKey[16];
923 __le32 CurrentLeaseState;
924 __le32 NewLeaseState;
925 __le32 BreakReason;
926 __le32 AccessMaskHint;
927 __le32 ShareMaskHint;
928} __packed;
929
930struct smb2_lease_ack {
931 struct smb2_hdr hdr;
932 __le16 StructureSize; /* Must be 36 */
933 __le16 Reserved;
934 __le32 Flags;
935 __u8 LeaseKey[16];
936 __le32 LeaseState;
937 __le64 LeaseDuration;
938} __packed;
939
Pavel Shilovskybe4cb9e2011-12-29 17:06:33 +0400940/*
941 * PDU infolevel structure definitions
942 * BB consider moving to a different header
943 */
944
Pavel Shilovsky6fc05c22012-09-18 16:20:34 -0700945/* File System Information Classes */
946#define FS_VOLUME_INFORMATION 1 /* Query */
Steven Frenchaf6a12e2013-10-09 20:55:53 -0500947#define FS_LABEL_INFORMATION 2 /* Local only */
Pavel Shilovsky6fc05c22012-09-18 16:20:34 -0700948#define FS_SIZE_INFORMATION 3 /* Query */
949#define FS_DEVICE_INFORMATION 4 /* Query */
950#define FS_ATTRIBUTE_INFORMATION 5 /* Query */
951#define FS_CONTROL_INFORMATION 6 /* Query, Set */
952#define FS_FULL_SIZE_INFORMATION 7 /* Query */
953#define FS_OBJECT_ID_INFORMATION 8 /* Query, Set */
Steven Frenchaf6a12e2013-10-09 20:55:53 -0500954#define FS_DRIVER_PATH_INFORMATION 9 /* Local only */
955#define FS_VOLUME_FLAGS_INFORMATION 10 /* Local only */
956#define FS_SECTOR_SIZE_INFORMATION 11 /* SMB3 or later. Query */
Pavel Shilovsky6fc05c22012-09-18 16:20:34 -0700957
958struct smb2_fs_full_size_info {
959 __le64 TotalAllocationUnits;
960 __le64 CallerAvailableAllocationUnits;
961 __le64 ActualAvailableAllocationUnits;
962 __le32 SectorsPerAllocationUnit;
963 __le32 BytesPerSector;
964} __packed;
965
Steven Frenchaf6a12e2013-10-09 20:55:53 -0500966#define SSINFO_FLAGS_ALIGNED_DEVICE 0x00000001
967#define SSINFO_FLAGS_PARTITION_ALIGNED_ON_DEVICE 0x00000002
968#define SSINFO_FLAGS_NO_SEEK_PENALTY 0x00000004
969#define SSINFO_FLAGS_TRIM_ENABLED 0x00000008
970
971/* sector size info struct */
972struct smb3_fs_ss_info {
973 __le32 LogicalBytesPerSector;
974 __le32 PhysicalBytesPerSectorForAtomicity;
975 __le32 PhysicalBytesPerSectorForPerf;
976 __le32 FileSystemEffectivePhysicalBytesPerSectorForAtomicity;
977 __le32 Flags;
978 __le32 ByteOffsetForSectorAlignment;
979 __le32 ByteOffsetForPartitionAlignment;
980} __packed;
981
Pavel Shilovskybe4cb9e2011-12-29 17:06:33 +0400982/* partial list of QUERY INFO levels */
983#define FILE_DIRECTORY_INFORMATION 1
984#define FILE_FULL_DIRECTORY_INFORMATION 2
985#define FILE_BOTH_DIRECTORY_INFORMATION 3
986#define FILE_BASIC_INFORMATION 4
987#define FILE_STANDARD_INFORMATION 5
988#define FILE_INTERNAL_INFORMATION 6
989#define FILE_EA_INFORMATION 7
990#define FILE_ACCESS_INFORMATION 8
991#define FILE_NAME_INFORMATION 9
992#define FILE_RENAME_INFORMATION 10
993#define FILE_LINK_INFORMATION 11
994#define FILE_NAMES_INFORMATION 12
995#define FILE_DISPOSITION_INFORMATION 13
996#define FILE_POSITION_INFORMATION 14
997#define FILE_FULL_EA_INFORMATION 15
998#define FILE_MODE_INFORMATION 16
999#define FILE_ALIGNMENT_INFORMATION 17
1000#define FILE_ALL_INFORMATION 18
1001#define FILE_ALLOCATION_INFORMATION 19
1002#define FILE_END_OF_FILE_INFORMATION 20
1003#define FILE_ALTERNATE_NAME_INFORMATION 21
1004#define FILE_STREAM_INFORMATION 22
1005#define FILE_PIPE_INFORMATION 23
1006#define FILE_PIPE_LOCAL_INFORMATION 24
1007#define FILE_PIPE_REMOTE_INFORMATION 25
1008#define FILE_MAILSLOT_QUERY_INFORMATION 26
1009#define FILE_MAILSLOT_SET_INFORMATION 27
1010#define FILE_COMPRESSION_INFORMATION 28
1011#define FILE_OBJECT_ID_INFORMATION 29
1012/* Number 30 not defined in documents */
1013#define FILE_MOVE_CLUSTER_INFORMATION 31
1014#define FILE_QUOTA_INFORMATION 32
1015#define FILE_REPARSE_POINT_INFORMATION 33
1016#define FILE_NETWORK_OPEN_INFORMATION 34
1017#define FILE_ATTRIBUTE_TAG_INFORMATION 35
1018#define FILE_TRACKING_INFORMATION 36
1019#define FILEID_BOTH_DIRECTORY_INFORMATION 37
1020#define FILEID_FULL_DIRECTORY_INFORMATION 38
1021#define FILE_VALID_DATA_LENGTH_INFORMATION 39
1022#define FILE_SHORT_NAME_INFORMATION 40
1023#define FILE_SFIO_RESERVE_INFORMATION 44
1024#define FILE_SFIO_VOLUME_INFORMATION 45
1025#define FILE_HARD_LINK_INFORMATION 46
1026#define FILE_NORMALIZED_NAME_INFORMATION 48
1027#define FILEID_GLOBAL_TX_DIRECTORY_INFORMATION 50
1028#define FILE_STANDARD_LINK_INFORMATION 54
1029
Pavel Shilovskyf0df7372012-09-18 16:20:26 -07001030struct smb2_file_internal_info {
1031 __le64 IndexNumber;
1032} __packed; /* level 6 Query */
1033
Pavel Shilovsky35143eb2012-09-18 16:20:31 -07001034struct smb2_file_rename_info { /* encoding of request for level 10 */
1035 __u8 ReplaceIfExists; /* 1 = replace existing target with new */
1036 /* 0 = fail if target already exists */
1037 __u8 Reserved[7];
1038 __u64 RootDirectory; /* MBZ for network operations (why says spec?) */
1039 __le32 FileNameLength;
1040 char FileName[0]; /* New name to be assigned */
1041} __packed; /* level 10 Set */
1042
Pavel Shilovsky568798c2012-09-18 16:20:31 -07001043struct smb2_file_link_info { /* encoding of request for level 11 */
1044 __u8 ReplaceIfExists; /* 1 = replace existing link with new */
1045 /* 0 = fail if link already exists */
1046 __u8 Reserved[7];
1047 __u64 RootDirectory; /* MBZ for network operations (why says spec?) */
1048 __le32 FileNameLength;
1049 char FileName[0]; /* Name to be assigned to new link */
1050} __packed; /* level 11 Set */
1051
Pavel Shilovskybe4cb9e2011-12-29 17:06:33 +04001052/*
1053 * This level 18, although with struct with same name is different from cifs
1054 * level 0x107. Level 0x107 has an extra u64 between AccessFlags and
1055 * CurrentByteOffset.
1056 */
1057struct smb2_file_all_info { /* data block encoding of response to level 18 */
1058 __le64 CreationTime; /* Beginning of FILE_BASIC_INFO equivalent */
1059 __le64 LastAccessTime;
1060 __le64 LastWriteTime;
1061 __le64 ChangeTime;
1062 __le32 Attributes;
1063 __u32 Pad1; /* End of FILE_BASIC_INFO_INFO equivalent */
1064 __le64 AllocationSize; /* Beginning of FILE_STANDARD_INFO equivalent */
1065 __le64 EndOfFile; /* size ie offset to first free byte in file */
1066 __le32 NumberOfLinks; /* hard links */
1067 __u8 DeletePending;
1068 __u8 Directory;
1069 __u16 Pad2; /* End of FILE_STANDARD_INFO equivalent */
1070 __le64 IndexNumber;
1071 __le32 EASize;
1072 __le32 AccessFlags;
1073 __le64 CurrentByteOffset;
1074 __le32 Mode;
1075 __le32 AlignmentRequirement;
1076 __le32 FileNameLength;
1077 char FileName[1];
1078} __packed; /* level 18 Query */
1079
Pavel Shilovskyc839ff22012-09-18 16:20:32 -07001080struct smb2_file_eof_info { /* encoding of request for level 10 */
1081 __le64 EndOfFile; /* new end of file value */
1082} __packed; /* level 20 Set */
1083
Steve Frenchddfbefb2011-03-15 02:08:48 +00001084#endif /* _SMB2PDU_H */