1 /* SPDX-License-Identifier: LGPL-2.1 */
2 #ifndef _COMMON_SMB2PDU_H
3 #define _COMMON_SMB2PDU_H
4 
5 /*
6  * Note that, due to trying to use names similar to the protocol specifications,
7  * there are many mixed case field names in the structures below.  Although
8  * this does not match typical Linux kernel style, it is necessary to be
9  * able to match against the protocol specfication.
10  *
11  * SMB2 commands
12  * Some commands have minimal (wct=0,bcc=0), or uninteresting, responses
13  * (ie no useful data other than the SMB error code itself) and are marked such.
14  * Knowing this helps avoid response buffer allocations and copy in some cases.
15  */
16 
17 /* List of commands in host endian */
18 #define SMB2_NEGOTIATE_HE	0x0000
19 #define SMB2_SESSION_SETUP_HE	0x0001
20 #define SMB2_LOGOFF_HE		0x0002 /* trivial request/resp */
21 #define SMB2_TREE_CONNECT_HE	0x0003
22 #define SMB2_TREE_DISCONNECT_HE	0x0004 /* trivial req/resp */
23 #define SMB2_CREATE_HE		0x0005
24 #define SMB2_CLOSE_HE		0x0006
25 #define SMB2_FLUSH_HE		0x0007 /* trivial resp */
26 #define SMB2_READ_HE		0x0008
27 #define SMB2_WRITE_HE		0x0009
28 #define SMB2_LOCK_HE		0x000A
29 #define SMB2_IOCTL_HE		0x000B
30 #define SMB2_CANCEL_HE		0x000C
31 #define SMB2_ECHO_HE		0x000D
32 #define SMB2_QUERY_DIRECTORY_HE	0x000E
33 #define SMB2_CHANGE_NOTIFY_HE	0x000F
34 #define SMB2_QUERY_INFO_HE	0x0010
35 #define SMB2_SET_INFO_HE	0x0011
36 #define SMB2_OPLOCK_BREAK_HE	0x0012
37 
38 /* The same list in little endian */
39 #define SMB2_NEGOTIATE		cpu_to_le16(SMB2_NEGOTIATE_HE)
40 #define SMB2_SESSION_SETUP	cpu_to_le16(SMB2_SESSION_SETUP_HE)
41 #define SMB2_LOGOFF		cpu_to_le16(SMB2_LOGOFF_HE)
42 #define SMB2_TREE_CONNECT	cpu_to_le16(SMB2_TREE_CONNECT_HE)
43 #define SMB2_TREE_DISCONNECT	cpu_to_le16(SMB2_TREE_DISCONNECT_HE)
44 #define SMB2_CREATE		cpu_to_le16(SMB2_CREATE_HE)
45 #define SMB2_CLOSE		cpu_to_le16(SMB2_CLOSE_HE)
46 #define SMB2_FLUSH		cpu_to_le16(SMB2_FLUSH_HE)
47 #define SMB2_READ		cpu_to_le16(SMB2_READ_HE)
48 #define SMB2_WRITE		cpu_to_le16(SMB2_WRITE_HE)
49 #define SMB2_LOCK		cpu_to_le16(SMB2_LOCK_HE)
50 #define SMB2_IOCTL		cpu_to_le16(SMB2_IOCTL_HE)
51 #define SMB2_CANCEL		cpu_to_le16(SMB2_CANCEL_HE)
52 #define SMB2_ECHO		cpu_to_le16(SMB2_ECHO_HE)
53 #define SMB2_QUERY_DIRECTORY	cpu_to_le16(SMB2_QUERY_DIRECTORY_HE)
54 #define SMB2_CHANGE_NOTIFY	cpu_to_le16(SMB2_CHANGE_NOTIFY_HE)
55 #define SMB2_QUERY_INFO		cpu_to_le16(SMB2_QUERY_INFO_HE)
56 #define SMB2_SET_INFO		cpu_to_le16(SMB2_SET_INFO_HE)
57 #define SMB2_OPLOCK_BREAK	cpu_to_le16(SMB2_OPLOCK_BREAK_HE)
58 
59 #define SMB2_INTERNAL_CMD	cpu_to_le16(0xFFFF)
60 
61 #define NUMBER_OF_SMB2_COMMANDS	0x0013
62 
63 /*
64  * SMB2 Header Definition
65  *
66  * "MBZ" :  Must be Zero
67  * "BB"  :  BugBug, Something to check/review/analyze later
68  * "PDU" :  "Protocol Data Unit" (ie a network "frame")
69  *
70  */
71 
72 #define __SMB2_HEADER_STRUCTURE_SIZE	64
73 #define SMB2_HEADER_STRUCTURE_SIZE				\
74 	cpu_to_le16(__SMB2_HEADER_STRUCTURE_SIZE)
75 
76 #define SMB2_PROTO_NUMBER cpu_to_le32(0x424d53fe)
77 #define SMB2_TRANSFORM_PROTO_NUM cpu_to_le32(0x424d53fd)
78 #define SMB2_COMPRESSION_TRANSFORM_ID cpu_to_le32(0x424d53fc)
79 
80 /*
81  *	SMB2 flag definitions
82  */
83 #define SMB2_FLAGS_SERVER_TO_REDIR	cpu_to_le32(0x00000001)
84 #define SMB2_FLAGS_ASYNC_COMMAND	cpu_to_le32(0x00000002)
85 #define SMB2_FLAGS_RELATED_OPERATIONS	cpu_to_le32(0x00000004)
86 #define SMB2_FLAGS_SIGNED		cpu_to_le32(0x00000008)
87 #define SMB2_FLAGS_PRIORITY_MASK	cpu_to_le32(0x00000070) /* SMB3.1.1 */
88 #define SMB2_FLAGS_DFS_OPERATIONS	cpu_to_le32(0x10000000)
89 #define SMB2_FLAGS_REPLAY_OPERATION	cpu_to_le32(0x20000000) /* SMB3 & up */
90 
91 /* See MS-SMB2 section 2.2.1 */
92 struct smb2_hdr {
93 	__le32 ProtocolId;	/* 0xFE 'S' 'M' 'B' */
94 	__le16 StructureSize;	/* 64 */
95 	__le16 CreditCharge;	/* MBZ */
96 	__le32 Status;		/* Error from server */
97 	__le16 Command;
98 	__le16 CreditRequest;	/* CreditResponse */
99 	__le32 Flags;
100 	__le32 NextCommand;
101 	__le64 MessageId;
102 	union {
103 		struct {
104 			__le32 ProcessId;
105 			__le32  TreeId;
106 		} __packed SyncId;
107 		__le64  AsyncId;
108 	} __packed Id;
109 	__le64  SessionId;
110 	__u8   Signature[16];
111 } __packed;
112 
113 struct smb2_pdu {
114 	struct smb2_hdr hdr;
115 	__le16 StructureSize2; /* size of wct area (varies, request specific) */
116 } __packed;
117 
118 #define SMB3_AES_CCM_NONCE 11
119 #define SMB3_AES_GCM_NONCE 12
120 
121 /* Transform flags (for 3.0 dialect this flag indicates CCM */
122 #define TRANSFORM_FLAG_ENCRYPTED	0x0001
123 struct smb2_transform_hdr {
124 	__le32 ProtocolId;	/* 0xFD 'S' 'M' 'B' */
125 	__u8   Signature[16];
126 	__u8   Nonce[16];
127 	__le32 OriginalMessageSize;
128 	__u16  Reserved1;
129 	__le16 Flags; /* EncryptionAlgorithm for 3.0, enc enabled for 3.1.1 */
130 	__le64  SessionId;
131 } __packed;
132 
133 
134 /* See MS-SMB2 2.2.42 */
135 struct smb2_compression_transform_hdr_unchained {
136 	__le32 ProtocolId;	/* 0xFC 'S' 'M' 'B' */
137 	__le32 OriginalCompressedSegmentSize;
138 	__le16 CompressionAlgorithm;
139 	__le16 Flags;
140 	__le16 Length; /* if chained it is length, else offset */
141 } __packed;
142 
143 /* See MS-SMB2 2.2.42.1 */
144 #define SMB2_COMPRESSION_FLAG_NONE	0x0000
145 #define SMB2_COMPRESSION_FLAG_CHAINED	0x0001
146 
147 struct compression_payload_header {
148 	__le16	CompressionAlgorithm;
149 	__le16	Flags;
150 	__le32	Length; /* length of compressed playload including field below if present */
151 	/* __le32 OriginalPayloadSize; */ /* optional, present when LZNT1, LZ77, LZ77+Huffman */
152 } __packed;
153 
154 /* See MS-SMB2 2.2.42.2 */
155 struct smb2_compression_transform_hdr_chained {
156 	__le32 ProtocolId;	/* 0xFC 'S' 'M' 'B' */
157 	__le32 OriginalCompressedSegmentSize;
158 	/* struct compression_payload_header[] */
159 } __packed;
160 
161 /* See MS-SMB2 2.2.42.2.2 */
162 struct compression_pattern_payload_v1 {
163 	__le16	Pattern;
164 	__le16	Reserved1;
165 	__le16	Reserved2;
166 	__le32	Repetitions;
167 } __packed;
168 
169 /* See MS-SMB2 section 2.2.9.2 */
170 /* Context Types */
171 #define SMB2_RESERVED_TREE_CONNECT_CONTEXT_ID 0x0000
172 #define SMB2_REMOTED_IDENTITY_TREE_CONNECT_CONTEXT_ID cpu_to_le16(0x0001)
173 
174 struct tree_connect_contexts {
175 	__le16 ContextType;
176 	__le16 DataLength;
177 	__le32 Reserved;
178 	__u8   Data[];
179 } __packed;
180 
181 /* Remoted identity tree connect context structures - see MS-SMB2 2.2.9.2.1 */
182 struct smb3_blob_data {
183 	__le16 BlobSize;
184 	__u8   BlobData[];
185 } __packed;
186 
187 /* Valid values for Attr */
188 #define SE_GROUP_MANDATORY		0x00000001
189 #define SE_GROUP_ENABLED_BY_DEFAULT	0x00000002
190 #define SE_GROUP_ENABLED		0x00000004
191 #define SE_GROUP_OWNER			0x00000008
192 #define SE_GROUP_USE_FOR_DENY_ONLY	0x00000010
193 #define SE_GROUP_INTEGRITY		0x00000020
194 #define SE_GROUP_INTEGRITY_ENABLED	0x00000040
195 #define SE_GROUP_RESOURCE		0x20000000
196 #define SE_GROUP_LOGON_ID		0xC0000000
197 
198 /* struct sid_attr_data is SidData array in BlobData format then le32 Attr */
199 
200 struct sid_array_data {
201 	__le16 SidAttrCount;
202 	/* SidAttrList - array of sid_attr_data structs */
203 } __packed;
204 
205 struct luid_attr_data {
206 
207 } __packed;
208 
209 /*
210  * struct privilege_data is the same as BLOB_DATA - see MS-SMB2 2.2.9.2.1.5
211  * but with size of LUID_ATTR_DATA struct and BlobData set to LUID_ATTR DATA
212  */
213 
214 struct privilege_array_data {
215 	__le16 PrivilegeCount;
216 	/* array of privilege_data structs */
217 } __packed;
218 
219 struct remoted_identity_tcon_context {
220 	__le16 TicketType; /* must be 0x0001 */
221 	__le16 TicketSize; /* total size of this struct */
222 	__le16 User; /* offset to SID_ATTR_DATA struct with user info */
223 	__le16 UserName; /* offset to null terminated Unicode username string */
224 	__le16 Domain; /* offset to null terminated Unicode domain name */
225 	__le16 Groups; /* offset to SID_ARRAY_DATA struct with group info */
226 	__le16 RestrictedGroups; /* similar to above */
227 	__le16 Privileges; /* offset to PRIVILEGE_ARRAY_DATA struct */
228 	__le16 PrimaryGroup; /* offset to SID_ARRAY_DATA struct */
229 	__le16 Owner; /* offset to BLOB_DATA struct */
230 	__le16 DefaultDacl; /* offset to BLOB_DATA struct */
231 	__le16 DeviceGroups; /* offset to SID_ARRAY_DATA struct */
232 	__le16 UserClaims; /* offset to BLOB_DATA struct */
233 	__le16 DeviceClaims; /* offset to BLOB_DATA struct */
234 	__u8   TicketInfo[]; /* variable length buf - remoted identity data */
235 } __packed;
236 
237 struct smb2_tree_connect_req_extension {
238 	__le32 TreeConnectContextOffset;
239 	__le16 TreeConnectContextCount;
240 	__u8  Reserved[10];
241 	__u8  PathName[]; /* variable sized array */
242 	/* followed by array of TreeConnectContexts */
243 } __packed;
244 
245 /* Flags/Reserved for SMB3.1.1 */
246 #define SMB2_TREE_CONNECT_FLAG_CLUSTER_RECONNECT cpu_to_le16(0x0001)
247 #define SMB2_TREE_CONNECT_FLAG_REDIRECT_TO_OWNER cpu_to_le16(0x0002)
248 #define SMB2_TREE_CONNECT_FLAG_EXTENSION_PRESENT cpu_to_le16(0x0004)
249 
250 struct smb2_tree_connect_req {
251 	struct smb2_hdr hdr;
252 	__le16 StructureSize;	/* Must be 9 */
253 	__le16 Flags;		/* Flags in SMB3.1.1 */
254 	__le16 PathOffset;
255 	__le16 PathLength;
256 	__u8   Buffer[1];	/* variable length */
257 } __packed;
258 
259 /* Possible ShareType values */
260 #define SMB2_SHARE_TYPE_DISK	0x01
261 #define SMB2_SHARE_TYPE_PIPE	0x02
262 #define	SMB2_SHARE_TYPE_PRINT	0x03
263 
264 /*
265  * Possible ShareFlags - exactly one and only one of the first 4 caching flags
266  * must be set (any of the remaining, SHI1005, flags may be set individually
267  * or in combination.
268  */
269 #define SMB2_SHAREFLAG_MANUAL_CACHING			0x00000000
270 #define SMB2_SHAREFLAG_AUTO_CACHING			0x00000010
271 #define SMB2_SHAREFLAG_VDO_CACHING			0x00000020
272 #define SMB2_SHAREFLAG_NO_CACHING			0x00000030
273 #define SHI1005_FLAGS_DFS				0x00000001
274 #define SHI1005_FLAGS_DFS_ROOT				0x00000002
275 #define SHI1005_FLAGS_RESTRICT_EXCLUSIVE_OPENS		0x00000100
276 #define SHI1005_FLAGS_FORCE_SHARED_DELETE		0x00000200
277 #define SHI1005_FLAGS_ALLOW_NAMESPACE_CACHING		0x00000400
278 #define SHI1005_FLAGS_ACCESS_BASED_DIRECTORY_ENUM	0x00000800
279 #define SHI1005_FLAGS_FORCE_LEVELII_OPLOCK		0x00001000
280 #define SHI1005_FLAGS_ENABLE_HASH_V1			0x00002000
281 #define SHI1005_FLAGS_ENABLE_HASH_V2			0x00004000
282 #define SHI1005_FLAGS_ENCRYPT_DATA			0x00008000
283 #define SMB2_SHAREFLAG_IDENTITY_REMOTING		0x00040000 /* 3.1.1 */
284 #define SMB2_SHAREFLAG_COMPRESS_DATA			0x00100000 /* 3.1.1 */
285 #define SHI1005_FLAGS_ALL				0x0014FF33
286 
287 /* Possible share capabilities */
288 #define SMB2_SHARE_CAP_DFS	cpu_to_le32(0x00000008) /* all dialects */
289 #define SMB2_SHARE_CAP_CONTINUOUS_AVAILABILITY cpu_to_le32(0x00000010) /* 3.0 */
290 #define SMB2_SHARE_CAP_SCALEOUT	cpu_to_le32(0x00000020) /* 3.0 */
291 #define SMB2_SHARE_CAP_CLUSTER	cpu_to_le32(0x00000040) /* 3.0 */
292 #define SMB2_SHARE_CAP_ASYMMETRIC cpu_to_le32(0x00000080) /* 3.02 */
293 #define SMB2_SHARE_CAP_REDIRECT_TO_OWNER cpu_to_le32(0x00000100) /* 3.1.1 */
294 
295 struct smb2_tree_connect_rsp {
296 	struct smb2_hdr hdr;
297 	__le16 StructureSize;	/* Must be 16 */
298 	__u8   ShareType;	/* see below */
299 	__u8   Reserved;
300 	__le32 ShareFlags;	/* see below */
301 	__le32 Capabilities;	/* see below */
302 	__le32 MaximalAccess;
303 } __packed;
304 
305 struct smb2_tree_disconnect_req {
306 	struct smb2_hdr hdr;
307 	__le16 StructureSize;	/* Must be 4 */
308 	__le16 Reserved;
309 } __packed;
310 
311 struct smb2_tree_disconnect_rsp {
312 	struct smb2_hdr hdr;
313 	__le16 StructureSize;	/* Must be 4 */
314 	__le16 Reserved;
315 } __packed;
316 
317 
318 /*
319  * SMB2_NEGOTIATE_PROTOCOL  See MS-SMB2 section 2.2.3
320  */
321 /* SecurityMode flags */
322 #define	SMB2_NEGOTIATE_SIGNING_ENABLED     0x0001
323 #define	SMB2_NEGOTIATE_SIGNING_ENABLED_LE  cpu_to_le16(0x0001)
324 #define SMB2_NEGOTIATE_SIGNING_REQUIRED	   0x0002
325 #define SMB2_NEGOTIATE_SIGNING_REQUIRED_LE cpu_to_le16(0x0002)
326 #define SMB2_SEC_MODE_FLAGS_ALL            0x0003
327 
328 /* Capabilities flags */
329 #define SMB2_GLOBAL_CAP_DFS		0x00000001
330 #define SMB2_GLOBAL_CAP_LEASING		0x00000002 /* Resp only New to SMB2.1 */
331 #define SMB2_GLOBAL_CAP_LARGE_MTU	0X00000004 /* Resp only New to SMB2.1 */
332 #define SMB2_GLOBAL_CAP_MULTI_CHANNEL	0x00000008 /* New to SMB3 */
333 #define SMB2_GLOBAL_CAP_PERSISTENT_HANDLES 0x00000010 /* New to SMB3 */
334 #define SMB2_GLOBAL_CAP_DIRECTORY_LEASING  0x00000020 /* New to SMB3 */
335 #define SMB2_GLOBAL_CAP_ENCRYPTION	0x00000040 /* New to SMB3 */
336 /* Internal types */
337 #define SMB2_NT_FIND			0x00100000
338 #define SMB2_LARGE_FILES		0x00200000
339 
340 #define SMB2_CLIENT_GUID_SIZE		16
341 #define SMB2_CREATE_GUID_SIZE		16
342 
343 /* Dialects */
344 #define SMB10_PROT_ID  0x0000 /* local only, not sent on wire w/CIFS negprot */
345 #define SMB20_PROT_ID  0x0202
346 #define SMB21_PROT_ID  0x0210
347 #define SMB2X_PROT_ID  0x02FF
348 #define SMB30_PROT_ID  0x0300
349 #define SMB302_PROT_ID 0x0302
350 #define SMB311_PROT_ID 0x0311
351 #define BAD_PROT_ID    0xFFFF
352 
353 #define SMB311_SALT_SIZE			32
354 /* Hash Algorithm Types */
355 #define SMB2_PREAUTH_INTEGRITY_SHA512	cpu_to_le16(0x0001)
356 #define SMB2_PREAUTH_HASH_SIZE 64
357 
358 /* Negotiate Contexts - ContextTypes. See MS-SMB2 section 2.2.3.1 for details */
359 #define SMB2_PREAUTH_INTEGRITY_CAPABILITIES	cpu_to_le16(1)
360 #define SMB2_ENCRYPTION_CAPABILITIES		cpu_to_le16(2)
361 #define SMB2_COMPRESSION_CAPABILITIES		cpu_to_le16(3)
362 #define SMB2_NETNAME_NEGOTIATE_CONTEXT_ID	cpu_to_le16(5)
363 #define SMB2_TRANSPORT_CAPABILITIES		cpu_to_le16(6)
364 #define SMB2_RDMA_TRANSFORM_CAPABILITIES	cpu_to_le16(7)
365 #define SMB2_SIGNING_CAPABILITIES		cpu_to_le16(8)
366 #define SMB2_POSIX_EXTENSIONS_AVAILABLE		cpu_to_le16(0x100)
367 
368 struct smb2_neg_context {
369 	__le16	ContextType;
370 	__le16	DataLength;
371 	__le32	Reserved;
372 	/* Followed by array of data. NOTE: some servers require padding to 8 byte boundary */
373 } __packed;
374 
375 /*
376  * SaltLength that the server send can be zero, so the only three required
377  * fields (all __le16) end up six bytes total, so the minimum context data len
378  * in the response is six bytes which accounts for
379  *
380  *      HashAlgorithmCount, SaltLength, and 1 HashAlgorithm.
381  */
382 #define MIN_PREAUTH_CTXT_DATA_LEN 6
383 
384 struct smb2_preauth_neg_context {
385 	__le16	ContextType; /* 1 */
386 	__le16	DataLength;
387 	__le32	Reserved;
388 	__le16	HashAlgorithmCount; /* 1 */
389 	__le16	SaltLength;
390 	__le16	HashAlgorithms; /* HashAlgorithms[0] since only one defined */
391 	__u8	Salt[SMB311_SALT_SIZE];
392 } __packed;
393 
394 /* Encryption Algorithms Ciphers */
395 #define SMB2_ENCRYPTION_AES128_CCM	cpu_to_le16(0x0001)
396 #define SMB2_ENCRYPTION_AES128_GCM	cpu_to_le16(0x0002)
397 #define SMB2_ENCRYPTION_AES256_CCM      cpu_to_le16(0x0003)
398 #define SMB2_ENCRYPTION_AES256_GCM      cpu_to_le16(0x0004)
399 
400 /* Min encrypt context data is one cipher so 2 bytes + 2 byte count field */
401 #define MIN_ENCRYPT_CTXT_DATA_LEN	4
402 struct smb2_encryption_neg_context {
403 	__le16	ContextType; /* 2 */
404 	__le16	DataLength;
405 	__le32	Reserved;
406 	/* CipherCount usally 2, but can be 3 when AES256-GCM enabled */
407 	__le16	CipherCount; /* AES128-GCM and AES128-CCM by default */
408 	__le16	Ciphers[];
409 } __packed;
410 
411 /* See MS-SMB2 2.2.3.1.3 */
412 #define SMB3_COMPRESS_NONE	cpu_to_le16(0x0000)
413 #define SMB3_COMPRESS_LZNT1	cpu_to_le16(0x0001)
414 #define SMB3_COMPRESS_LZ77	cpu_to_le16(0x0002)
415 #define SMB3_COMPRESS_LZ77_HUFF	cpu_to_le16(0x0003)
416 /* Pattern scanning algorithm See MS-SMB2 3.1.4.4.1 */
417 #define SMB3_COMPRESS_PATTERN	cpu_to_le16(0x0004) /* Pattern_V1 */
418 
419 /* Compression Flags */
420 #define SMB2_COMPRESSION_CAPABILITIES_FLAG_NONE		cpu_to_le32(0x00000000)
421 #define SMB2_COMPRESSION_CAPABILITIES_FLAG_CHAINED	cpu_to_le32(0x00000001)
422 
423 struct smb2_compression_capabilities_context {
424 	__le16	ContextType; /* 3 */
425 	__le16  DataLength;
426 	__le32	Reserved;
427 	__le16	CompressionAlgorithmCount;
428 	__le16	Padding;
429 	__le32	Flags;
430 	__le16	CompressionAlgorithms[3];
431 	__u16	Pad;  /* Some servers require pad to DataLen multiple of 8 */
432 	/* Check if pad needed */
433 } __packed;
434 
435 /*
436  * For smb2_netname_negotiate_context_id See MS-SMB2 2.2.3.1.4.
437  * Its struct simply contains NetName, an array of Unicode characters
438  */
439 struct smb2_netname_neg_context {
440 	__le16	ContextType; /* 5 */
441 	__le16	DataLength;
442 	__le32	Reserved;
443 	__le16	NetName[]; /* hostname of target converted to UCS-2 */
444 } __packed;
445 
446 /*
447  * For smb2_transport_capabilities context see MS-SMB2 2.2.3.1.5
448  * and 2.2.4.1.5
449  */
450 
451 /* Flags */
452 #define SMB2_ACCEPT_TRANSFORM_LEVEL_SECURITY	0x00000001
453 
454 struct smb2_transport_capabilities_context {
455 	__le16	ContextType; /* 6 */
456 	__le16  DataLength;
457 	__u32	Reserved;
458 	__le32	Flags;
459 	__u32	Pad;
460 } __packed;
461 
462 /*
463  * For rdma transform capabilities context see MS-SMB2 2.2.3.1.6
464  * and 2.2.4.1.6
465  */
466 
467 /* RDMA Transform IDs */
468 #define SMB2_RDMA_TRANSFORM_NONE	0x0000
469 #define SMB2_RDMA_TRANSFORM_ENCRYPTION	0x0001
470 #define SMB2_RDMA_TRANSFORM_SIGNING	0x0002
471 
472 struct smb2_rdma_transform_capabilities_context {
473 	__le16	ContextType; /* 7 */
474 	__le16  DataLength;
475 	__u32	Reserved;
476 	__le16	TransformCount;
477 	__u16	Reserved1;
478 	__u32	Reserved2;
479 	__le16	RDMATransformIds[];
480 } __packed;
481 
482 /*
483  * For signing capabilities context see MS-SMB2 2.2.3.1.7
484  * and 2.2.4.1.7
485  */
486 
487 /* Signing algorithms */
488 #define SIGNING_ALG_HMAC_SHA256    0
489 #define SIGNING_ALG_HMAC_SHA256_LE cpu_to_le16(0)
490 #define SIGNING_ALG_AES_CMAC       1
491 #define SIGNING_ALG_AES_CMAC_LE    cpu_to_le16(1)
492 #define SIGNING_ALG_AES_GMAC       2
493 #define SIGNING_ALG_AES_GMAC_LE    cpu_to_le16(2)
494 
495 struct smb2_signing_capabilities {
496 	__le16	ContextType; /* 8 */
497 	__le16	DataLength;
498 	__le32	Reserved;
499 	__le16	SigningAlgorithmCount;
500 	__le16	SigningAlgorithms[];
501 	/*  Followed by padding to 8 byte boundary (required by some servers) */
502 } __packed;
503 
504 #define POSIX_CTXT_DATA_LEN	16
505 struct smb2_posix_neg_context {
506 	__le16	ContextType; /* 0x100 */
507 	__le16	DataLength;
508 	__le32	Reserved;
509 	__u8	Name[16]; /* POSIX ctxt GUID 93AD25509CB411E7B42383DE968BCD7C */
510 } __packed;
511 
512 struct smb2_negotiate_req {
513 	struct smb2_hdr hdr;
514 	__le16 StructureSize; /* Must be 36 */
515 	__le16 DialectCount;
516 	__le16 SecurityMode;
517 	__le16 Reserved;	/* MBZ */
518 	__le32 Capabilities;
519 	__u8   ClientGUID[SMB2_CLIENT_GUID_SIZE];
520 	/* In SMB3.02 and earlier next three were MBZ le64 ClientStartTime */
521 	__le32 NegotiateContextOffset; /* SMB3.1.1 only. MBZ earlier */
522 	__le16 NegotiateContextCount;  /* SMB3.1.1 only. MBZ earlier */
523 	__le16 Reserved2;
524 	__le16 Dialects[];
525 } __packed;
526 
527 struct smb2_negotiate_rsp {
528 	struct smb2_hdr hdr;
529 	__le16 StructureSize;	/* Must be 65 */
530 	__le16 SecurityMode;
531 	__le16 DialectRevision;
532 	__le16 NegotiateContextCount;	/* Prior to SMB3.1.1 was Reserved & MBZ */
533 	__u8   ServerGUID[16];
534 	__le32 Capabilities;
535 	__le32 MaxTransactSize;
536 	__le32 MaxReadSize;
537 	__le32 MaxWriteSize;
538 	__le64 SystemTime;	/* MBZ */
539 	__le64 ServerStartTime;
540 	__le16 SecurityBufferOffset;
541 	__le16 SecurityBufferLength;
542 	__le32 NegotiateContextOffset;	/* Pre:SMB3.1.1 was reserved/ignored */
543 	__u8   Buffer[1];	/* variable length GSS security buffer */
544 } __packed;
545 
546 
547 /*
548  * SMB2_SESSION_SETUP  See MS-SMB2 section 2.2.5
549  */
550 /* Flags */
551 #define SMB2_SESSION_REQ_FLAG_BINDING		0x01
552 #define SMB2_SESSION_REQ_FLAG_ENCRYPT_DATA	0x04
553 
554 struct smb2_sess_setup_req {
555 	struct smb2_hdr hdr;
556 	__le16 StructureSize; /* Must be 25 */
557 	__u8   Flags;
558 	__u8   SecurityMode;
559 	__le32 Capabilities;
560 	__le32 Channel;
561 	__le16 SecurityBufferOffset;
562 	__le16 SecurityBufferLength;
563 	__le64 PreviousSessionId;
564 	__u8   Buffer[1];	/* variable length GSS security buffer */
565 } __packed;
566 
567 /* Currently defined SessionFlags */
568 #define SMB2_SESSION_FLAG_IS_GUEST        0x0001
569 #define SMB2_SESSION_FLAG_IS_GUEST_LE     cpu_to_le16(0x0001)
570 #define SMB2_SESSION_FLAG_IS_NULL         0x0002
571 #define SMB2_SESSION_FLAG_IS_NULL_LE      cpu_to_le16(0x0002)
572 #define SMB2_SESSION_FLAG_ENCRYPT_DATA    0x0004
573 #define SMB2_SESSION_FLAG_ENCRYPT_DATA_LE cpu_to_le16(0x0004)
574 
575 struct smb2_sess_setup_rsp {
576 	struct smb2_hdr hdr;
577 	__le16 StructureSize; /* Must be 9 */
578 	__le16 SessionFlags;
579 	__le16 SecurityBufferOffset;
580 	__le16 SecurityBufferLength;
581 	__u8   Buffer[1];	/* variable length GSS security buffer */
582 } __packed;
583 
584 
585 /*
586  * SMB2_LOGOFF  See MS-SMB2 section 2.2.7
587  */
588 struct smb2_logoff_req {
589 	struct smb2_hdr hdr;
590 	__le16 StructureSize;	/* Must be 4 */
591 	__le16 Reserved;
592 } __packed;
593 
594 struct smb2_logoff_rsp {
595 	struct smb2_hdr hdr;
596 	__le16 StructureSize;	/* Must be 4 */
597 	__le16 Reserved;
598 } __packed;
599 
600 
601 /*
602  * SMB2_CLOSE  See MS-SMB2 section 2.2.15
603  */
604 /* Currently defined values for close flags */
605 #define SMB2_CLOSE_FLAG_POSTQUERY_ATTRIB	cpu_to_le16(0x0001)
606 struct smb2_close_req {
607 	struct smb2_hdr hdr;
608 	__le16 StructureSize;	/* Must be 24 */
609 	__le16 Flags;
610 	__le32 Reserved;
611 	__le64  PersistentFileId; /* opaque endianness */
612 	__le64  VolatileFileId; /* opaque endianness */
613 } __packed;
614 
615 /*
616  * Maximum size of a SMB2_CLOSE response is 64 (smb2 header) + 60 (data)
617  */
618 #define MAX_SMB2_CLOSE_RESPONSE_SIZE 124
619 
620 struct smb2_close_rsp {
621 	struct smb2_hdr hdr;
622 	__le16 StructureSize; /* 60 */
623 	__le16 Flags;
624 	__le32 Reserved;
625 	__le64 CreationTime;
626 	__le64 LastAccessTime;
627 	__le64 LastWriteTime;
628 	__le64 ChangeTime;
629 	__le64 AllocationSize;	/* Beginning of FILE_STANDARD_INFO equivalent */
630 	__le64 EndOfFile;
631 	__le32 Attributes;
632 } __packed;
633 
634 
635 /*
636  * SMB2_READ  See MS-SMB2 section 2.2.19
637  */
638 /* For read request Flags field below, following flag is defined for SMB3.02 */
639 #define SMB2_READFLAG_READ_UNBUFFERED	0x01
640 #define SMB2_READFLAG_REQUEST_COMPRESSED 0x02 /* See MS-SMB2 2.2.19 */
641 
642 /* Channel field for read and write: exactly one of following flags can be set*/
643 #define SMB2_CHANNEL_NONE               cpu_to_le32(0x00000000)
644 #define SMB2_CHANNEL_RDMA_V1            cpu_to_le32(0x00000001)
645 #define SMB2_CHANNEL_RDMA_V1_INVALIDATE cpu_to_le32(0x00000002)
646 #define SMB2_CHANNEL_RDMA_TRANSFORM     cpu_to_le32(0x00000003)
647 
648 /* SMB2 read request without RFC1001 length at the beginning */
649 struct smb2_read_req {
650 	struct smb2_hdr hdr;
651 	__le16 StructureSize; /* Must be 49 */
652 	__u8   Padding; /* offset from start of SMB2 header to place read */
653 	__u8   Flags; /* MBZ unless SMB3.02 or later */
654 	__le32 Length;
655 	__le64 Offset;
656 	__le64  PersistentFileId;
657 	__le64  VolatileFileId;
658 	__le32 MinimumCount;
659 	__le32 Channel; /* MBZ except for SMB3 or later */
660 	__le32 RemainingBytes;
661 	__le16 ReadChannelInfoOffset;
662 	__le16 ReadChannelInfoLength;
663 	__u8   Buffer[1];
664 } __packed;
665 
666 /* Read flags */
667 #define SMB2_READFLAG_RESPONSE_NONE            cpu_to_le32(0x00000000)
668 #define SMB2_READFLAG_RESPONSE_RDMA_TRANSFORM  cpu_to_le32(0x00000001)
669 
670 struct smb2_read_rsp {
671 	struct smb2_hdr hdr;
672 	__le16 StructureSize; /* Must be 17 */
673 	__u8   DataOffset;
674 	__u8   Reserved;
675 	__le32 DataLength;
676 	__le32 DataRemaining;
677 	__le32 Flags;
678 	__u8   Buffer[1];
679 } __packed;
680 
681 
682 /*
683  * SMB2_WRITE  See MS-SMB2 section 2.2.21
684  */
685 /* For write request Flags field below the following flags are defined: */
686 #define SMB2_WRITEFLAG_WRITE_THROUGH	0x00000001	/* SMB2.1 or later */
687 #define SMB2_WRITEFLAG_WRITE_UNBUFFERED	0x00000002	/* SMB3.02 or later */
688 
689 struct smb2_write_req {
690 	struct smb2_hdr hdr;
691 	__le16 StructureSize; /* Must be 49 */
692 	__le16 DataOffset; /* offset from start of SMB2 header to write data */
693 	__le32 Length;
694 	__le64 Offset;
695 	__le64  PersistentFileId; /* opaque endianness */
696 	__le64  VolatileFileId; /* opaque endianness */
697 	__le32 Channel; /* MBZ unless SMB3.02 or later */
698 	__le32 RemainingBytes;
699 	__le16 WriteChannelInfoOffset;
700 	__le16 WriteChannelInfoLength;
701 	__le32 Flags;
702 	__u8   Buffer[1];
703 } __packed;
704 
705 struct smb2_write_rsp {
706 	struct smb2_hdr hdr;
707 	__le16 StructureSize; /* Must be 17 */
708 	__u8   DataOffset;
709 	__u8   Reserved;
710 	__le32 DataLength;
711 	__le32 DataRemaining;
712 	__u32  Reserved2;
713 	__u8   Buffer[1];
714 } __packed;
715 
716 
717 /*
718  * SMB2_FLUSH  See MS-SMB2 section 2.2.17
719  */
720 struct smb2_flush_req {
721 	struct smb2_hdr hdr;
722 	__le16 StructureSize;	/* Must be 24 */
723 	__le16 Reserved1;
724 	__le32 Reserved2;
725 	__le64  PersistentFileId;
726 	__le64  VolatileFileId;
727 } __packed;
728 
729 struct smb2_flush_rsp {
730 	struct smb2_hdr hdr;
731 	__le16 StructureSize;
732 	__le16 Reserved;
733 } __packed;
734 
735 
736 /*
737  * SMB2_NOTIFY  See MS-SMB2 section 2.2.35
738  */
739 /* notify flags */
740 #define SMB2_WATCH_TREE			0x0001
741 
742 /* notify completion filter flags. See MS-FSCC 2.6 and MS-SMB2 2.2.35 */
743 #define FILE_NOTIFY_CHANGE_FILE_NAME		0x00000001
744 #define FILE_NOTIFY_CHANGE_DIR_NAME		0x00000002
745 #define FILE_NOTIFY_CHANGE_ATTRIBUTES		0x00000004
746 #define FILE_NOTIFY_CHANGE_SIZE			0x00000008
747 #define FILE_NOTIFY_CHANGE_LAST_WRITE		0x00000010
748 #define FILE_NOTIFY_CHANGE_LAST_ACCESS		0x00000020
749 #define FILE_NOTIFY_CHANGE_CREATION		0x00000040
750 #define FILE_NOTIFY_CHANGE_EA			0x00000080
751 #define FILE_NOTIFY_CHANGE_SECURITY		0x00000100
752 #define FILE_NOTIFY_CHANGE_STREAM_NAME		0x00000200
753 #define FILE_NOTIFY_CHANGE_STREAM_SIZE		0x00000400
754 #define FILE_NOTIFY_CHANGE_STREAM_WRITE		0x00000800
755 
756 /* SMB2 Notify Action Flags */
757 #define FILE_ACTION_ADDED                       0x00000001
758 #define FILE_ACTION_REMOVED                     0x00000002
759 #define FILE_ACTION_MODIFIED                    0x00000003
760 #define FILE_ACTION_RENAMED_OLD_NAME            0x00000004
761 #define FILE_ACTION_RENAMED_NEW_NAME            0x00000005
762 #define FILE_ACTION_ADDED_STREAM                0x00000006
763 #define FILE_ACTION_REMOVED_STREAM              0x00000007
764 #define FILE_ACTION_MODIFIED_STREAM             0x00000008
765 #define FILE_ACTION_REMOVED_BY_DELETE           0x00000009
766 
767 struct smb2_change_notify_req {
768 	struct smb2_hdr hdr;
769 	__le16	StructureSize;
770 	__le16	Flags;
771 	__le32	OutputBufferLength;
772 	__le64	PersistentFileId; /* opaque endianness */
773 	__le64	VolatileFileId; /* opaque endianness */
774 	__le32	CompletionFilter;
775 	__u32	Reserved;
776 } __packed;
777 
778 struct smb2_change_notify_rsp {
779 	struct smb2_hdr hdr;
780 	__le16	StructureSize;  /* Must be 9 */
781 	__le16	OutputBufferOffset;
782 	__le32	OutputBufferLength;
783 	__u8	Buffer[1]; /* array of file notify structs */
784 } __packed;
785 
786 
787 /*
788  * SMB2_CREATE  See MS-SMB2 section 2.2.13
789  */
790 /* Oplock levels */
791 #define SMB2_OPLOCK_LEVEL_NONE		0x00
792 #define SMB2_OPLOCK_LEVEL_II		0x01
793 #define SMB2_OPLOCK_LEVEL_EXCLUSIVE	0x08
794 #define SMB2_OPLOCK_LEVEL_BATCH		0x09
795 #define SMB2_OPLOCK_LEVEL_LEASE		0xFF
796 /* Non-spec internal type */
797 #define SMB2_OPLOCK_LEVEL_NOCHANGE	0x99
798 
799 /* Impersonation Levels. See MS-WPO section 9.7 and MSDN-IMPERS */
800 #define IL_ANONYMOUS		cpu_to_le32(0x00000000)
801 #define IL_IDENTIFICATION	cpu_to_le32(0x00000001)
802 #define IL_IMPERSONATION	cpu_to_le32(0x00000002)
803 #define IL_DELEGATE		cpu_to_le32(0x00000003)
804 
805 /* File Attrubutes */
806 #define FILE_ATTRIBUTE_READONLY			0x00000001
807 #define FILE_ATTRIBUTE_HIDDEN			0x00000002
808 #define FILE_ATTRIBUTE_SYSTEM			0x00000004
809 #define FILE_ATTRIBUTE_DIRECTORY		0x00000010
810 #define FILE_ATTRIBUTE_ARCHIVE			0x00000020
811 #define FILE_ATTRIBUTE_NORMAL			0x00000080
812 #define FILE_ATTRIBUTE_TEMPORARY		0x00000100
813 #define FILE_ATTRIBUTE_SPARSE_FILE		0x00000200
814 #define FILE_ATTRIBUTE_REPARSE_POINT		0x00000400
815 #define FILE_ATTRIBUTE_COMPRESSED		0x00000800
816 #define FILE_ATTRIBUTE_OFFLINE			0x00001000
817 #define FILE_ATTRIBUTE_NOT_CONTENT_INDEXED	0x00002000
818 #define FILE_ATTRIBUTE_ENCRYPTED		0x00004000
819 #define FILE_ATTRIBUTE_INTEGRITY_STREAM		0x00008000
820 #define FILE_ATTRIBUTE_NO_SCRUB_DATA		0x00020000
821 #define FILE_ATTRIBUTE__MASK			0x00007FB7
822 
823 #define FILE_ATTRIBUTE_READONLY_LE              cpu_to_le32(0x00000001)
824 #define FILE_ATTRIBUTE_HIDDEN_LE		cpu_to_le32(0x00000002)
825 #define FILE_ATTRIBUTE_SYSTEM_LE		cpu_to_le32(0x00000004)
826 #define FILE_ATTRIBUTE_DIRECTORY_LE		cpu_to_le32(0x00000010)
827 #define FILE_ATTRIBUTE_ARCHIVE_LE		cpu_to_le32(0x00000020)
828 #define FILE_ATTRIBUTE_NORMAL_LE		cpu_to_le32(0x00000080)
829 #define FILE_ATTRIBUTE_TEMPORARY_LE		cpu_to_le32(0x00000100)
830 #define FILE_ATTRIBUTE_SPARSE_FILE_LE		cpu_to_le32(0x00000200)
831 #define FILE_ATTRIBUTE_REPARSE_POINT_LE		cpu_to_le32(0x00000400)
832 #define FILE_ATTRIBUTE_COMPRESSED_LE		cpu_to_le32(0x00000800)
833 #define FILE_ATTRIBUTE_OFFLINE_LE		cpu_to_le32(0x00001000)
834 #define FILE_ATTRIBUTE_NOT_CONTENT_INDEXED_LE	cpu_to_le32(0x00002000)
835 #define FILE_ATTRIBUTE_ENCRYPTED_LE		cpu_to_le32(0x00004000)
836 #define FILE_ATTRIBUTE_INTEGRITY_STREAM_LE	cpu_to_le32(0x00008000)
837 #define FILE_ATTRIBUTE_NO_SCRUB_DATA_LE		cpu_to_le32(0x00020000)
838 #define FILE_ATTRIBUTE_MASK_LE			cpu_to_le32(0x00007FB7)
839 
840 /* Desired Access Flags */
841 #define FILE_READ_DATA_LE		cpu_to_le32(0x00000001)
842 #define FILE_LIST_DIRECTORY_LE		cpu_to_le32(0x00000001)
843 #define FILE_WRITE_DATA_LE		cpu_to_le32(0x00000002)
844 #define FILE_APPEND_DATA_LE		cpu_to_le32(0x00000004)
845 #define FILE_ADD_SUBDIRECTORY_LE	cpu_to_le32(0x00000004)
846 #define FILE_READ_EA_LE			cpu_to_le32(0x00000008)
847 #define FILE_WRITE_EA_LE		cpu_to_le32(0x00000010)
848 #define FILE_EXECUTE_LE			cpu_to_le32(0x00000020)
849 #define FILE_DELETE_CHILD_LE		cpu_to_le32(0x00000040)
850 #define FILE_READ_ATTRIBUTES_LE		cpu_to_le32(0x00000080)
851 #define FILE_WRITE_ATTRIBUTES_LE	cpu_to_le32(0x00000100)
852 #define FILE_DELETE_LE			cpu_to_le32(0x00010000)
853 #define FILE_READ_CONTROL_LE		cpu_to_le32(0x00020000)
854 #define FILE_WRITE_DAC_LE		cpu_to_le32(0x00040000)
855 #define FILE_WRITE_OWNER_LE		cpu_to_le32(0x00080000)
856 #define FILE_SYNCHRONIZE_LE		cpu_to_le32(0x00100000)
857 #define FILE_ACCESS_SYSTEM_SECURITY_LE	cpu_to_le32(0x01000000)
858 #define FILE_MAXIMAL_ACCESS_LE		cpu_to_le32(0x02000000)
859 #define FILE_GENERIC_ALL_LE		cpu_to_le32(0x10000000)
860 #define FILE_GENERIC_EXECUTE_LE		cpu_to_le32(0x20000000)
861 #define FILE_GENERIC_WRITE_LE		cpu_to_le32(0x40000000)
862 #define FILE_GENERIC_READ_LE		cpu_to_le32(0x80000000)
863 #define DESIRED_ACCESS_MASK             cpu_to_le32(0xF21F01FF)
864 
865 
866 #define FILE_READ_DESIRED_ACCESS_LE     (FILE_READ_DATA_LE        |	\
867 					 FILE_READ_EA_LE          |     \
868 					 FILE_GENERIC_READ_LE)
869 #define FILE_WRITE_DESIRE_ACCESS_LE     (FILE_WRITE_DATA_LE       |	\
870 					 FILE_APPEND_DATA_LE      |	\
871 					 FILE_WRITE_EA_LE         |	\
872 					 FILE_WRITE_ATTRIBUTES_LE |	\
873 					 FILE_GENERIC_WRITE_LE)
874 
875 /* ShareAccess Flags */
876 #define FILE_SHARE_READ_LE		cpu_to_le32(0x00000001)
877 #define FILE_SHARE_WRITE_LE		cpu_to_le32(0x00000002)
878 #define FILE_SHARE_DELETE_LE		cpu_to_le32(0x00000004)
879 #define FILE_SHARE_ALL_LE		cpu_to_le32(0x00000007)
880 
881 /* CreateDisposition Flags */
882 #define FILE_SUPERSEDE_LE		cpu_to_le32(0x00000000)
883 #define FILE_OPEN_LE			cpu_to_le32(0x00000001)
884 #define FILE_CREATE_LE			cpu_to_le32(0x00000002)
885 #define	FILE_OPEN_IF_LE			cpu_to_le32(0x00000003)
886 #define FILE_OVERWRITE_LE		cpu_to_le32(0x00000004)
887 #define FILE_OVERWRITE_IF_LE		cpu_to_le32(0x00000005)
888 #define FILE_CREATE_MASK_LE             cpu_to_le32(0x00000007)
889 
890 #define FILE_READ_RIGHTS (FILE_READ_DATA | FILE_READ_EA \
891 			| FILE_READ_ATTRIBUTES)
892 #define FILE_WRITE_RIGHTS (FILE_WRITE_DATA | FILE_APPEND_DATA \
893 			| FILE_WRITE_EA | FILE_WRITE_ATTRIBUTES)
894 #define FILE_EXEC_RIGHTS (FILE_EXECUTE)
895 
896 /* CreateOptions Flags */
897 #define FILE_DIRECTORY_FILE_LE		cpu_to_le32(0x00000001)
898 /* same as #define CREATE_NOT_FILE_LE	cpu_to_le32(0x00000001) */
899 #define FILE_WRITE_THROUGH_LE		cpu_to_le32(0x00000002)
900 #define FILE_SEQUENTIAL_ONLY_LE		cpu_to_le32(0x00000004)
901 #define FILE_NO_INTERMEDIATE_BUFFERING_LE cpu_to_le32(0x00000008)
902 #define FILE_NON_DIRECTORY_FILE_LE	cpu_to_le32(0x00000040)
903 #define FILE_COMPLETE_IF_OPLOCKED_LE	cpu_to_le32(0x00000100)
904 #define FILE_NO_EA_KNOWLEDGE_LE		cpu_to_le32(0x00000200)
905 #define FILE_RANDOM_ACCESS_LE		cpu_to_le32(0x00000800)
906 #define FILE_DELETE_ON_CLOSE_LE		cpu_to_le32(0x00001000)
907 #define FILE_OPEN_BY_FILE_ID_LE		cpu_to_le32(0x00002000)
908 #define FILE_OPEN_FOR_BACKUP_INTENT_LE	cpu_to_le32(0x00004000)
909 #define FILE_NO_COMPRESSION_LE		cpu_to_le32(0x00008000)
910 #define FILE_OPEN_REPARSE_POINT_LE	cpu_to_le32(0x00200000)
911 #define FILE_OPEN_NO_RECALL_LE		cpu_to_le32(0x00400000)
912 #define CREATE_OPTIONS_MASK_LE          cpu_to_le32(0x00FFFFFF)
913 
914 #define FILE_READ_RIGHTS_LE (FILE_READ_DATA_LE | FILE_READ_EA_LE \
915 			| FILE_READ_ATTRIBUTES_LE)
916 #define FILE_WRITE_RIGHTS_LE (FILE_WRITE_DATA_LE | FILE_APPEND_DATA_LE \
917 			| FILE_WRITE_EA_LE | FILE_WRITE_ATTRIBUTES_LE)
918 #define FILE_EXEC_RIGHTS_LE (FILE_EXECUTE_LE)
919 
920 /* Create Context Values */
921 #define SMB2_CREATE_EA_BUFFER			"ExtA" /* extended attributes */
922 #define SMB2_CREATE_SD_BUFFER			"SecD" /* security descriptor */
923 #define SMB2_CREATE_DURABLE_HANDLE_REQUEST	"DHnQ"
924 #define SMB2_CREATE_DURABLE_HANDLE_RECONNECT	"DHnC"
925 #define SMB2_CREATE_ALLOCATION_SIZE		"AISi"
926 #define SMB2_CREATE_QUERY_MAXIMAL_ACCESS_REQUEST "MxAc"
927 #define SMB2_CREATE_TIMEWARP_REQUEST		"TWrp"
928 #define SMB2_CREATE_QUERY_ON_DISK_ID		"QFid"
929 #define SMB2_CREATE_REQUEST_LEASE		"RqLs"
930 #define SMB2_CREATE_DURABLE_HANDLE_REQUEST_V2	"DH2Q"
931 #define SMB2_CREATE_DURABLE_HANDLE_RECONNECT_V2	"DH2C"
932 #define SMB2_CREATE_TAG_POSIX          "\x93\xAD\x25\x50\x9C\xB4\x11\xE7\xB4\x23\x83\xDE\x96\x8B\xCD\x7C"
933 
934 /* Flag (SMB3 open response) values */
935 #define SMB2_CREATE_FLAG_REPARSEPOINT 0x01
936 
937 struct create_context {
938 	__le32 Next;
939 	__le16 NameOffset;
940 	__le16 NameLength;
941 	__le16 Reserved;
942 	__le16 DataOffset;
943 	__le32 DataLength;
944 	__u8 Buffer[];
945 } __packed;
946 
947 struct smb2_create_req {
948 	struct smb2_hdr hdr;
949 	__le16 StructureSize;	/* Must be 57 */
950 	__u8   SecurityFlags;
951 	__u8   RequestedOplockLevel;
952 	__le32 ImpersonationLevel;
953 	__le64 SmbCreateFlags;
954 	__le64 Reserved;
955 	__le32 DesiredAccess;
956 	__le32 FileAttributes;
957 	__le32 ShareAccess;
958 	__le32 CreateDisposition;
959 	__le32 CreateOptions;
960 	__le16 NameOffset;
961 	__le16 NameLength;
962 	__le32 CreateContextsOffset;
963 	__le32 CreateContextsLength;
964 	__u8   Buffer[];
965 } __packed;
966 
967 struct smb2_create_rsp {
968 	struct smb2_hdr hdr;
969 	__le16 StructureSize;	/* Must be 89 */
970 	__u8   OplockLevel;
971 	__u8   Flags;  /* 0x01 if reparse point */
972 	__le32 CreateAction;
973 	__le64 CreationTime;
974 	__le64 LastAccessTime;
975 	__le64 LastWriteTime;
976 	__le64 ChangeTime;
977 	__le64 AllocationSize;
978 	__le64 EndofFile;
979 	__le32 FileAttributes;
980 	__le32 Reserved2;
981 	__le64  PersistentFileId;
982 	__le64  VolatileFileId;
983 	__le32 CreateContextsOffset;
984 	__le32 CreateContextsLength;
985 	__u8   Buffer[1];
986 } __packed;
987 
988 
989 #endif				/* _COMMON_SMB2PDU_H */
990