1 /* SPDX-License-Identifier: LGPL-2.1 */
5 * Copyright (c) International Business Machines Corp., 2009, 2013
7 * Author(s): Steve French (sfrench@us.ibm.com)
8 * Pavel Shilovsky (pshilovsky@samba.org) 2012
19 * Note that, due to trying to use names similar to the protocol specifications,
20 * there are many mixed case field names in the structures below. Although
21 * this does not match typical Linux kernel style, it is necessary to be
22 * able to match against the protocol specfication.
25 * Some commands have minimal (wct=0,bcc=0), or uninteresting, responses
26 * (ie no useful data other than the SMB error code itself) and are marked such.
27 * Knowing this helps avoid response buffer allocations and copy in some cases.
30 /* List of commands in host endian */
31 #define SMB2_NEGOTIATE_HE 0x0000
32 #define SMB2_SESSION_SETUP_HE 0x0001
33 #define SMB2_LOGOFF_HE 0x0002 /* trivial request/resp */
34 #define SMB2_TREE_CONNECT_HE 0x0003
35 #define SMB2_TREE_DISCONNECT_HE 0x0004 /* trivial req/resp */
36 #define SMB2_CREATE_HE 0x0005
37 #define SMB2_CLOSE_HE 0x0006
38 #define SMB2_FLUSH_HE 0x0007 /* trivial resp */
39 #define SMB2_READ_HE 0x0008
40 #define SMB2_WRITE_HE 0x0009
41 #define SMB2_LOCK_HE 0x000A
42 #define SMB2_IOCTL_HE 0x000B
43 #define SMB2_CANCEL_HE 0x000C
44 #define SMB2_ECHO_HE 0x000D
45 #define SMB2_QUERY_DIRECTORY_HE 0x000E
46 #define SMB2_CHANGE_NOTIFY_HE 0x000F
47 #define SMB2_QUERY_INFO_HE 0x0010
48 #define SMB2_SET_INFO_HE 0x0011
49 #define SMB2_OPLOCK_BREAK_HE 0x0012
51 /* The same list in little endian */
52 #define SMB2_NEGOTIATE cpu_to_le16(SMB2_NEGOTIATE_HE)
53 #define SMB2_SESSION_SETUP cpu_to_le16(SMB2_SESSION_SETUP_HE)
54 #define SMB2_LOGOFF cpu_to_le16(SMB2_LOGOFF_HE)
55 #define SMB2_TREE_CONNECT cpu_to_le16(SMB2_TREE_CONNECT_HE)
56 #define SMB2_TREE_DISCONNECT cpu_to_le16(SMB2_TREE_DISCONNECT_HE)
57 #define SMB2_CREATE cpu_to_le16(SMB2_CREATE_HE)
58 #define SMB2_CLOSE cpu_to_le16(SMB2_CLOSE_HE)
59 #define SMB2_FLUSH cpu_to_le16(SMB2_FLUSH_HE)
60 #define SMB2_READ cpu_to_le16(SMB2_READ_HE)
61 #define SMB2_WRITE cpu_to_le16(SMB2_WRITE_HE)
62 #define SMB2_LOCK cpu_to_le16(SMB2_LOCK_HE)
63 #define SMB2_IOCTL cpu_to_le16(SMB2_IOCTL_HE)
64 #define SMB2_CANCEL cpu_to_le16(SMB2_CANCEL_HE)
65 #define SMB2_ECHO cpu_to_le16(SMB2_ECHO_HE)
66 #define SMB2_QUERY_DIRECTORY cpu_to_le16(SMB2_QUERY_DIRECTORY_HE)
67 #define SMB2_CHANGE_NOTIFY cpu_to_le16(SMB2_CHANGE_NOTIFY_HE)
68 #define SMB2_QUERY_INFO cpu_to_le16(SMB2_QUERY_INFO_HE)
69 #define SMB2_SET_INFO cpu_to_le16(SMB2_SET_INFO_HE)
70 #define SMB2_OPLOCK_BREAK cpu_to_le16(SMB2_OPLOCK_BREAK_HE)
72 #define SMB2_INTERNAL_CMD cpu_to_le16(0xFFFF)
74 #define NUMBER_OF_SMB2_COMMANDS 0x0013
76 /* 52 transform hdr + 64 hdr + 88 create rsp */
77 #define SMB2_TRANSFORM_HEADER_SIZE 52
78 #define MAX_SMB2_HDR_SIZE 204
80 #define SMB2_PROTO_NUMBER cpu_to_le32(0x424d53fe)
81 #define SMB2_TRANSFORM_PROTO_NUM cpu_to_le32(0x424d53fd)
82 #define SMB2_COMPRESSION_TRANSFORM_ID cpu_to_le32(0x424d53fc)
85 * SMB2 Header Definition
87 * "MBZ" : Must be Zero
88 * "BB" : BugBug, Something to check/review/analyze later
89 * "PDU" : "Protocol Data Unit" (ie a network "frame")
93 #define SMB2_HEADER_STRUCTURE_SIZE cpu_to_le16(64)
95 struct smb2_sync_hdr {
96 __le32 ProtocolId; /* 0xFE 'S' 'M' 'B' */
97 __le16 StructureSize; /* 64 */
98 __le16 CreditCharge; /* MBZ */
99 __le32 Status; /* Error from server */
101 __le16 CreditRequest; /* CreditResponse */
106 __u32 TreeId; /* opaque - so do not make little endian */
107 __u64 SessionId; /* opaque - so do not make little endian */
111 /* The total header size for SMB2 read and write */
112 #define SMB2_READWRITE_PDU_HEADER_SIZE (48 + sizeof(struct smb2_sync_hdr))
114 struct smb2_sync_pdu {
115 struct smb2_sync_hdr sync_hdr;
116 __le16 StructureSize2; /* size of wct area (varies, request specific) */
119 #define SMB3_AES_CCM_NONCE 11
120 #define SMB3_AES_GCM_NONCE 12
122 /* Transform flags (for 3.0 dialect this flag indicates CCM */
123 #define TRANSFORM_FLAG_ENCRYPTED 0x0001
124 struct smb2_transform_hdr {
125 __le32 ProtocolId; /* 0xFD 'S' 'M' 'B' */
128 __le32 OriginalMessageSize;
130 __le16 Flags; /* EncryptionAlgorithm for 3.0, enc enabled for 3.1.1 */
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;
140 __le16 Length; /* if chained it is length, else offset */
143 /* See MS-SMB2 2.2.42.1 */
144 #define SMB2_COMPRESSION_FLAG_NONE 0x0000
145 #define SMB2_COMPRESSION_FLAG_CHAINED 0x0001
147 struct compression_payload_header {
148 __le16 CompressionAlgorithm;
150 __le32 Length; /* length of compressed playload including field below if present */
151 /* __le32 OriginalPayloadSize; */ /* optional, present when LZNT1, LZ77, LZ77+Huffman */
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[] */
161 /* See MS-SMB2 2.2.42.2.2 */
162 struct compression_pattern_payload_v1 {
169 /* See MS-SMB2 2.2.43 */
170 struct smb2_rdma_transform {
171 __le16 RdmaDescriptorOffset;
172 __le16 RdmaDescriptorLength;
173 __le32 Channel; /* for values see channel description in smb2 read above */
174 __le16 TransformCount;
180 #define SMB2_RDMA_TRANSFORM_TYPE_ENCRYPTION 0x0001
181 #define SMB2_RDMA_TRANSFORM_TYPE_SIGNING 0x0002
183 struct smb2_rdma_crypto_transform {
184 __le16 TransformType;
185 __le16 SignatureLength;
188 __u8 Signature[]; /* variable length */
190 /* followed by padding */
194 * SMB2 flag definitions
196 #define SMB2_FLAGS_SERVER_TO_REDIR cpu_to_le32(0x00000001)
197 #define SMB2_FLAGS_ASYNC_COMMAND cpu_to_le32(0x00000002)
198 #define SMB2_FLAGS_RELATED_OPERATIONS cpu_to_le32(0x00000004)
199 #define SMB2_FLAGS_SIGNED cpu_to_le32(0x00000008)
200 #define SMB2_FLAGS_PRIORITY_MASK cpu_to_le32(0x00000070) /* SMB3.1.1 */
201 #define SMB2_FLAGS_DFS_OPERATIONS cpu_to_le32(0x10000000)
202 #define SMB2_FLAGS_REPLAY_OPERATION cpu_to_le32(0x20000000) /* SMB3 & up */
205 * Definitions for SMB2 Protocol Data Units (network frames)
207 * See MS-SMB2.PDF specification for protocol details.
208 * The Naming convention is the lower case version of the SMB2
209 * command code name for the struct. Note that structures must be packed.
213 #define COMPOUND_FID 0xFFFFFFFFFFFFFFFFULL
215 #define SMB2_ERROR_STRUCTURE_SIZE2 cpu_to_le16(9)
217 struct smb2_err_rsp {
218 struct smb2_sync_hdr sync_hdr;
219 __le16 StructureSize;
220 __le16 Reserved; /* MBZ */
221 __le32 ByteCount; /* even if zero, at least one byte follows */
222 __u8 ErrorData[1]; /* variable length */
225 #define SYMLINK_ERROR_TAG 0x4c4d5953
227 struct smb2_symlink_err_rsp {
228 __le32 SymLinkLength;
229 __le32 SymLinkErrorTag;
231 __le16 ReparseDataLength;
232 __le16 UnparsedPathLength;
233 __le16 SubstituteNameOffset;
234 __le16 SubstituteNameLength;
235 __le16 PrintNameOffset;
236 __le16 PrintNameLength;
241 /* SMB 3.1.1 and later dialects. See MS-SMB2 section 2.2.2.1 */
242 struct smb2_error_context_rsp {
243 __le32 ErrorDataLength;
245 __u8 ErrorContextData; /* ErrorDataLength long array */
249 #define SMB2_ERROR_ID_DEFAULT 0x00000000
250 #define SMB2_ERROR_ID_SHARE_REDIRECT cpu_to_le32(0x72645253) /* "rdRS" */
252 /* Defines for Type field below (see MS-SMB2 2.2.2.2.2.1) */
253 #define MOVE_DST_IPADDR_V4 cpu_to_le32(0x00000001)
254 #define MOVE_DST_IPADDR_V6 cpu_to_le32(0x00000002)
256 struct move_dst_ipaddr {
259 __u8 address[16]; /* IPv4 followed by 12 bytes rsvd or IPv6 address */
262 struct share_redirect_error_context_rsp {
263 __le32 StructureSize;
264 __le32 NotificationType;
265 __le32 ResourceNameOffset;
266 __le32 ResourceNameLength;
270 struct move_dst_ipaddr IpAddrMoveList[];
271 /* __u8 ResourceName[] */ /* Name of share as counted Unicode string */
274 #define SMB2_CLIENT_GUID_SIZE 16
276 struct smb2_negotiate_req {
277 struct smb2_sync_hdr sync_hdr;
278 __le16 StructureSize; /* Must be 36 */
281 __le16 Reserved; /* MBZ */
283 __u8 ClientGUID[SMB2_CLIENT_GUID_SIZE];
284 /* In SMB3.02 and earlier next three were MBZ le64 ClientStartTime */
285 __le32 NegotiateContextOffset; /* SMB3.1.1 only. MBZ earlier */
286 __le16 NegotiateContextCount; /* SMB3.1.1 only. MBZ earlier */
288 __le16 Dialects[4]; /* BB expand this if autonegotiate > 4 dialects */
292 #define SMB10_PROT_ID 0x0000 /* local only, not sent on wire w/CIFS negprot */
293 #define SMB20_PROT_ID 0x0202
294 #define SMB21_PROT_ID 0x0210
295 #define SMB30_PROT_ID 0x0300
296 #define SMB302_PROT_ID 0x0302
297 #define SMB311_PROT_ID 0x0311
298 #define BAD_PROT_ID 0xFFFF
300 /* SecurityMode flags */
301 #define SMB2_NEGOTIATE_SIGNING_ENABLED 0x0001
302 #define SMB2_NEGOTIATE_SIGNING_REQUIRED 0x0002
303 #define SMB2_SEC_MODE_FLAGS_ALL 0x0003
305 /* Capabilities flags */
306 #define SMB2_GLOBAL_CAP_DFS 0x00000001
307 #define SMB2_GLOBAL_CAP_LEASING 0x00000002 /* Resp only New to SMB2.1 */
308 #define SMB2_GLOBAL_CAP_LARGE_MTU 0X00000004 /* Resp only New to SMB2.1 */
309 #define SMB2_GLOBAL_CAP_MULTI_CHANNEL 0x00000008 /* New to SMB3 */
310 #define SMB2_GLOBAL_CAP_PERSISTENT_HANDLES 0x00000010 /* New to SMB3 */
311 #define SMB2_GLOBAL_CAP_DIRECTORY_LEASING 0x00000020 /* New to SMB3 */
312 #define SMB2_GLOBAL_CAP_ENCRYPTION 0x00000040 /* New to SMB3 */
314 #define SMB2_NT_FIND 0x00100000
315 #define SMB2_LARGE_FILES 0x00200000
318 /* Negotiate Contexts - ContextTypes. See MS-SMB2 section 2.2.3.1 for details */
319 #define SMB2_PREAUTH_INTEGRITY_CAPABILITIES cpu_to_le16(1)
320 #define SMB2_ENCRYPTION_CAPABILITIES cpu_to_le16(2)
321 #define SMB2_COMPRESSION_CAPABILITIES cpu_to_le16(3)
322 #define SMB2_NETNAME_NEGOTIATE_CONTEXT_ID cpu_to_le16(5)
323 #define SMB2_TRANSPORT_CAPABILITIES cpu_to_le16(6)
324 #define SMB2_RDMA_TRANSFORM_CAPABILITIES cpu_to_le16(7)
325 #define SMB2_SIGNING_CAPABILITIES cpu_to_le16(8)
326 #define SMB2_POSIX_EXTENSIONS_AVAILABLE cpu_to_le16(0x100)
328 struct smb2_neg_context {
332 /* Followed by array of data */
335 #define SMB311_LINUX_CLIENT_SALT_SIZE 32
336 /* Hash Algorithm Types */
337 #define SMB2_PREAUTH_INTEGRITY_SHA512 cpu_to_le16(0x0001)
338 #define SMB2_PREAUTH_HASH_SIZE 64
341 * SaltLength that the server send can be zero, so the only three required
342 * fields (all __le16) end up six bytes total, so the minimum context data len
343 * in the response is six bytes which accounts for
345 * HashAlgorithmCount, SaltLength, and 1 HashAlgorithm.
347 #define MIN_PREAUTH_CTXT_DATA_LEN 6
349 struct smb2_preauth_neg_context {
350 __le16 ContextType; /* 1 */
353 __le16 HashAlgorithmCount; /* 1 */
355 __le16 HashAlgorithms; /* HashAlgorithms[0] since only one defined */
356 __u8 Salt[SMB311_LINUX_CLIENT_SALT_SIZE];
359 /* Encryption Algorithms Ciphers */
360 #define SMB2_ENCRYPTION_AES128_CCM cpu_to_le16(0x0001)
361 #define SMB2_ENCRYPTION_AES128_GCM cpu_to_le16(0x0002)
362 /* we currently do not request AES256_CCM since presumably GCM faster */
363 #define SMB2_ENCRYPTION_AES256_CCM cpu_to_le16(0x0003)
364 #define SMB2_ENCRYPTION_AES256_GCM cpu_to_le16(0x0004)
366 /* Min encrypt context data is one cipher so 2 bytes + 2 byte count field */
367 #define MIN_ENCRYPT_CTXT_DATA_LEN 4
368 struct smb2_encryption_neg_context {
369 __le16 ContextType; /* 2 */
372 /* CipherCount usally 2, but can be 3 when AES256-GCM enabled */
373 __le16 CipherCount; /* AES128-GCM and AES128-CCM by default */
377 /* See MS-SMB2 2.2.3.1.3 */
378 #define SMB3_COMPRESS_NONE cpu_to_le16(0x0000)
379 #define SMB3_COMPRESS_LZNT1 cpu_to_le16(0x0001)
380 #define SMB3_COMPRESS_LZ77 cpu_to_le16(0x0002)
381 #define SMB3_COMPRESS_LZ77_HUFF cpu_to_le16(0x0003)
382 /* Pattern scanning algorithm See MS-SMB2 3.1.4.4.1 */
383 #define SMB3_COMPRESS_PATTERN cpu_to_le16(0x0004) /* Pattern_V1 */
385 /* Compression Flags */
386 #define SMB2_COMPRESSION_CAPABILITIES_FLAG_NONE cpu_to_le32(0x00000000)
387 #define SMB2_COMPRESSION_CAPABILITIES_FLAG_CHAINED cpu_to_le32(0x00000001)
389 struct smb2_compression_capabilities_context {
390 __le16 ContextType; /* 3 */
393 __le16 CompressionAlgorithmCount;
396 __le16 CompressionAlgorithms[3];
400 * For smb2_netname_negotiate_context_id See MS-SMB2 2.2.3.1.4.
401 * Its struct simply contains NetName, an array of Unicode characters
403 struct smb2_netname_neg_context {
404 __le16 ContextType; /* 5 */
407 __le16 NetName[]; /* hostname of target converted to UCS-2 */
411 * For smb2_transport_capabilities context see MS-SMB2 2.2.3.1.5
416 #define SMB2_ACCEPT_TRANSFORM_LEVEL_SECURITY 0x00000001
418 struct smb2_transport_capabilities_context {
419 __le16 ContextType; /* 6 */
426 * For rdma transform capabilities context see MS-SMB2 2.2.3.1.6
430 /* RDMA Transform IDs */
431 #define SMB2_RDMA_TRANSFORM_NONE 0x0000
432 #define SMB2_RDMA_TRANSFORM_ENCRYPTION 0x0001
433 #define SMB2_RDMA_TRANSFORM_SIGNING 0x0002
435 struct smb2_rdma_transform_capabilities_context {
436 __le16 ContextType; /* 7 */
439 __le16 TransformCount;
442 __le16 RDMATransformIds[];
446 * For signing capabilities context see MS-SMB2 2.2.3.1.7
450 /* Signing algorithms */
451 #define SIGNING_ALG_HMAC_SHA256 0
452 #define SIGNING_ALG_AES_CMAC 1
453 #define SIGNING_ALG_AES_GMAC 2
455 struct smb2_signing_capabilities {
456 __le16 ContextType; /* 8 */
459 __le16 SigningAlgorithmCount;
460 __le16 SigningAlgorithms[];
463 #define POSIX_CTXT_DATA_LEN 16
464 struct smb2_posix_neg_context {
465 __le16 ContextType; /* 0x100 */
468 __u8 Name[16]; /* POSIX ctxt GUID 93AD25509CB411E7B42383DE968BCD7C */
471 struct smb2_negotiate_rsp {
472 struct smb2_sync_hdr sync_hdr;
473 __le16 StructureSize; /* Must be 65 */
475 __le16 DialectRevision;
476 __le16 NegotiateContextCount; /* Prior to SMB3.1.1 was Reserved & MBZ */
479 __le32 MaxTransactSize;
482 __le64 SystemTime; /* MBZ */
483 __le64 ServerStartTime;
484 __le16 SecurityBufferOffset;
485 __le16 SecurityBufferLength;
486 __le32 NegotiateContextOffset; /* Pre:SMB3.1.1 was reserved/ignored */
487 __u8 Buffer[1]; /* variable length GSS security buffer */
491 #define SMB2_SESSION_REQ_FLAG_BINDING 0x01
492 #define SMB2_SESSION_REQ_FLAG_ENCRYPT_DATA 0x04
494 struct smb2_sess_setup_req {
495 struct smb2_sync_hdr sync_hdr;
496 __le16 StructureSize; /* Must be 25 */
501 __le16 SecurityBufferOffset;
502 __le16 SecurityBufferLength;
503 __u64 PreviousSessionId;
504 __u8 Buffer[1]; /* variable length GSS security buffer */
507 /* Currently defined SessionFlags */
508 #define SMB2_SESSION_FLAG_IS_GUEST 0x0001
509 #define SMB2_SESSION_FLAG_IS_NULL 0x0002
510 #define SMB2_SESSION_FLAG_ENCRYPT_DATA 0x0004
511 struct smb2_sess_setup_rsp {
512 struct smb2_sync_hdr sync_hdr;
513 __le16 StructureSize; /* Must be 9 */
515 __le16 SecurityBufferOffset;
516 __le16 SecurityBufferLength;
517 __u8 Buffer[1]; /* variable length GSS security buffer */
520 struct smb2_logoff_req {
521 struct smb2_sync_hdr sync_hdr;
522 __le16 StructureSize; /* Must be 4 */
526 struct smb2_logoff_rsp {
527 struct smb2_sync_hdr sync_hdr;
528 __le16 StructureSize; /* Must be 4 */
532 /* Flags/Reserved for SMB3.1.1 */
533 #define SMB2_TREE_CONNECT_FLAG_CLUSTER_RECONNECT cpu_to_le16(0x0001)
534 #define SMB2_TREE_CONNECT_FLAG_REDIRECT_TO_OWNER cpu_to_le16(0x0002)
535 #define SMB2_TREE_CONNECT_FLAG_EXTENSION_PRESENT cpu_to_le16(0x0004)
537 struct smb2_tree_connect_req {
538 struct smb2_sync_hdr sync_hdr;
539 __le16 StructureSize; /* Must be 9 */
540 __le16 Flags; /* Reserved MBZ for dialects prior to SMB3.1.1 */
543 __u8 Buffer[1]; /* variable length */
546 /* See MS-SMB2 section 2.2.9.2 */
548 #define SMB2_RESERVED_TREE_CONNECT_CONTEXT_ID 0x0000
549 #define SMB2_REMOTED_IDENTITY_TREE_CONNECT_CONTEXT_ID cpu_to_le16(0x0001)
551 struct tree_connect_contexts {
558 /* Remoted identity tree connect context structures - see MS-SMB2 2.2.9.2.1 */
559 struct smb3_blob_data {
564 /* Valid values for Attr */
565 #define SE_GROUP_MANDATORY 0x00000001
566 #define SE_GROUP_ENABLED_BY_DEFAULT 0x00000002
567 #define SE_GROUP_ENABLED 0x00000004
568 #define SE_GROUP_OWNER 0x00000008
569 #define SE_GROUP_USE_FOR_DENY_ONLY 0x00000010
570 #define SE_GROUP_INTEGRITY 0x00000020
571 #define SE_GROUP_INTEGRITY_ENABLED 0x00000040
572 #define SE_GROUP_RESOURCE 0x20000000
573 #define SE_GROUP_LOGON_ID 0xC0000000
575 /* struct sid_attr_data is SidData array in BlobData format then le32 Attr */
577 struct sid_array_data {
579 /* SidAttrList - array of sid_attr_data structs */
582 struct luid_attr_data {
587 * struct privilege_data is the same as BLOB_DATA - see MS-SMB2 2.2.9.2.1.5
588 * but with size of LUID_ATTR_DATA struct and BlobData set to LUID_ATTR DATA
591 struct privilege_array_data {
592 __le16 PrivilegeCount;
593 /* array of privilege_data structs */
596 struct remoted_identity_tcon_context {
597 __le16 TicketType; /* must be 0x0001 */
598 __le16 TicketSize; /* total size of this struct */
599 __le16 User; /* offset to SID_ATTR_DATA struct with user info */
600 __le16 UserName; /* offset to null terminated Unicode username string */
601 __le16 Domain; /* offset to null terminated Unicode domain name */
602 __le16 Groups; /* offset to SID_ARRAY_DATA struct with group info */
603 __le16 RestrictedGroups; /* similar to above */
604 __le16 Privileges; /* offset to PRIVILEGE_ARRAY_DATA struct */
605 __le16 PrimaryGroup; /* offset to SID_ARRAY_DATA struct */
606 __le16 Owner; /* offset to BLOB_DATA struct */
607 __le16 DefaultDacl; /* offset to BLOB_DATA struct */
608 __le16 DeviceGroups; /* offset to SID_ARRAY_DATA struct */
609 __le16 UserClaims; /* offset to BLOB_DATA struct */
610 __le16 DeviceClaims; /* offset to BLOB_DATA struct */
611 __u8 TicketInfo[]; /* variable length buf - remoted identity data */
614 struct smb2_tree_connect_req_extension {
615 __le32 TreeConnectContextOffset;
616 __le16 TreeConnectContextCount;
618 __u8 PathName[]; /* variable sized array */
619 /* followed by array of TreeConnectContexts */
622 struct smb2_tree_connect_rsp {
623 struct smb2_sync_hdr sync_hdr;
624 __le16 StructureSize; /* Must be 16 */
625 __u8 ShareType; /* see below */
627 __le32 ShareFlags; /* see below */
628 __le32 Capabilities; /* see below */
629 __le32 MaximalAccess;
632 /* Possible ShareType values */
633 #define SMB2_SHARE_TYPE_DISK 0x01
634 #define SMB2_SHARE_TYPE_PIPE 0x02
635 #define SMB2_SHARE_TYPE_PRINT 0x03
638 * Possible ShareFlags - exactly one and only one of the first 4 caching flags
639 * must be set (any of the remaining, SHI1005, flags may be set individually
642 #define SMB2_SHAREFLAG_MANUAL_CACHING 0x00000000
643 #define SMB2_SHAREFLAG_AUTO_CACHING 0x00000010
644 #define SMB2_SHAREFLAG_VDO_CACHING 0x00000020
645 #define SMB2_SHAREFLAG_NO_CACHING 0x00000030
646 #define SHI1005_FLAGS_DFS 0x00000001
647 #define SHI1005_FLAGS_DFS_ROOT 0x00000002
648 #define SHI1005_FLAGS_RESTRICT_EXCLUSIVE_OPENS 0x00000100
649 #define SHI1005_FLAGS_FORCE_SHARED_DELETE 0x00000200
650 #define SHI1005_FLAGS_ALLOW_NAMESPACE_CACHING 0x00000400
651 #define SHI1005_FLAGS_ACCESS_BASED_DIRECTORY_ENUM 0x00000800
652 #define SHI1005_FLAGS_FORCE_LEVELII_OPLOCK 0x00001000
653 #define SHI1005_FLAGS_ENABLE_HASH_V1 0x00002000
654 #define SHI1005_FLAGS_ENABLE_HASH_V2 0x00004000
655 #define SHI1005_FLAGS_ENCRYPT_DATA 0x00008000
656 #define SMB2_SHAREFLAG_IDENTITY_REMOTING 0x00040000 /* 3.1.1 */
657 #define SMB2_SHAREFLAG_COMPRESS_DATA 0x00100000 /* 3.1.1 */
658 #define SHI1005_FLAGS_ALL 0x0014FF33
660 /* Possible share capabilities */
661 #define SMB2_SHARE_CAP_DFS cpu_to_le32(0x00000008) /* all dialects */
662 #define SMB2_SHARE_CAP_CONTINUOUS_AVAILABILITY cpu_to_le32(0x00000010) /* 3.0 */
663 #define SMB2_SHARE_CAP_SCALEOUT cpu_to_le32(0x00000020) /* 3.0 */
664 #define SMB2_SHARE_CAP_CLUSTER cpu_to_le32(0x00000040) /* 3.0 */
665 #define SMB2_SHARE_CAP_ASYMMETRIC cpu_to_le32(0x00000080) /* 3.02 */
666 #define SMB2_SHARE_CAP_REDIRECT_TO_OWNER cpu_to_le32(0x00000100) /* 3.1.1 */
668 struct smb2_tree_disconnect_req {
669 struct smb2_sync_hdr sync_hdr;
670 __le16 StructureSize; /* Must be 4 */
674 struct smb2_tree_disconnect_rsp {
675 struct smb2_sync_hdr sync_hdr;
676 __le16 StructureSize; /* Must be 4 */
680 /* File Attrubutes */
681 #define FILE_ATTRIBUTE_READONLY 0x00000001
682 #define FILE_ATTRIBUTE_HIDDEN 0x00000002
683 #define FILE_ATTRIBUTE_SYSTEM 0x00000004
684 #define FILE_ATTRIBUTE_DIRECTORY 0x00000010
685 #define FILE_ATTRIBUTE_ARCHIVE 0x00000020
686 #define FILE_ATTRIBUTE_NORMAL 0x00000080
687 #define FILE_ATTRIBUTE_TEMPORARY 0x00000100
688 #define FILE_ATTRIBUTE_SPARSE_FILE 0x00000200
689 #define FILE_ATTRIBUTE_REPARSE_POINT 0x00000400
690 #define FILE_ATTRIBUTE_COMPRESSED 0x00000800
691 #define FILE_ATTRIBUTE_OFFLINE 0x00001000
692 #define FILE_ATTRIBUTE_NOT_CONTENT_INDEXED 0x00002000
693 #define FILE_ATTRIBUTE_ENCRYPTED 0x00004000
694 #define FILE_ATTRIBUTE_INTEGRITY_STREAM 0x00008000
695 #define FILE_ATTRIBUTE_NO_SCRUB_DATA 0x00020000
698 #define SMB2_OPLOCK_LEVEL_NONE 0x00
699 #define SMB2_OPLOCK_LEVEL_II 0x01
700 #define SMB2_OPLOCK_LEVEL_EXCLUSIVE 0x08
701 #define SMB2_OPLOCK_LEVEL_BATCH 0x09
702 #define SMB2_OPLOCK_LEVEL_LEASE 0xFF
703 /* Non-spec internal type */
704 #define SMB2_OPLOCK_LEVEL_NOCHANGE 0x99
706 /* Desired Access Flags */
707 #define FILE_READ_DATA_LE cpu_to_le32(0x00000001)
708 #define FILE_WRITE_DATA_LE cpu_to_le32(0x00000002)
709 #define FILE_APPEND_DATA_LE cpu_to_le32(0x00000004)
710 #define FILE_READ_EA_LE cpu_to_le32(0x00000008)
711 #define FILE_WRITE_EA_LE cpu_to_le32(0x00000010)
712 #define FILE_EXECUTE_LE cpu_to_le32(0x00000020)
713 #define FILE_READ_ATTRIBUTES_LE cpu_to_le32(0x00000080)
714 #define FILE_WRITE_ATTRIBUTES_LE cpu_to_le32(0x00000100)
715 #define FILE_DELETE_LE cpu_to_le32(0x00010000)
716 #define FILE_READ_CONTROL_LE cpu_to_le32(0x00020000)
717 #define FILE_WRITE_DAC_LE cpu_to_le32(0x00040000)
718 #define FILE_WRITE_OWNER_LE cpu_to_le32(0x00080000)
719 #define FILE_SYNCHRONIZE_LE cpu_to_le32(0x00100000)
720 #define FILE_ACCESS_SYSTEM_SECURITY_LE cpu_to_le32(0x01000000)
721 #define FILE_MAXIMAL_ACCESS_LE cpu_to_le32(0x02000000)
722 #define FILE_GENERIC_ALL_LE cpu_to_le32(0x10000000)
723 #define FILE_GENERIC_EXECUTE_LE cpu_to_le32(0x20000000)
724 #define FILE_GENERIC_WRITE_LE cpu_to_le32(0x40000000)
725 #define FILE_GENERIC_READ_LE cpu_to_le32(0x80000000)
727 /* ShareAccess Flags */
728 #define FILE_SHARE_READ_LE cpu_to_le32(0x00000001)
729 #define FILE_SHARE_WRITE_LE cpu_to_le32(0x00000002)
730 #define FILE_SHARE_DELETE_LE cpu_to_le32(0x00000004)
731 #define FILE_SHARE_ALL_LE cpu_to_le32(0x00000007)
733 /* CreateDisposition Flags */
734 #define FILE_SUPERSEDE_LE cpu_to_le32(0x00000000)
735 #define FILE_OPEN_LE cpu_to_le32(0x00000001)
736 #define FILE_CREATE_LE cpu_to_le32(0x00000002)
737 #define FILE_OPEN_IF_LE cpu_to_le32(0x00000003)
738 #define FILE_OVERWRITE_LE cpu_to_le32(0x00000004)
739 #define FILE_OVERWRITE_IF_LE cpu_to_le32(0x00000005)
741 /* CreateOptions Flags */
742 #define FILE_DIRECTORY_FILE_LE cpu_to_le32(0x00000001)
743 /* same as #define CREATE_NOT_FILE_LE cpu_to_le32(0x00000001) */
744 #define FILE_WRITE_THROUGH_LE cpu_to_le32(0x00000002)
745 #define FILE_SEQUENTIAL_ONLY_LE cpu_to_le32(0x00000004)
746 #define FILE_NO_INTERMEDIATE_BUFFERRING_LE cpu_to_le32(0x00000008)
747 #define FILE_SYNCHRONOUS_IO_ALERT_LE cpu_to_le32(0x00000010)
748 #define FILE_SYNCHRONOUS_IO_NON_ALERT_LE cpu_to_le32(0x00000020)
749 #define FILE_NON_DIRECTORY_FILE_LE cpu_to_le32(0x00000040)
750 #define FILE_COMPLETE_IF_OPLOCKED_LE cpu_to_le32(0x00000100)
751 #define FILE_NO_EA_KNOWLEDGE_LE cpu_to_le32(0x00000200)
752 #define FILE_RANDOM_ACCESS_LE cpu_to_le32(0x00000800)
753 #define FILE_DELETE_ON_CLOSE_LE cpu_to_le32(0x00001000)
754 #define FILE_OPEN_BY_FILE_ID_LE cpu_to_le32(0x00002000)
755 #define FILE_OPEN_FOR_BACKUP_INTENT_LE cpu_to_le32(0x00004000)
756 #define FILE_NO_COMPRESSION_LE cpu_to_le32(0x00008000)
757 #define FILE_RESERVE_OPFILTER_LE cpu_to_le32(0x00100000)
758 #define FILE_OPEN_REPARSE_POINT_LE cpu_to_le32(0x00200000)
759 #define FILE_OPEN_NO_RECALL_LE cpu_to_le32(0x00400000)
760 #define FILE_OPEN_FOR_FREE_SPACE_QUERY_LE cpu_to_le32(0x00800000)
762 #define FILE_READ_RIGHTS_LE (FILE_READ_DATA_LE | FILE_READ_EA_LE \
763 | FILE_READ_ATTRIBUTES_LE)
764 #define FILE_WRITE_RIGHTS_LE (FILE_WRITE_DATA_LE | FILE_APPEND_DATA_LE \
765 | FILE_WRITE_EA_LE | FILE_WRITE_ATTRIBUTES_LE)
766 #define FILE_EXEC_RIGHTS_LE (FILE_EXECUTE_LE)
768 /* Impersonation Levels. See MS-WPO section 9.7 and MSDN-IMPERS */
769 #define IL_ANONYMOUS cpu_to_le32(0x00000000)
770 #define IL_IDENTIFICATION cpu_to_le32(0x00000001)
771 #define IL_IMPERSONATION cpu_to_le32(0x00000002)
772 #define IL_DELEGATE cpu_to_le32(0x00000003)
774 /* Create Context Values */
775 #define SMB2_CREATE_EA_BUFFER "ExtA" /* extended attributes */
776 #define SMB2_CREATE_SD_BUFFER "SecD" /* security descriptor */
777 #define SMB2_CREATE_DURABLE_HANDLE_REQUEST "DHnQ"
778 #define SMB2_CREATE_DURABLE_HANDLE_RECONNECT "DHnC"
779 #define SMB2_CREATE_ALLOCATION_SIZE "AISi"
780 #define SMB2_CREATE_QUERY_MAXIMAL_ACCESS_REQUEST "MxAc"
781 #define SMB2_CREATE_TIMEWARP_REQUEST "TWrp"
782 #define SMB2_CREATE_QUERY_ON_DISK_ID "QFid"
783 #define SMB2_CREATE_REQUEST_LEASE "RqLs"
784 #define SMB2_CREATE_DURABLE_HANDLE_REQUEST_V2 "DH2Q"
785 #define SMB2_CREATE_DURABLE_HANDLE_RECONNECT_V2 "DH2C"
786 #define SMB2_CREATE_APP_INSTANCE_ID 0x45BCA66AEFA7F74A9008FA462E144D74
787 #define SMB2_CREATE_APP_INSTANCE_VERSION 0xB982D0B73B56074FA07B524A8116A010
788 #define SVHDX_OPEN_DEVICE_CONTEX 0x9CCBCF9E04C1E643980E158DA1F6EC83
789 #define SMB2_CREATE_TAG_POSIX 0x93AD25509CB411E7B42383DE968BCD7C
791 /* Flag (SMB3 open response) values */
792 #define SMB2_CREATE_FLAG_REPARSEPOINT 0x01
795 * Maximum number of iovs we need for an open/create request.
796 * [0] : struct smb2_create_req
798 * [2] : lease context
799 * [3] : durable context
800 * [4] : posix context
801 * [5] : time warp context
802 * [6] : query id context
803 * [7] : compound padding
805 #define SMB2_CREATE_IOV_SIZE 8
807 struct smb2_create_req {
808 struct smb2_sync_hdr sync_hdr;
809 __le16 StructureSize; /* Must be 57 */
811 __u8 RequestedOplockLevel;
812 __le32 ImpersonationLevel;
813 __le64 SmbCreateFlags;
815 __le32 DesiredAccess;
816 __le32 FileAttributes;
818 __le32 CreateDisposition;
819 __le32 CreateOptions;
822 __le32 CreateContextsOffset;
823 __le32 CreateContextsLength;
828 * Maximum size of a SMB2_CREATE response is 64 (smb2 header) +
829 * 88 (fixed part of create response) + 520 (path) + 208 (contexts) +
830 * 2 bytes of padding.
832 #define MAX_SMB2_CREATE_RESPONSE_SIZE 880
834 struct smb2_create_rsp {
835 struct smb2_sync_hdr sync_hdr;
836 __le16 StructureSize; /* Must be 89 */
838 __u8 Flag; /* 0x01 if reparse point */
841 __le64 LastAccessTime;
842 __le64 LastWriteTime;
844 __le64 AllocationSize;
846 __le32 FileAttributes;
848 __u64 PersistentFileId; /* opaque endianness */
849 __u64 VolatileFileId; /* opaque endianness */
850 __le32 CreateContextsOffset;
851 __le32 CreateContextsLength;
855 struct create_context {
865 #define SMB2_LEASE_READ_CACHING_HE 0x01
866 #define SMB2_LEASE_HANDLE_CACHING_HE 0x02
867 #define SMB2_LEASE_WRITE_CACHING_HE 0x04
869 #define SMB2_LEASE_NONE cpu_to_le32(0x00)
870 #define SMB2_LEASE_READ_CACHING cpu_to_le32(0x01)
871 #define SMB2_LEASE_HANDLE_CACHING cpu_to_le32(0x02)
872 #define SMB2_LEASE_WRITE_CACHING cpu_to_le32(0x04)
874 #define SMB2_LEASE_FLAG_BREAK_IN_PROGRESS cpu_to_le32(0x00000002)
875 #define SMB2_LEASE_FLAG_PARENT_LEASE_KEY_SET cpu_to_le32(0x00000004)
877 #define SMB2_LEASE_KEY_SIZE 16
879 struct lease_context {
880 u8 LeaseKey[SMB2_LEASE_KEY_SIZE];
883 __le64 LeaseDuration;
886 struct lease_context_v2 {
887 u8 LeaseKey[SMB2_LEASE_KEY_SIZE];
890 __le64 LeaseDuration;
891 __le64 ParentLeaseKeyLow;
892 __le64 ParentLeaseKeyHigh;
897 struct create_lease {
898 struct create_context ccontext;
900 struct lease_context lcontext;
903 struct create_lease_v2 {
904 struct create_context ccontext;
906 struct lease_context_v2 lcontext;
910 struct create_durable {
911 struct create_context ccontext;
916 __u64 PersistentFileId;
917 __u64 VolatileFileId;
922 struct create_posix {
923 struct create_context ccontext;
929 /* See MS-SMB2 2.2.13.2.11 */
931 #define SMB2_DHANDLE_FLAG_PERSISTENT 0x00000002
932 struct durable_context_v2 {
939 struct create_durable_v2 {
940 struct create_context ccontext;
942 struct durable_context_v2 dcontext;
945 /* See MS-SMB2 2.2.13.2.12 */
946 struct durable_reconnect_context_v2 {
948 __u64 PersistentFileId;
949 __u64 VolatileFileId;
952 __le32 Flags; /* see above DHANDLE_FLAG_PERSISTENT */
955 /* See MS-SMB2 2.2.14.2.9 */
956 struct create_on_disk_id {
957 struct create_context ccontext;
964 /* See MS-SMB2 2.2.14.2.12 */
965 struct durable_reconnect_context_v2_rsp {
967 __le32 Flags; /* see above DHANDLE_FLAG_PERSISTENT */
970 struct create_durable_handle_reconnect_v2 {
971 struct create_context ccontext;
973 struct durable_reconnect_context_v2 dcontext;
977 /* See MS-SMB2 2.2.13.2.5 */
978 struct crt_twarp_ctxt {
979 struct create_context ccontext;
985 /* See MS-SMB2 2.2.13.2.9 */
986 struct crt_query_id_ctxt {
987 struct create_context ccontext;
992 struct create_context ccontext;
998 #define COPY_CHUNK_RES_KEY_SIZE 24
999 struct resume_key_req {
1000 char ResumeKey[COPY_CHUNK_RES_KEY_SIZE];
1001 __le32 ContextLength; /* MBZ */
1002 char Context[]; /* ignored, Windows sets to 4 bytes of zero */
1005 /* this goes in the ioctl buffer when doing a copychunk request */
1006 struct copychunk_ioctl {
1007 char SourceKey[COPY_CHUNK_RES_KEY_SIZE];
1008 __le32 ChunkCount; /* we are only sending 1 */
1010 /* array will only be one chunk long for us */
1011 __le64 SourceOffset;
1012 __le64 TargetOffset;
1013 __le32 Length; /* how many bytes to copy */
1017 /* this goes in the ioctl buffer when doing FSCTL_SET_ZERO_DATA */
1018 struct file_zero_data_information {
1020 __le64 BeyondFinalZero;
1023 struct copychunk_ioctl_rsp {
1024 __le32 ChunksWritten;
1025 __le32 ChunkBytesWritten;
1026 __le32 TotalBytesWritten;
1029 /* See MS-FSCC 2.3.29 and 2.3.30 */
1030 struct get_retrieval_pointer_count_req {
1031 __le64 StartingVcn; /* virtual cluster number (signed) */
1034 struct get_retrieval_pointer_count_rsp {
1039 * See MS-FSCC 2.3.33 and 2.3.34
1040 * request is the same as get_retrieval_point_count_req struct above
1042 struct smb3_extents {
1044 __le64 Lcn; /* logical cluster number */
1047 struct get_retrieval_pointers_refcount_rsp {
1051 struct smb3_extents extents[];
1054 struct fsctl_set_integrity_information_req {
1055 __le16 ChecksumAlgorithm;
1060 struct fsctl_get_integrity_information_rsp {
1061 __le16 ChecksumAlgorithm;
1064 __le32 ChecksumChunkSizeInBytes;
1065 __le32 ClusterSizeInBytes;
1068 struct file_allocated_range_buffer {
1073 /* Integrity ChecksumAlgorithm choices for above */
1074 #define CHECKSUM_TYPE_NONE 0x0000
1075 #define CHECKSUM_TYPE_CRC64 0x0002
1076 #define CHECKSUM_TYPE_UNCHANGED 0xFFFF /* set only */
1078 /* Integrity flags for above */
1079 #define FSCTL_INTEGRITY_FLAG_CHECKSUM_ENFORCEMENT_OFF 0x00000001
1081 /* Reparse structures - see MS-FSCC 2.1.2 */
1083 /* struct fsctl_reparse_info_req is empty, only response structs (see below) */
1085 struct reparse_data_buffer {
1087 __le16 ReparseDataLength;
1089 __u8 DataBuffer[]; /* Variable Length */
1092 struct reparse_guid_data_buffer {
1094 __le16 ReparseDataLength;
1096 __u8 ReparseGuid[16];
1097 __u8 DataBuffer[]; /* Variable Length */
1100 struct reparse_mount_point_data_buffer {
1102 __le16 ReparseDataLength;
1104 __le16 SubstituteNameOffset;
1105 __le16 SubstituteNameLength;
1106 __le16 PrintNameOffset;
1107 __le16 PrintNameLength;
1108 __u8 PathBuffer[]; /* Variable Length */
1111 #define SYMLINK_FLAG_RELATIVE 0x00000001
1113 struct reparse_symlink_data_buffer {
1115 __le16 ReparseDataLength;
1117 __le16 SubstituteNameOffset;
1118 __le16 SubstituteNameLength;
1119 __le16 PrintNameOffset;
1120 __le16 PrintNameLength;
1122 __u8 PathBuffer[]; /* Variable Length */
1125 /* See MS-FSCC 2.1.2.6 and cifspdu.h for struct reparse_posix_data */
1128 /* See MS-DFSC 2.2.2 */
1129 struct fsctl_get_dfs_referral_req {
1130 __le16 MaxReferralLevel;
1131 __u8 RequestFileName[];
1134 /* DFS response is struct get_dfs_refer_rsp */
1136 /* See MS-SMB2 2.2.31.3 */
1137 struct network_resiliency_req {
1141 /* There is no buffer for the response ie no struct network_resiliency_rsp */
1144 struct validate_negotiate_info_req {
1145 __le32 Capabilities;
1146 __u8 Guid[SMB2_CLIENT_GUID_SIZE];
1147 __le16 SecurityMode;
1148 __le16 DialectCount;
1149 __le16 Dialects[4]; /* BB expand this if autonegotiate > 4 dialects */
1152 struct validate_negotiate_info_rsp {
1153 __le32 Capabilities;
1154 __u8 Guid[SMB2_CLIENT_GUID_SIZE];
1155 __le16 SecurityMode;
1156 __le16 Dialect; /* Dialect in use for the connection */
1159 #define RSS_CAPABLE cpu_to_le32(0x00000001)
1160 #define RDMA_CAPABLE cpu_to_le32(0x00000002)
1162 #define INTERNETWORK cpu_to_le16(0x0002)
1163 #define INTERNETWORKV6 cpu_to_le16(0x0017)
1165 struct network_interface_info_ioctl_rsp {
1166 __le32 Next; /* next interface. zero if this is last one */
1168 __le32 Capability; /* RSS or RDMA Capable */
1175 struct iface_info_ipv4 {
1181 struct iface_info_ipv6 {
1184 __u8 IPv6Address[16];
1188 #define NO_FILE_ID 0xFFFFFFFFFFFFFFFFULL /* general ioctls to srv not to file */
1190 struct compress_ioctl {
1191 __le16 CompressionState; /* See cifspdu.h for possible flag values */
1194 struct duplicate_extents_to_file {
1195 __u64 PersistentFileHandle; /* source file handle, opaque endianness */
1196 __u64 VolatileFileHandle;
1197 __le64 SourceFileOffset;
1198 __le64 TargetFileOffset;
1199 __le64 ByteCount; /* Bytes to be copied */
1203 * Maximum number of iovs we need for an ioctl request.
1204 * [0] : struct smb2_ioctl_req
1207 #define SMB2_IOCTL_IOV_SIZE 2
1209 struct smb2_ioctl_req {
1210 struct smb2_sync_hdr sync_hdr;
1211 __le16 StructureSize; /* Must be 57 */
1214 __u64 PersistentFileId; /* opaque endianness */
1215 __u64 VolatileFileId; /* opaque endianness */
1218 __le32 MaxInputResponse;
1219 __le32 OutputOffset;
1221 __le32 MaxOutputResponse;
1227 struct smb2_ioctl_rsp {
1228 struct smb2_sync_hdr sync_hdr;
1229 __le16 StructureSize; /* Must be 57 */
1232 __u64 PersistentFileId; /* opaque endianness */
1233 __u64 VolatileFileId; /* opaque endianness */
1236 __le32 OutputOffset;
1240 /* char * buffer[] */
1243 /* Currently defined values for close flags */
1244 #define SMB2_CLOSE_FLAG_POSTQUERY_ATTRIB cpu_to_le16(0x0001)
1245 struct smb2_close_req {
1246 struct smb2_sync_hdr sync_hdr;
1247 __le16 StructureSize; /* Must be 24 */
1250 __u64 PersistentFileId; /* opaque endianness */
1251 __u64 VolatileFileId; /* opaque endianness */
1255 * Maximum size of a SMB2_CLOSE response is 64 (smb2 header) + 60 (data)
1257 #define MAX_SMB2_CLOSE_RESPONSE_SIZE 124
1259 struct smb2_close_rsp {
1260 struct smb2_sync_hdr sync_hdr;
1261 __le16 StructureSize; /* 60 */
1264 __le64 CreationTime;
1265 __le64 LastAccessTime;
1266 __le64 LastWriteTime;
1268 __le64 AllocationSize; /* Beginning of FILE_STANDARD_INFO equivalent */
1273 struct smb2_flush_req {
1274 struct smb2_sync_hdr sync_hdr;
1275 __le16 StructureSize; /* Must be 24 */
1278 __u64 PersistentFileId; /* opaque endianness */
1279 __u64 VolatileFileId; /* opaque endianness */
1282 struct smb2_flush_rsp {
1283 struct smb2_sync_hdr sync_hdr;
1284 __le16 StructureSize;
1288 /* For read request Flags field below, following flag is defined for SMB3.02 */
1289 #define SMB2_READFLAG_READ_UNBUFFERED 0x01
1290 #define SMB2_READFLAG_REQUEST_COMPRESSED 0x02 /* See MS-SMB2 2.2.19 */
1292 /* Channel field for read and write: exactly one of following flags can be set*/
1293 #define SMB2_CHANNEL_NONE cpu_to_le32(0x00000000)
1294 #define SMB2_CHANNEL_RDMA_V1 cpu_to_le32(0x00000001) /* SMB3 or later */
1295 #define SMB2_CHANNEL_RDMA_V1_INVALIDATE cpu_to_le32(0x00000002) /* >= SMB3.02 */
1296 #define SMB2_CHANNEL_RDMA_TRANSFORM cpu_to_le32(0x00000003) /* >= SMB3.02, only used on write */
1298 /* SMB2 read request without RFC1001 length at the beginning */
1299 struct smb2_read_plain_req {
1300 struct smb2_sync_hdr sync_hdr;
1301 __le16 StructureSize; /* Must be 49 */
1302 __u8 Padding; /* offset from start of SMB2 header to place read */
1303 __u8 Flags; /* MBZ unless SMB3.02 or later */
1306 __u64 PersistentFileId; /* opaque endianness */
1307 __u64 VolatileFileId; /* opaque endianness */
1308 __le32 MinimumCount;
1309 __le32 Channel; /* MBZ except for SMB3 or later */
1310 __le32 RemainingBytes;
1311 __le16 ReadChannelInfoOffset;
1312 __le16 ReadChannelInfoLength;
1317 #define SMB2_READFLAG_RESPONSE_NONE 0x00000000
1318 #define SMB2_READFLAG_RESPONSE_RDMA_TRANSFORM 0x00000001
1320 struct smb2_read_rsp {
1321 struct smb2_sync_hdr sync_hdr;
1322 __le16 StructureSize; /* Must be 17 */
1326 __le32 DataRemaining;
1331 /* For write request Flags field below the following flags are defined: */
1332 #define SMB2_WRITEFLAG_WRITE_THROUGH 0x00000001 /* SMB2.1 or later */
1333 #define SMB2_WRITEFLAG_WRITE_UNBUFFERED 0x00000002 /* SMB3.02 or later */
1335 struct smb2_write_req {
1336 struct smb2_sync_hdr sync_hdr;
1337 __le16 StructureSize; /* Must be 49 */
1338 __le16 DataOffset; /* offset from start of SMB2 header to write data */
1341 __u64 PersistentFileId; /* opaque endianness */
1342 __u64 VolatileFileId; /* opaque endianness */
1343 __le32 Channel; /* MBZ unless SMB3.02 or later */
1344 __le32 RemainingBytes;
1345 __le16 WriteChannelInfoOffset;
1346 __le16 WriteChannelInfoLength;
1351 struct smb2_write_rsp {
1352 struct smb2_sync_hdr sync_hdr;
1353 __le16 StructureSize; /* Must be 17 */
1357 __le32 DataRemaining;
1363 #define SMB2_WATCH_TREE 0x0001
1365 /* notify completion filter flags. See MS-FSCC 2.6 and MS-SMB2 2.2.35 */
1366 #define FILE_NOTIFY_CHANGE_FILE_NAME 0x00000001
1367 #define FILE_NOTIFY_CHANGE_DIR_NAME 0x00000002
1368 #define FILE_NOTIFY_CHANGE_ATTRIBUTES 0x00000004
1369 #define FILE_NOTIFY_CHANGE_SIZE 0x00000008
1370 #define FILE_NOTIFY_CHANGE_LAST_WRITE 0x00000010
1371 #define FILE_NOTIFY_CHANGE_LAST_ACCESS 0x00000020
1372 #define FILE_NOTIFY_CHANGE_CREATION 0x00000040
1373 #define FILE_NOTIFY_CHANGE_EA 0x00000080
1374 #define FILE_NOTIFY_CHANGE_SECURITY 0x00000100
1375 #define FILE_NOTIFY_CHANGE_STREAM_NAME 0x00000200
1376 #define FILE_NOTIFY_CHANGE_STREAM_SIZE 0x00000400
1377 #define FILE_NOTIFY_CHANGE_STREAM_WRITE 0x00000800
1379 struct smb2_change_notify_req {
1380 struct smb2_sync_hdr sync_hdr;
1381 __le16 StructureSize;
1383 __le32 OutputBufferLength;
1384 __u64 PersistentFileId; /* opaque endianness */
1385 __u64 VolatileFileId; /* opaque endianness */
1386 __le32 CompletionFilter;
1390 struct smb2_change_notify_rsp {
1391 struct smb2_sync_hdr sync_hdr;
1392 __le16 StructureSize; /* Must be 9 */
1393 __le16 OutputBufferOffset;
1394 __le32 OutputBufferLength;
1395 __u8 Buffer[1]; /* array of file notify structs */
1398 #define SMB2_LOCKFLAG_SHARED_LOCK 0x0001
1399 #define SMB2_LOCKFLAG_EXCLUSIVE_LOCK 0x0002
1400 #define SMB2_LOCKFLAG_UNLOCK 0x0004
1401 #define SMB2_LOCKFLAG_FAIL_IMMEDIATELY 0x0010
1403 struct smb2_lock_element {
1410 struct smb2_lock_req {
1411 struct smb2_sync_hdr sync_hdr;
1412 __le16 StructureSize; /* Must be 48 */
1415 * The least significant four bits are the index, the other 28 bits are
1416 * the lock sequence number (0 to 64). See MS-SMB2 2.2.26
1418 __le32 LockSequenceNumber;
1419 __u64 PersistentFileId; /* opaque endianness */
1420 __u64 VolatileFileId; /* opaque endianness */
1421 /* Followed by at least one */
1422 struct smb2_lock_element locks[1];
1425 struct smb2_lock_rsp {
1426 struct smb2_sync_hdr sync_hdr;
1427 __le16 StructureSize; /* Must be 4 */
1431 struct smb2_echo_req {
1432 struct smb2_sync_hdr sync_hdr;
1433 __le16 StructureSize; /* Must be 4 */
1437 struct smb2_echo_rsp {
1438 struct smb2_sync_hdr sync_hdr;
1439 __le16 StructureSize; /* Must be 4 */
1443 /* search (query_directory) Flags field */
1444 #define SMB2_RESTART_SCANS 0x01
1445 #define SMB2_RETURN_SINGLE_ENTRY 0x02
1446 #define SMB2_INDEX_SPECIFIED 0x04
1447 #define SMB2_REOPEN 0x10
1449 #define SMB2_QUERY_DIRECTORY_IOV_SIZE 2
1452 * Valid FileInformation classes.
1454 * Note that these are a subset of the (file) QUERY_INFO levels defined
1455 * later in this file (but since QUERY_DIRECTORY uses equivalent numbers
1456 * we do not redefine them here)
1458 * FileDirectoryInfomation 0x01
1459 * FileFullDirectoryInformation 0x02
1460 * FileIdFullDirectoryInformation 0x26
1461 * FileBothDirectoryInformation 0x03
1462 * FileIdBothDirectoryInformation 0x25
1463 * FileNamesInformation 0x0C
1464 * FileIdExtdDirectoryInformation 0x3C
1467 struct smb2_query_directory_req {
1468 struct smb2_sync_hdr sync_hdr;
1469 __le16 StructureSize; /* Must be 33 */
1470 __u8 FileInformationClass;
1473 __u64 PersistentFileId; /* opaque endianness */
1474 __u64 VolatileFileId; /* opaque endianness */
1475 __le16 FileNameOffset;
1476 __le16 FileNameLength;
1477 __le32 OutputBufferLength;
1481 struct smb2_query_directory_rsp {
1482 struct smb2_sync_hdr sync_hdr;
1483 __le16 StructureSize; /* Must be 9 */
1484 __le16 OutputBufferOffset;
1485 __le32 OutputBufferLength;
1489 /* Possible InfoType values */
1490 #define SMB2_O_INFO_FILE 0x01
1491 #define SMB2_O_INFO_FILESYSTEM 0x02
1492 #define SMB2_O_INFO_SECURITY 0x03
1493 #define SMB2_O_INFO_QUOTA 0x04
1495 /* Security info type additionalinfo flags. See MS-SMB2 (2.2.37) or MS-DTYP */
1496 #define OWNER_SECINFO 0x00000001
1497 #define GROUP_SECINFO 0x00000002
1498 #define DACL_SECINFO 0x00000004
1499 #define SACL_SECINFO 0x00000008
1500 #define LABEL_SECINFO 0x00000010
1501 #define ATTRIBUTE_SECINFO 0x00000020
1502 #define SCOPE_SECINFO 0x00000040
1503 #define BACKUP_SECINFO 0x00010000
1504 #define UNPROTECTED_SACL_SECINFO 0x10000000
1505 #define UNPROTECTED_DACL_SECINFO 0x20000000
1506 #define PROTECTED_SACL_SECINFO 0x40000000
1507 #define PROTECTED_DACL_SECINFO 0x80000000
1509 /* Flags used for FileFullEAinfo */
1510 #define SL_RESTART_SCAN 0x00000001
1511 #define SL_RETURN_SINGLE_ENTRY 0x00000002
1512 #define SL_INDEX_SPECIFIED 0x00000004
1514 struct smb2_query_info_req {
1515 struct smb2_sync_hdr sync_hdr;
1516 __le16 StructureSize; /* Must be 41 */
1519 __le32 OutputBufferLength;
1520 __le16 InputBufferOffset;
1522 __le32 InputBufferLength;
1523 __le32 AdditionalInformation;
1525 __u64 PersistentFileId; /* opaque endianness */
1526 __u64 VolatileFileId; /* opaque endianness */
1530 struct smb2_query_info_rsp {
1531 struct smb2_sync_hdr sync_hdr;
1532 __le16 StructureSize; /* Must be 9 */
1533 __le16 OutputBufferOffset;
1534 __le32 OutputBufferLength;
1539 * Maximum number of iovs we need for a set-info request.
1540 * The largest one is rename/hardlink
1541 * [0] : struct smb2_set_info_req + smb2_file_[rename|link]_info
1543 * [2] : compound padding
1545 #define SMB2_SET_INFO_IOV_SIZE 3
1547 struct smb2_set_info_req {
1548 struct smb2_sync_hdr sync_hdr;
1549 __le16 StructureSize; /* Must be 33 */
1552 __le32 BufferLength;
1553 __le16 BufferOffset;
1555 __le32 AdditionalInformation;
1556 __u64 PersistentFileId; /* opaque endianness */
1557 __u64 VolatileFileId; /* opaque endianness */
1561 struct smb2_set_info_rsp {
1562 struct smb2_sync_hdr sync_hdr;
1563 __le16 StructureSize; /* Must be 2 */
1566 struct smb2_oplock_break {
1567 struct smb2_sync_hdr sync_hdr;
1568 __le16 StructureSize; /* Must be 24 */
1572 __u64 PersistentFid;
1576 #define SMB2_NOTIFY_BREAK_LEASE_FLAG_ACK_REQUIRED cpu_to_le32(0x01)
1578 struct smb2_lease_break {
1579 struct smb2_sync_hdr sync_hdr;
1580 __le16 StructureSize; /* Must be 44 */
1584 __le32 CurrentLeaseState;
1585 __le32 NewLeaseState;
1587 __le32 AccessMaskHint;
1588 __le32 ShareMaskHint;
1591 struct smb2_lease_ack {
1592 struct smb2_sync_hdr sync_hdr;
1593 __le16 StructureSize; /* Must be 36 */
1598 __le64 LeaseDuration;
1602 * PDU infolevel structure definitions
1603 * BB consider moving to a different header
1606 /* File System Information Classes */
1607 #define FS_VOLUME_INFORMATION 1 /* Query */
1608 #define FS_LABEL_INFORMATION 2 /* Local only */
1609 #define FS_SIZE_INFORMATION 3 /* Query */
1610 #define FS_DEVICE_INFORMATION 4 /* Query */
1611 #define FS_ATTRIBUTE_INFORMATION 5 /* Query */
1612 #define FS_CONTROL_INFORMATION 6 /* Query, Set */
1613 #define FS_FULL_SIZE_INFORMATION 7 /* Query */
1614 #define FS_OBJECT_ID_INFORMATION 8 /* Query, Set */
1615 #define FS_DRIVER_PATH_INFORMATION 9 /* Local only */
1616 #define FS_VOLUME_FLAGS_INFORMATION 10 /* Local only */
1617 #define FS_SECTOR_SIZE_INFORMATION 11 /* SMB3 or later. Query */
1618 #define FS_POSIX_INFORMATION 100 /* SMB3.1.1 POSIX. Query */
1620 struct smb2_fs_full_size_info {
1621 __le64 TotalAllocationUnits;
1622 __le64 CallerAvailableAllocationUnits;
1623 __le64 ActualAvailableAllocationUnits;
1624 __le32 SectorsPerAllocationUnit;
1625 __le32 BytesPerSector;
1628 #define SSINFO_FLAGS_ALIGNED_DEVICE 0x00000001
1629 #define SSINFO_FLAGS_PARTITION_ALIGNED_ON_DEVICE 0x00000002
1630 #define SSINFO_FLAGS_NO_SEEK_PENALTY 0x00000004
1631 #define SSINFO_FLAGS_TRIM_ENABLED 0x00000008
1633 /* sector size info struct */
1634 struct smb3_fs_ss_info {
1635 __le32 LogicalBytesPerSector;
1636 __le32 PhysicalBytesPerSectorForAtomicity;
1637 __le32 PhysicalBytesPerSectorForPerf;
1638 __le32 FileSystemEffectivePhysicalBytesPerSectorForAtomicity;
1640 __le32 ByteOffsetForSectorAlignment;
1641 __le32 ByteOffsetForPartitionAlignment;
1644 /* volume info struct - see MS-FSCC 2.5.9 */
1645 #define MAX_VOL_LABEL_LEN 32
1646 struct smb3_fs_vol_info {
1647 __le64 VolumeCreationTime;
1648 __u32 VolumeSerialNumber;
1649 __le32 VolumeLabelLength; /* includes trailing null */
1650 __u8 SupportsObjects; /* True if eg like NTFS, supports objects */
1652 __u8 VolumeLabel[]; /* variable len */
1655 /* partial list of QUERY INFO levels */
1656 #define FILE_DIRECTORY_INFORMATION 1
1657 #define FILE_FULL_DIRECTORY_INFORMATION 2
1658 #define FILE_BOTH_DIRECTORY_INFORMATION 3
1659 #define FILE_BASIC_INFORMATION 4
1660 #define FILE_STANDARD_INFORMATION 5
1661 #define FILE_INTERNAL_INFORMATION 6
1662 #define FILE_EA_INFORMATION 7
1663 #define FILE_ACCESS_INFORMATION 8
1664 #define FILE_NAME_INFORMATION 9
1665 #define FILE_RENAME_INFORMATION 10
1666 #define FILE_LINK_INFORMATION 11
1667 #define FILE_NAMES_INFORMATION 12
1668 #define FILE_DISPOSITION_INFORMATION 13
1669 #define FILE_POSITION_INFORMATION 14
1670 #define FILE_FULL_EA_INFORMATION 15
1671 #define FILE_MODE_INFORMATION 16
1672 #define FILE_ALIGNMENT_INFORMATION 17
1673 #define FILE_ALL_INFORMATION 18
1674 #define FILE_ALLOCATION_INFORMATION 19
1675 #define FILE_END_OF_FILE_INFORMATION 20
1676 #define FILE_ALTERNATE_NAME_INFORMATION 21
1677 #define FILE_STREAM_INFORMATION 22
1678 #define FILE_PIPE_INFORMATION 23
1679 #define FILE_PIPE_LOCAL_INFORMATION 24
1680 #define FILE_PIPE_REMOTE_INFORMATION 25
1681 #define FILE_MAILSLOT_QUERY_INFORMATION 26
1682 #define FILE_MAILSLOT_SET_INFORMATION 27
1683 #define FILE_COMPRESSION_INFORMATION 28
1684 #define FILE_OBJECT_ID_INFORMATION 29
1685 /* Number 30 not defined in documents */
1686 #define FILE_MOVE_CLUSTER_INFORMATION 31
1687 #define FILE_QUOTA_INFORMATION 32
1688 #define FILE_REPARSE_POINT_INFORMATION 33
1689 #define FILE_NETWORK_OPEN_INFORMATION 34
1690 #define FILE_ATTRIBUTE_TAG_INFORMATION 35
1691 #define FILE_TRACKING_INFORMATION 36
1692 #define FILEID_BOTH_DIRECTORY_INFORMATION 37
1693 #define FILEID_FULL_DIRECTORY_INFORMATION 38
1694 #define FILE_VALID_DATA_LENGTH_INFORMATION 39
1695 #define FILE_SHORT_NAME_INFORMATION 40
1696 #define FILE_SFIO_RESERVE_INFORMATION 44
1697 #define FILE_SFIO_VOLUME_INFORMATION 45
1698 #define FILE_HARD_LINK_INFORMATION 46
1699 #define FILE_NORMALIZED_NAME_INFORMATION 48
1700 #define FILEID_GLOBAL_TX_DIRECTORY_INFORMATION 50
1701 #define FILE_STANDARD_LINK_INFORMATION 54
1702 #define FILE_ID_INFORMATION 59
1703 #define FILE_ID_EXTD_DIRECTORY_INFORMATION 60
1705 struct smb2_file_internal_info {
1707 } __packed; /* level 6 Query */
1709 struct smb2_file_rename_info { /* encoding of request for level 10 */
1710 __u8 ReplaceIfExists; /* 1 = replace existing target with new */
1711 /* 0 = fail if target already exists */
1713 __u64 RootDirectory; /* MBZ for network operations (why says spec?) */
1714 __le32 FileNameLength;
1715 char FileName[]; /* New name to be assigned */
1716 /* padding - overall struct size must be >= 24 so filename + pad >= 6 */
1717 } __packed; /* level 10 Set */
1719 struct smb2_file_link_info { /* encoding of request for level 11 */
1720 __u8 ReplaceIfExists; /* 1 = replace existing link with new */
1721 /* 0 = fail if link already exists */
1723 __u64 RootDirectory; /* MBZ for network operations (why says spec?) */
1724 __le32 FileNameLength;
1725 char FileName[]; /* Name to be assigned to new link */
1726 } __packed; /* level 11 Set */
1728 struct smb2_file_full_ea_info { /* encoding of response for level 15 */
1729 __le32 next_entry_offset;
1731 __u8 ea_name_length;
1732 __le16 ea_value_length;
1733 char ea_data[]; /* \0 terminated name plus value */
1734 } __packed; /* level 15 Set */
1737 * This level 18, although with struct with same name is different from cifs
1738 * level 0x107. Level 0x107 has an extra u64 between AccessFlags and
1739 * CurrentByteOffset.
1741 struct smb2_file_all_info { /* data block encoding of response to level 18 */
1742 __le64 CreationTime; /* Beginning of FILE_BASIC_INFO equivalent */
1743 __le64 LastAccessTime;
1744 __le64 LastWriteTime;
1747 __u32 Pad1; /* End of FILE_BASIC_INFO_INFO equivalent */
1748 __le64 AllocationSize; /* Beginning of FILE_STANDARD_INFO equivalent */
1749 __le64 EndOfFile; /* size ie offset to first free byte in file */
1750 __le32 NumberOfLinks; /* hard links */
1753 __u16 Pad2; /* End of FILE_STANDARD_INFO equivalent */
1757 __le64 CurrentByteOffset;
1759 __le32 AlignmentRequirement;
1760 __le32 FileNameLength;
1762 } __packed; /* level 18 Query */
1764 struct smb2_file_eof_info { /* encoding of request for level 10 */
1765 __le64 EndOfFile; /* new end of file value */
1766 } __packed; /* level 20 Set */
1768 struct smb2_file_reparse_point_info {
1773 struct smb2_file_network_open_info {
1774 __le64 CreationTime;
1775 __le64 LastAccessTime;
1776 __le64 LastWriteTime;
1778 __le64 AllocationSize;
1782 } __packed; /* level 34 Query also similar returned in close rsp and open rsp */
1784 /* See MS-FSCC 2.4.21 */
1785 struct smb2_file_id_information {
1786 __le64 VolumeSerialNumber;
1787 __u64 PersistentFileId; /* opaque endianness */
1788 __u64 VolatileFileId; /* opaque endianness */
1789 } __packed; /* level 59 */
1791 /* See MS-FSCC 2.4.18 */
1792 struct smb2_file_id_extd_directory_info {
1793 __le32 NextEntryOffset;
1795 __le64 CreationTime;
1796 __le64 LastAccessTime;
1797 __le64 LastWriteTime;
1800 __le64 AllocationSize;
1801 __le32 FileAttributes;
1802 __le32 FileNameLength;
1803 __le32 EaSize; /* EA size */
1804 __le32 ReparsePointTag; /* valid if FILE_ATTR_REPARSE_POINT set in FileAttributes */
1805 __le64 UniqueId; /* inode num - le since Samba puts ino in low 32 bit */
1807 } __packed; /* level 60 */
1809 extern char smb2_padding[7];
1811 /* equivalent of the contents of SMB3.1.1 POSIX open context response */
1812 struct create_posix_rsp {
1816 struct cifs_sid owner; /* var-sized on the wire */
1817 struct cifs_sid group; /* var-sized on the wire */
1821 * SMB2-only POSIX info level for query dir
1823 * See posix_info_sid_size(), posix_info_extra_size() and
1824 * posix_info_parse() to help with the handling of this struct.
1826 struct smb2_posix_info {
1827 __le32 NextEntryOffset;
1829 __le64 CreationTime;
1830 __le64 LastAccessTime;
1831 __le64 LastWriteTime;
1834 __le64 AllocationSize;
1835 __le32 DosAttributes;
1839 /* beginning of POSIX Create Context Response */
1844 * var sized owner SID
1845 * var sized group SID
1846 * le32 filenamelength
1851 /* Level 100 query info */
1852 struct smb311_posix_qinfo {
1853 __le64 CreationTime;
1854 __le64 LastAccessTime;
1855 __le64 LastWriteTime;
1858 __le64 AllocationSize;
1859 __le32 DosAttributes;
1863 /* beginning of POSIX Create Context Response */
1869 * var sized owner SID
1870 * var sized group SID
1871 * le32 filenamelength
1877 * Parsed version of the above struct. Allows direct access to the
1878 * variable length fields
1880 struct smb2_posix_info_parsed {
1881 const struct smb2_posix_info *base;
1883 struct cifs_sid owner;
1884 struct cifs_sid group;
1889 #endif /* _SMB2PDU_H */