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