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