4 * Copyright (c) International Business Machines Corp., 2009, 2013
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.
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.
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
31 * Note that, due to trying to use names similar to the protocol specifications,
32 * there are many mixed case field names in the structures below. Although
33 * this does not match typical Linux kernel style, it is necessary to be
34 * able to match against the protocol specfication.
37 * Some commands have minimal (wct=0,bcc=0), or uninteresting, responses
38 * (ie no useful data other than the SMB error code itself) and are marked such.
39 * Knowing this helps avoid response buffer allocations and copy in some cases.
42 /* List of commands in host endian */
43 #define SMB2_NEGOTIATE_HE 0x0000
44 #define SMB2_SESSION_SETUP_HE 0x0001
45 #define SMB2_LOGOFF_HE 0x0002 /* trivial request/resp */
46 #define SMB2_TREE_CONNECT_HE 0x0003
47 #define SMB2_TREE_DISCONNECT_HE 0x0004 /* trivial req/resp */
48 #define SMB2_CREATE_HE 0x0005
49 #define SMB2_CLOSE_HE 0x0006
50 #define SMB2_FLUSH_HE 0x0007 /* trivial resp */
51 #define SMB2_READ_HE 0x0008
52 #define SMB2_WRITE_HE 0x0009
53 #define SMB2_LOCK_HE 0x000A
54 #define SMB2_IOCTL_HE 0x000B
55 #define SMB2_CANCEL_HE 0x000C
56 #define SMB2_ECHO_HE 0x000D
57 #define SMB2_QUERY_DIRECTORY_HE 0x000E
58 #define SMB2_CHANGE_NOTIFY_HE 0x000F
59 #define SMB2_QUERY_INFO_HE 0x0010
60 #define SMB2_SET_INFO_HE 0x0011
61 #define SMB2_OPLOCK_BREAK_HE 0x0012
63 /* The same list in little endian */
64 #define SMB2_NEGOTIATE cpu_to_le16(SMB2_NEGOTIATE_HE)
65 #define SMB2_SESSION_SETUP cpu_to_le16(SMB2_SESSION_SETUP_HE)
66 #define SMB2_LOGOFF cpu_to_le16(SMB2_LOGOFF_HE)
67 #define SMB2_TREE_CONNECT cpu_to_le16(SMB2_TREE_CONNECT_HE)
68 #define SMB2_TREE_DISCONNECT cpu_to_le16(SMB2_TREE_DISCONNECT_HE)
69 #define SMB2_CREATE cpu_to_le16(SMB2_CREATE_HE)
70 #define SMB2_CLOSE cpu_to_le16(SMB2_CLOSE_HE)
71 #define SMB2_FLUSH cpu_to_le16(SMB2_FLUSH_HE)
72 #define SMB2_READ cpu_to_le16(SMB2_READ_HE)
73 #define SMB2_WRITE cpu_to_le16(SMB2_WRITE_HE)
74 #define SMB2_LOCK cpu_to_le16(SMB2_LOCK_HE)
75 #define SMB2_IOCTL cpu_to_le16(SMB2_IOCTL_HE)
76 #define SMB2_CANCEL cpu_to_le16(SMB2_CANCEL_HE)
77 #define SMB2_ECHO cpu_to_le16(SMB2_ECHO_HE)
78 #define SMB2_QUERY_DIRECTORY cpu_to_le16(SMB2_QUERY_DIRECTORY_HE)
79 #define SMB2_CHANGE_NOTIFY cpu_to_le16(SMB2_CHANGE_NOTIFY_HE)
80 #define SMB2_QUERY_INFO cpu_to_le16(SMB2_QUERY_INFO_HE)
81 #define SMB2_SET_INFO cpu_to_le16(SMB2_SET_INFO_HE)
82 #define SMB2_OPLOCK_BREAK cpu_to_le16(SMB2_OPLOCK_BREAK_HE)
84 #define SMB2_INTERNAL_CMD cpu_to_le16(0xFFFF)
86 #define NUMBER_OF_SMB2_COMMANDS 0x0013
88 /* 52 transform hdr + 64 hdr + 88 create rsp */
89 #define SMB2_TRANSFORM_HEADER_SIZE 52
90 #define MAX_SMB2_HDR_SIZE 204
92 #define SMB2_PROTO_NUMBER cpu_to_le32(0x424d53fe)
93 #define SMB2_TRANSFORM_PROTO_NUM cpu_to_le32(0x424d53fd)
94 #define SMB2_COMPRESSION_TRANSFORM_ID cpu_to_le32(0x424d53fc)
97 * SMB2 Header Definition
99 * "MBZ" : Must be Zero
100 * "BB" : BugBug, Something to check/review/analyze later
101 * "PDU" : "Protocol Data Unit" (ie a network "frame")
105 #define SMB2_HEADER_STRUCTURE_SIZE cpu_to_le16(64)
107 struct smb2_sync_hdr {
108 __le32 ProtocolId; /* 0xFE 'S' 'M' 'B' */
109 __le16 StructureSize; /* 64 */
110 __le16 CreditCharge; /* MBZ */
111 __le32 Status; /* Error from server */
113 __le16 CreditRequest; /* CreditResponse */
118 __u32 TreeId; /* opaque - so do not make little endian */
119 __u64 SessionId; /* opaque - so do not make little endian */
123 /* The total header size for SMB2 read and write */
124 #define SMB2_READWRITE_PDU_HEADER_SIZE (48 + sizeof(struct smb2_sync_hdr))
126 struct smb2_sync_pdu {
127 struct smb2_sync_hdr sync_hdr;
128 __le16 StructureSize2; /* size of wct area (varies, request specific) */
131 #define SMB3_AES_CCM_NONCE 11
132 #define SMB3_AES_GCM_NONCE 12
134 /* Transform flags (for 3.0 dialect this flag indicates CCM */
135 #define TRANSFORM_FLAG_ENCRYPTED 0x0001
136 struct smb2_transform_hdr {
137 __le32 ProtocolId; /* 0xFD 'S' 'M' 'B' */
140 __le32 OriginalMessageSize;
142 __le16 Flags; /* EncryptionAlgorithm for 3.0, enc enabled for 3.1.1 */
146 /* See MS-SMB2 2.2.42 */
147 struct smb2_compression_transform_hdr_unchained {
148 __le32 ProtocolId; /* 0xFC 'S' 'M' 'B' */
149 __le32 OriginalCompressedSegmentSize;
150 __le16 CompressionAlgorithm;
152 __le16 Length; /* if chained it is length, else offset */
155 /* See MS-SMB2 2.2.42.1 */
156 #define SMB2_COMPRESSION_FLAG_NONE 0x0000
157 #define SMB2_COMPRESSION_FLAG_CHAINED 0x0001
159 struct compression_payload_header {
160 __le16 CompressionAlgorithm;
162 __le32 Length; /* length of compressed playload including field below if present */
163 /* __le32 OriginalPayloadSize; */ /* optional, present when LZNT1, LZ77, LZ77+Huffman */
166 /* See MS-SMB2 2.2.42.2 */
167 struct smb2_compression_transform_hdr_chained {
168 __le32 ProtocolId; /* 0xFC 'S' 'M' 'B' */
169 __le32 OriginalCompressedSegmentSize;
170 /* struct compression_payload_header[] */
173 /* See MS-SMB2 2.2.42.2.2 */
174 struct compression_pattern_payload_v1 {
181 /* See MS-SMB2 2.2.43 */
182 struct smb2_rdma_transform {
183 __le16 RdmaDescriptorOffset;
184 __le16 RdmaDescriptorLength;
185 __le32 Channel; /* for values see channel description in smb2 read above */
186 __le16 TransformCount;
192 #define SMB2_RDMA_TRANSFORM_TYPE_ENCRYPTION 0x0001
193 #define SMB2_RDMA_TRANSFORM_TYPE_SIGNING 0x0002
195 struct smb2_rdma_crypto_transform {
196 __le16 TransformType;
197 __le16 SignatureLength;
200 __u8 Signature[]; /* variable length */
202 /* followed by padding */
206 * SMB2 flag definitions
208 #define SMB2_FLAGS_SERVER_TO_REDIR cpu_to_le32(0x00000001)
209 #define SMB2_FLAGS_ASYNC_COMMAND cpu_to_le32(0x00000002)
210 #define SMB2_FLAGS_RELATED_OPERATIONS cpu_to_le32(0x00000004)
211 #define SMB2_FLAGS_SIGNED cpu_to_le32(0x00000008)
212 #define SMB2_FLAGS_PRIORITY_MASK cpu_to_le32(0x00000070) /* SMB3.1.1 */
213 #define SMB2_FLAGS_DFS_OPERATIONS cpu_to_le32(0x10000000)
214 #define SMB2_FLAGS_REPLAY_OPERATION cpu_to_le32(0x20000000) /* SMB3 & up */
217 * Definitions for SMB2 Protocol Data Units (network frames)
219 * See MS-SMB2.PDF specification for protocol details.
220 * The Naming convention is the lower case version of the SMB2
221 * command code name for the struct. Note that structures must be packed.
225 #define COMPOUND_FID 0xFFFFFFFFFFFFFFFFULL
227 #define SMB2_ERROR_STRUCTURE_SIZE2 cpu_to_le16(9)
229 struct smb2_err_rsp {
230 struct smb2_sync_hdr sync_hdr;
231 __le16 StructureSize;
232 __le16 Reserved; /* MBZ */
233 __le32 ByteCount; /* even if zero, at least one byte follows */
234 __u8 ErrorData[1]; /* variable length */
237 #define SYMLINK_ERROR_TAG 0x4c4d5953
239 struct smb2_symlink_err_rsp {
240 __le32 SymLinkLength;
241 __le32 SymLinkErrorTag;
243 __le16 ReparseDataLength;
244 __le16 UnparsedPathLength;
245 __le16 SubstituteNameOffset;
246 __le16 SubstituteNameLength;
247 __le16 PrintNameOffset;
248 __le16 PrintNameLength;
253 /* SMB 3.1.1 and later dialects. See MS-SMB2 section 2.2.2.1 */
254 struct smb2_error_context_rsp {
255 __le32 ErrorDataLength;
257 __u8 ErrorContextData; /* ErrorDataLength long array */
261 #define SMB2_ERROR_ID_DEFAULT 0x00000000
262 #define SMB2_ERROR_ID_SHARE_REDIRECT cpu_to_le32(0x72645253) /* "rdRS" */
264 /* Defines for Type field below (see MS-SMB2 2.2.2.2.2.1) */
265 #define MOVE_DST_IPADDR_V4 cpu_to_le32(0x00000001)
266 #define MOVE_DST_IPADDR_V6 cpu_to_le32(0x00000002)
268 struct move_dst_ipaddr {
271 __u8 address[16]; /* IPv4 followed by 12 bytes rsvd or IPv6 address */
274 struct share_redirect_error_context_rsp {
275 __le32 StructureSize;
276 __le32 NotificationType;
277 __le32 ResourceNameOffset;
278 __le32 ResourceNameLength;
282 struct move_dst_ipaddr IpAddrMoveList[];
283 /* __u8 ResourceName[] */ /* Name of share as counted Unicode string */
286 #define SMB2_CLIENT_GUID_SIZE 16
288 struct smb2_negotiate_req {
289 struct smb2_sync_hdr sync_hdr;
290 __le16 StructureSize; /* Must be 36 */
293 __le16 Reserved; /* MBZ */
295 __u8 ClientGUID[SMB2_CLIENT_GUID_SIZE];
296 /* In SMB3.02 and earlier next three were MBZ le64 ClientStartTime */
297 __le32 NegotiateContextOffset; /* SMB3.1.1 only. MBZ earlier */
298 __le16 NegotiateContextCount; /* SMB3.1.1 only. MBZ earlier */
300 __le16 Dialects[4]; /* BB expand this if autonegotiate > 4 dialects */
304 #define SMB10_PROT_ID 0x0000 /* local only, not sent on wire w/CIFS negprot */
305 #define SMB20_PROT_ID 0x0202
306 #define SMB21_PROT_ID 0x0210
307 #define SMB30_PROT_ID 0x0300
308 #define SMB302_PROT_ID 0x0302
309 #define SMB311_PROT_ID 0x0311
310 #define BAD_PROT_ID 0xFFFF
312 /* SecurityMode flags */
313 #define SMB2_NEGOTIATE_SIGNING_ENABLED 0x0001
314 #define SMB2_NEGOTIATE_SIGNING_REQUIRED 0x0002
315 #define SMB2_SEC_MODE_FLAGS_ALL 0x0003
317 /* Capabilities flags */
318 #define SMB2_GLOBAL_CAP_DFS 0x00000001
319 #define SMB2_GLOBAL_CAP_LEASING 0x00000002 /* Resp only New to SMB2.1 */
320 #define SMB2_GLOBAL_CAP_LARGE_MTU 0X00000004 /* Resp only New to SMB2.1 */
321 #define SMB2_GLOBAL_CAP_MULTI_CHANNEL 0x00000008 /* New to SMB3 */
322 #define SMB2_GLOBAL_CAP_PERSISTENT_HANDLES 0x00000010 /* New to SMB3 */
323 #define SMB2_GLOBAL_CAP_DIRECTORY_LEASING 0x00000020 /* New to SMB3 */
324 #define SMB2_GLOBAL_CAP_ENCRYPTION 0x00000040 /* New to SMB3 */
326 #define SMB2_NT_FIND 0x00100000
327 #define SMB2_LARGE_FILES 0x00200000
330 /* Negotiate Contexts - ContextTypes. See MS-SMB2 section 2.2.3.1 for details */
331 #define SMB2_PREAUTH_INTEGRITY_CAPABILITIES cpu_to_le16(1)
332 #define SMB2_ENCRYPTION_CAPABILITIES cpu_to_le16(2)
333 #define SMB2_COMPRESSION_CAPABILITIES cpu_to_le16(3)
334 #define SMB2_NETNAME_NEGOTIATE_CONTEXT_ID cpu_to_le16(5)
335 #define SMB2_TRANSPORT_CAPABILITIES cpu_to_le16(6)
336 #define SMB2_RDMA_TRANSFORM_CAPABILITIES cpu_to_le16(7)
337 #define SMB2_SIGNING_CAPABILITIES cpu_to_le16(8)
338 #define SMB2_POSIX_EXTENSIONS_AVAILABLE cpu_to_le16(0x100)
340 struct smb2_neg_context {
344 /* Followed by array of data */
347 #define SMB311_LINUX_CLIENT_SALT_SIZE 32
348 /* Hash Algorithm Types */
349 #define SMB2_PREAUTH_INTEGRITY_SHA512 cpu_to_le16(0x0001)
350 #define SMB2_PREAUTH_HASH_SIZE 64
353 * SaltLength that the server send can be zero, so the only three required
354 * fields (all __le16) end up six bytes total, so the minimum context data len
355 * in the response is six bytes which accounts for
357 * HashAlgorithmCount, SaltLength, and 1 HashAlgorithm.
359 #define MIN_PREAUTH_CTXT_DATA_LEN 6
361 struct smb2_preauth_neg_context {
362 __le16 ContextType; /* 1 */
365 __le16 HashAlgorithmCount; /* 1 */
367 __le16 HashAlgorithms; /* HashAlgorithms[0] since only one defined */
368 __u8 Salt[SMB311_LINUX_CLIENT_SALT_SIZE];
371 /* Encryption Algorithms Ciphers */
372 #define SMB2_ENCRYPTION_AES128_CCM cpu_to_le16(0x0001)
373 #define SMB2_ENCRYPTION_AES128_GCM cpu_to_le16(0x0002)
374 /* we currently do not request AES256_CCM since presumably GCM faster */
375 #define SMB2_ENCRYPTION_AES256_CCM cpu_to_le16(0x0003)
376 #define SMB2_ENCRYPTION_AES256_GCM cpu_to_le16(0x0004)
378 /* Min encrypt context data is one cipher so 2 bytes + 2 byte count field */
379 #define MIN_ENCRYPT_CTXT_DATA_LEN 4
380 struct smb2_encryption_neg_context {
381 __le16 ContextType; /* 2 */
384 /* CipherCount usally 2, but can be 3 when AES256-GCM enabled */
385 __le16 CipherCount; /* AES128-GCM and AES128-CCM by default */
389 /* See MS-SMB2 2.2.3.1.3 */
390 #define SMB3_COMPRESS_NONE cpu_to_le16(0x0000)
391 #define SMB3_COMPRESS_LZNT1 cpu_to_le16(0x0001)
392 #define SMB3_COMPRESS_LZ77 cpu_to_le16(0x0002)
393 #define SMB3_COMPRESS_LZ77_HUFF cpu_to_le16(0x0003)
394 /* Pattern scanning algorithm See MS-SMB2 3.1.4.4.1 */
395 #define SMB3_COMPRESS_PATTERN cpu_to_le16(0x0004) /* Pattern_V1 */
397 /* Compression Flags */
398 #define SMB2_COMPRESSION_CAPABILITIES_FLAG_NONE cpu_to_le32(0x00000000)
399 #define SMB2_COMPRESSION_CAPABILITIES_FLAG_CHAINED cpu_to_le32(0x00000001)
401 struct smb2_compression_capabilities_context {
402 __le16 ContextType; /* 3 */
405 __le16 CompressionAlgorithmCount;
408 __le16 CompressionAlgorithms[3];
412 * For smb2_netname_negotiate_context_id See MS-SMB2 2.2.3.1.4.
413 * Its struct simply contains NetName, an array of Unicode characters
415 struct smb2_netname_neg_context {
416 __le16 ContextType; /* 5 */
419 __le16 NetName[]; /* hostname of target converted to UCS-2 */
423 * For smb2_transport_capabilities context see MS-SMB2 2.2.3.1.5
428 #define SMB2_ACCEPT_TRANSFORM_LEVEL_SECURITY 0x00000001
430 struct smb2_transport_capabilities_context {
431 __le16 ContextType; /* 6 */
438 * For rdma transform capabilities context see MS-SMB2 2.2.3.1.6
442 /* RDMA Transform IDs */
443 #define SMB2_RDMA_TRANSFORM_NONE 0x0000
444 #define SMB2_RDMA_TRANSFORM_ENCRYPTION 0x0001
445 #define SMB2_RDMA_TRANSFORM_SIGNING 0x0002
447 struct smb2_rdma_transform_capabilities_context {
448 __le16 ContextType; /* 7 */
451 __le16 TransformCount;
454 __le16 RDMATransformIds[];
458 * For signing capabilities context see MS-SMB2 2.2.3.1.7
462 /* Signing algorithms */
463 #define SIGNING_ALG_HMAC_SHA256 0
464 #define SIGNING_ALG_AES_CMAC 1
465 #define SIGNING_ALG_AES_GMAC 2
467 struct smb2_signing_capabilities {
468 __le16 ContextType; /* 8 */
471 __le16 SigningAlgorithmCount;
472 __le16 SigningAlgorithms[];
475 #define POSIX_CTXT_DATA_LEN 16
476 struct smb2_posix_neg_context {
477 __le16 ContextType; /* 0x100 */
480 __u8 Name[16]; /* POSIX ctxt GUID 93AD25509CB411E7B42383DE968BCD7C */
483 struct smb2_negotiate_rsp {
484 struct smb2_sync_hdr sync_hdr;
485 __le16 StructureSize; /* Must be 65 */
487 __le16 DialectRevision;
488 __le16 NegotiateContextCount; /* Prior to SMB3.1.1 was Reserved & MBZ */
491 __le32 MaxTransactSize;
494 __le64 SystemTime; /* MBZ */
495 __le64 ServerStartTime;
496 __le16 SecurityBufferOffset;
497 __le16 SecurityBufferLength;
498 __le32 NegotiateContextOffset; /* Pre:SMB3.1.1 was reserved/ignored */
499 __u8 Buffer[1]; /* variable length GSS security buffer */
503 #define SMB2_SESSION_REQ_FLAG_BINDING 0x01
504 #define SMB2_SESSION_REQ_FLAG_ENCRYPT_DATA 0x04
506 struct smb2_sess_setup_req {
507 struct smb2_sync_hdr sync_hdr;
508 __le16 StructureSize; /* Must be 25 */
513 __le16 SecurityBufferOffset;
514 __le16 SecurityBufferLength;
515 __u64 PreviousSessionId;
516 __u8 Buffer[1]; /* variable length GSS security buffer */
519 /* Currently defined SessionFlags */
520 #define SMB2_SESSION_FLAG_IS_GUEST 0x0001
521 #define SMB2_SESSION_FLAG_IS_NULL 0x0002
522 #define SMB2_SESSION_FLAG_ENCRYPT_DATA 0x0004
523 struct smb2_sess_setup_rsp {
524 struct smb2_sync_hdr sync_hdr;
525 __le16 StructureSize; /* Must be 9 */
527 __le16 SecurityBufferOffset;
528 __le16 SecurityBufferLength;
529 __u8 Buffer[1]; /* variable length GSS security buffer */
532 struct smb2_logoff_req {
533 struct smb2_sync_hdr sync_hdr;
534 __le16 StructureSize; /* Must be 4 */
538 struct smb2_logoff_rsp {
539 struct smb2_sync_hdr sync_hdr;
540 __le16 StructureSize; /* Must be 4 */
544 /* Flags/Reserved for SMB3.1.1 */
545 #define SMB2_TREE_CONNECT_FLAG_CLUSTER_RECONNECT cpu_to_le16(0x0001)
546 #define SMB2_TREE_CONNECT_FLAG_REDIRECT_TO_OWNER cpu_to_le16(0x0002)
547 #define SMB2_TREE_CONNECT_FLAG_EXTENSION_PRESENT cpu_to_le16(0x0004)
549 struct smb2_tree_connect_req {
550 struct smb2_sync_hdr sync_hdr;
551 __le16 StructureSize; /* Must be 9 */
552 __le16 Flags; /* Reserved MBZ for dialects prior to SMB3.1.1 */
555 __u8 Buffer[1]; /* variable length */
558 /* See MS-SMB2 section 2.2.9.2 */
560 #define SMB2_RESERVED_TREE_CONNECT_CONTEXT_ID 0x0000
561 #define SMB2_REMOTED_IDENTITY_TREE_CONNECT_CONTEXT_ID cpu_to_le16(0x0001)
563 struct tree_connect_contexts {
570 /* Remoted identity tree connect context structures - see MS-SMB2 2.2.9.2.1 */
571 struct smb3_blob_data {
576 /* Valid values for Attr */
577 #define SE_GROUP_MANDATORY 0x00000001
578 #define SE_GROUP_ENABLED_BY_DEFAULT 0x00000002
579 #define SE_GROUP_ENABLED 0x00000004
580 #define SE_GROUP_OWNER 0x00000008
581 #define SE_GROUP_USE_FOR_DENY_ONLY 0x00000010
582 #define SE_GROUP_INTEGRITY 0x00000020
583 #define SE_GROUP_INTEGRITY_ENABLED 0x00000040
584 #define SE_GROUP_RESOURCE 0x20000000
585 #define SE_GROUP_LOGON_ID 0xC0000000
587 /* struct sid_attr_data is SidData array in BlobData format then le32 Attr */
589 struct sid_array_data {
591 /* SidAttrList - array of sid_attr_data structs */
594 struct luid_attr_data {
599 * struct privilege_data is the same as BLOB_DATA - see MS-SMB2 2.2.9.2.1.5
600 * but with size of LUID_ATTR_DATA struct and BlobData set to LUID_ATTR DATA
603 struct privilege_array_data {
604 __le16 PrivilegeCount;
605 /* array of privilege_data structs */
608 struct remoted_identity_tcon_context {
609 __le16 TicketType; /* must be 0x0001 */
610 __le16 TicketSize; /* total size of this struct */
611 __le16 User; /* offset to SID_ATTR_DATA struct with user info */
612 __le16 UserName; /* offset to null terminated Unicode username string */
613 __le16 Domain; /* offset to null terminated Unicode domain name */
614 __le16 Groups; /* offset to SID_ARRAY_DATA struct with group info */
615 __le16 RestrictedGroups; /* similar to above */
616 __le16 Privileges; /* offset to PRIVILEGE_ARRAY_DATA struct */
617 __le16 PrimaryGroup; /* offset to SID_ARRAY_DATA struct */
618 __le16 Owner; /* offset to BLOB_DATA struct */
619 __le16 DefaultDacl; /* offset to BLOB_DATA struct */
620 __le16 DeviceGroups; /* offset to SID_ARRAY_DATA struct */
621 __le16 UserClaims; /* offset to BLOB_DATA struct */
622 __le16 DeviceClaims; /* offset to BLOB_DATA struct */
623 __u8 TicketInfo[]; /* variable length buf - remoted identity data */
626 struct smb2_tree_connect_req_extension {
627 __le32 TreeConnectContextOffset;
628 __le16 TreeConnectContextCount;
630 __u8 PathName[]; /* variable sized array */
631 /* followed by array of TreeConnectContexts */
634 struct smb2_tree_connect_rsp {
635 struct smb2_sync_hdr sync_hdr;
636 __le16 StructureSize; /* Must be 16 */
637 __u8 ShareType; /* see below */
639 __le32 ShareFlags; /* see below */
640 __le32 Capabilities; /* see below */
641 __le32 MaximalAccess;
644 /* Possible ShareType values */
645 #define SMB2_SHARE_TYPE_DISK 0x01
646 #define SMB2_SHARE_TYPE_PIPE 0x02
647 #define SMB2_SHARE_TYPE_PRINT 0x03
650 * Possible ShareFlags - exactly one and only one of the first 4 caching flags
651 * must be set (any of the remaining, SHI1005, flags may be set individually
654 #define SMB2_SHAREFLAG_MANUAL_CACHING 0x00000000
655 #define SMB2_SHAREFLAG_AUTO_CACHING 0x00000010
656 #define SMB2_SHAREFLAG_VDO_CACHING 0x00000020
657 #define SMB2_SHAREFLAG_NO_CACHING 0x00000030
658 #define SHI1005_FLAGS_DFS 0x00000001
659 #define SHI1005_FLAGS_DFS_ROOT 0x00000002
660 #define SHI1005_FLAGS_RESTRICT_EXCLUSIVE_OPENS 0x00000100
661 #define SHI1005_FLAGS_FORCE_SHARED_DELETE 0x00000200
662 #define SHI1005_FLAGS_ALLOW_NAMESPACE_CACHING 0x00000400
663 #define SHI1005_FLAGS_ACCESS_BASED_DIRECTORY_ENUM 0x00000800
664 #define SHI1005_FLAGS_FORCE_LEVELII_OPLOCK 0x00001000
665 #define SHI1005_FLAGS_ENABLE_HASH_V1 0x00002000
666 #define SHI1005_FLAGS_ENABLE_HASH_V2 0x00004000
667 #define SHI1005_FLAGS_ENCRYPT_DATA 0x00008000
668 #define SMB2_SHAREFLAG_IDENTITY_REMOTING 0x00040000 /* 3.1.1 */
669 #define SMB2_SHAREFLAG_COMPRESS_DATA 0x00100000 /* 3.1.1 */
670 #define SHI1005_FLAGS_ALL 0x0014FF33
672 /* Possible share capabilities */
673 #define SMB2_SHARE_CAP_DFS cpu_to_le32(0x00000008) /* all dialects */
674 #define SMB2_SHARE_CAP_CONTINUOUS_AVAILABILITY cpu_to_le32(0x00000010) /* 3.0 */
675 #define SMB2_SHARE_CAP_SCALEOUT cpu_to_le32(0x00000020) /* 3.0 */
676 #define SMB2_SHARE_CAP_CLUSTER cpu_to_le32(0x00000040) /* 3.0 */
677 #define SMB2_SHARE_CAP_ASYMMETRIC cpu_to_le32(0x00000080) /* 3.02 */
678 #define SMB2_SHARE_CAP_REDIRECT_TO_OWNER cpu_to_le32(0x00000100) /* 3.1.1 */
680 struct smb2_tree_disconnect_req {
681 struct smb2_sync_hdr sync_hdr;
682 __le16 StructureSize; /* Must be 4 */
686 struct smb2_tree_disconnect_rsp {
687 struct smb2_sync_hdr sync_hdr;
688 __le16 StructureSize; /* Must be 4 */
692 /* File Attrubutes */
693 #define FILE_ATTRIBUTE_READONLY 0x00000001
694 #define FILE_ATTRIBUTE_HIDDEN 0x00000002
695 #define FILE_ATTRIBUTE_SYSTEM 0x00000004
696 #define FILE_ATTRIBUTE_DIRECTORY 0x00000010
697 #define FILE_ATTRIBUTE_ARCHIVE 0x00000020
698 #define FILE_ATTRIBUTE_NORMAL 0x00000080
699 #define FILE_ATTRIBUTE_TEMPORARY 0x00000100
700 #define FILE_ATTRIBUTE_SPARSE_FILE 0x00000200
701 #define FILE_ATTRIBUTE_REPARSE_POINT 0x00000400
702 #define FILE_ATTRIBUTE_COMPRESSED 0x00000800
703 #define FILE_ATTRIBUTE_OFFLINE 0x00001000
704 #define FILE_ATTRIBUTE_NOT_CONTENT_INDEXED 0x00002000
705 #define FILE_ATTRIBUTE_ENCRYPTED 0x00004000
706 #define FILE_ATTRIBUTE_INTEGRITY_STREAM 0x00008000
707 #define FILE_ATTRIBUTE_NO_SCRUB_DATA 0x00020000
710 #define SMB2_OPLOCK_LEVEL_NONE 0x00
711 #define SMB2_OPLOCK_LEVEL_II 0x01
712 #define SMB2_OPLOCK_LEVEL_EXCLUSIVE 0x08
713 #define SMB2_OPLOCK_LEVEL_BATCH 0x09
714 #define SMB2_OPLOCK_LEVEL_LEASE 0xFF
715 /* Non-spec internal type */
716 #define SMB2_OPLOCK_LEVEL_NOCHANGE 0x99
718 /* Desired Access Flags */
719 #define FILE_READ_DATA_LE cpu_to_le32(0x00000001)
720 #define FILE_WRITE_DATA_LE cpu_to_le32(0x00000002)
721 #define FILE_APPEND_DATA_LE cpu_to_le32(0x00000004)
722 #define FILE_READ_EA_LE cpu_to_le32(0x00000008)
723 #define FILE_WRITE_EA_LE cpu_to_le32(0x00000010)
724 #define FILE_EXECUTE_LE cpu_to_le32(0x00000020)
725 #define FILE_READ_ATTRIBUTES_LE cpu_to_le32(0x00000080)
726 #define FILE_WRITE_ATTRIBUTES_LE cpu_to_le32(0x00000100)
727 #define FILE_DELETE_LE cpu_to_le32(0x00010000)
728 #define FILE_READ_CONTROL_LE cpu_to_le32(0x00020000)
729 #define FILE_WRITE_DAC_LE cpu_to_le32(0x00040000)
730 #define FILE_WRITE_OWNER_LE cpu_to_le32(0x00080000)
731 #define FILE_SYNCHRONIZE_LE cpu_to_le32(0x00100000)
732 #define FILE_ACCESS_SYSTEM_SECURITY_LE cpu_to_le32(0x01000000)
733 #define FILE_MAXIMAL_ACCESS_LE cpu_to_le32(0x02000000)
734 #define FILE_GENERIC_ALL_LE cpu_to_le32(0x10000000)
735 #define FILE_GENERIC_EXECUTE_LE cpu_to_le32(0x20000000)
736 #define FILE_GENERIC_WRITE_LE cpu_to_le32(0x40000000)
737 #define FILE_GENERIC_READ_LE cpu_to_le32(0x80000000)
739 /* ShareAccess Flags */
740 #define FILE_SHARE_READ_LE cpu_to_le32(0x00000001)
741 #define FILE_SHARE_WRITE_LE cpu_to_le32(0x00000002)
742 #define FILE_SHARE_DELETE_LE cpu_to_le32(0x00000004)
743 #define FILE_SHARE_ALL_LE cpu_to_le32(0x00000007)
745 /* CreateDisposition Flags */
746 #define FILE_SUPERSEDE_LE cpu_to_le32(0x00000000)
747 #define FILE_OPEN_LE cpu_to_le32(0x00000001)
748 #define FILE_CREATE_LE cpu_to_le32(0x00000002)
749 #define FILE_OPEN_IF_LE cpu_to_le32(0x00000003)
750 #define FILE_OVERWRITE_LE cpu_to_le32(0x00000004)
751 #define FILE_OVERWRITE_IF_LE cpu_to_le32(0x00000005)
753 /* CreateOptions Flags */
754 #define FILE_DIRECTORY_FILE_LE cpu_to_le32(0x00000001)
755 /* same as #define CREATE_NOT_FILE_LE cpu_to_le32(0x00000001) */
756 #define FILE_WRITE_THROUGH_LE cpu_to_le32(0x00000002)
757 #define FILE_SEQUENTIAL_ONLY_LE cpu_to_le32(0x00000004)
758 #define FILE_NO_INTERMEDIATE_BUFFERRING_LE cpu_to_le32(0x00000008)
759 #define FILE_SYNCHRONOUS_IO_ALERT_LE cpu_to_le32(0x00000010)
760 #define FILE_SYNCHRONOUS_IO_NON_ALERT_LE cpu_to_le32(0x00000020)
761 #define FILE_NON_DIRECTORY_FILE_LE cpu_to_le32(0x00000040)
762 #define FILE_COMPLETE_IF_OPLOCKED_LE cpu_to_le32(0x00000100)
763 #define FILE_NO_EA_KNOWLEDGE_LE cpu_to_le32(0x00000200)
764 #define FILE_RANDOM_ACCESS_LE cpu_to_le32(0x00000800)
765 #define FILE_DELETE_ON_CLOSE_LE cpu_to_le32(0x00001000)
766 #define FILE_OPEN_BY_FILE_ID_LE cpu_to_le32(0x00002000)
767 #define FILE_OPEN_FOR_BACKUP_INTENT_LE cpu_to_le32(0x00004000)
768 #define FILE_NO_COMPRESSION_LE cpu_to_le32(0x00008000)
769 #define FILE_RESERVE_OPFILTER_LE cpu_to_le32(0x00100000)
770 #define FILE_OPEN_REPARSE_POINT_LE cpu_to_le32(0x00200000)
771 #define FILE_OPEN_NO_RECALL_LE cpu_to_le32(0x00400000)
772 #define FILE_OPEN_FOR_FREE_SPACE_QUERY_LE cpu_to_le32(0x00800000)
774 #define FILE_READ_RIGHTS_LE (FILE_READ_DATA_LE | FILE_READ_EA_LE \
775 | FILE_READ_ATTRIBUTES_LE)
776 #define FILE_WRITE_RIGHTS_LE (FILE_WRITE_DATA_LE | FILE_APPEND_DATA_LE \
777 | FILE_WRITE_EA_LE | FILE_WRITE_ATTRIBUTES_LE)
778 #define FILE_EXEC_RIGHTS_LE (FILE_EXECUTE_LE)
780 /* Impersonation Levels. See MS-WPO section 9.7 and MSDN-IMPERS */
781 #define IL_ANONYMOUS cpu_to_le32(0x00000000)
782 #define IL_IDENTIFICATION cpu_to_le32(0x00000001)
783 #define IL_IMPERSONATION cpu_to_le32(0x00000002)
784 #define IL_DELEGATE cpu_to_le32(0x00000003)
786 /* Create Context Values */
787 #define SMB2_CREATE_EA_BUFFER "ExtA" /* extended attributes */
788 #define SMB2_CREATE_SD_BUFFER "SecD" /* security descriptor */
789 #define SMB2_CREATE_DURABLE_HANDLE_REQUEST "DHnQ"
790 #define SMB2_CREATE_DURABLE_HANDLE_RECONNECT "DHnC"
791 #define SMB2_CREATE_ALLOCATION_SIZE "AISi"
792 #define SMB2_CREATE_QUERY_MAXIMAL_ACCESS_REQUEST "MxAc"
793 #define SMB2_CREATE_TIMEWARP_REQUEST "TWrp"
794 #define SMB2_CREATE_QUERY_ON_DISK_ID "QFid"
795 #define SMB2_CREATE_REQUEST_LEASE "RqLs"
796 #define SMB2_CREATE_DURABLE_HANDLE_REQUEST_V2 "DH2Q"
797 #define SMB2_CREATE_DURABLE_HANDLE_RECONNECT_V2 "DH2C"
798 #define SMB2_CREATE_APP_INSTANCE_ID 0x45BCA66AEFA7F74A9008FA462E144D74
799 #define SMB2_CREATE_APP_INSTANCE_VERSION 0xB982D0B73B56074FA07B524A8116A010
800 #define SVHDX_OPEN_DEVICE_CONTEX 0x9CCBCF9E04C1E643980E158DA1F6EC83
801 #define SMB2_CREATE_TAG_POSIX 0x93AD25509CB411E7B42383DE968BCD7C
803 /* Flag (SMB3 open response) values */
804 #define SMB2_CREATE_FLAG_REPARSEPOINT 0x01
807 * Maximum number of iovs we need for an open/create request.
808 * [0] : struct smb2_create_req
810 * [2] : lease context
811 * [3] : durable context
812 * [4] : posix context
813 * [5] : time warp context
814 * [6] : query id context
815 * [7] : compound padding
817 #define SMB2_CREATE_IOV_SIZE 8
819 struct smb2_create_req {
820 struct smb2_sync_hdr sync_hdr;
821 __le16 StructureSize; /* Must be 57 */
823 __u8 RequestedOplockLevel;
824 __le32 ImpersonationLevel;
825 __le64 SmbCreateFlags;
827 __le32 DesiredAccess;
828 __le32 FileAttributes;
830 __le32 CreateDisposition;
831 __le32 CreateOptions;
834 __le32 CreateContextsOffset;
835 __le32 CreateContextsLength;
840 * Maximum size of a SMB2_CREATE response is 64 (smb2 header) +
841 * 88 (fixed part of create response) + 520 (path) + 208 (contexts) +
842 * 2 bytes of padding.
844 #define MAX_SMB2_CREATE_RESPONSE_SIZE 880
846 struct smb2_create_rsp {
847 struct smb2_sync_hdr sync_hdr;
848 __le16 StructureSize; /* Must be 89 */
850 __u8 Flag; /* 0x01 if reparse point */
853 __le64 LastAccessTime;
854 __le64 LastWriteTime;
856 __le64 AllocationSize;
858 __le32 FileAttributes;
860 __u64 PersistentFileId; /* opaque endianness */
861 __u64 VolatileFileId; /* opaque endianness */
862 __le32 CreateContextsOffset;
863 __le32 CreateContextsLength;
867 struct create_context {
877 #define SMB2_LEASE_READ_CACHING_HE 0x01
878 #define SMB2_LEASE_HANDLE_CACHING_HE 0x02
879 #define SMB2_LEASE_WRITE_CACHING_HE 0x04
881 #define SMB2_LEASE_NONE cpu_to_le32(0x00)
882 #define SMB2_LEASE_READ_CACHING cpu_to_le32(0x01)
883 #define SMB2_LEASE_HANDLE_CACHING cpu_to_le32(0x02)
884 #define SMB2_LEASE_WRITE_CACHING cpu_to_le32(0x04)
886 #define SMB2_LEASE_FLAG_BREAK_IN_PROGRESS cpu_to_le32(0x00000002)
887 #define SMB2_LEASE_FLAG_PARENT_LEASE_KEY_SET cpu_to_le32(0x00000004)
889 #define SMB2_LEASE_KEY_SIZE 16
891 struct lease_context {
892 u8 LeaseKey[SMB2_LEASE_KEY_SIZE];
895 __le64 LeaseDuration;
898 struct lease_context_v2 {
899 u8 LeaseKey[SMB2_LEASE_KEY_SIZE];
902 __le64 LeaseDuration;
903 __le64 ParentLeaseKeyLow;
904 __le64 ParentLeaseKeyHigh;
909 struct create_lease {
910 struct create_context ccontext;
912 struct lease_context lcontext;
915 struct create_lease_v2 {
916 struct create_context ccontext;
918 struct lease_context_v2 lcontext;
922 struct create_durable {
923 struct create_context ccontext;
928 __u64 PersistentFileId;
929 __u64 VolatileFileId;
934 struct create_posix {
935 struct create_context ccontext;
941 /* See MS-SMB2 2.2.13.2.11 */
943 #define SMB2_DHANDLE_FLAG_PERSISTENT 0x00000002
944 struct durable_context_v2 {
951 struct create_durable_v2 {
952 struct create_context ccontext;
954 struct durable_context_v2 dcontext;
957 /* See MS-SMB2 2.2.13.2.12 */
958 struct durable_reconnect_context_v2 {
960 __u64 PersistentFileId;
961 __u64 VolatileFileId;
964 __le32 Flags; /* see above DHANDLE_FLAG_PERSISTENT */
967 /* See MS-SMB2 2.2.14.2.9 */
968 struct create_on_disk_id {
969 struct create_context ccontext;
976 /* See MS-SMB2 2.2.14.2.12 */
977 struct durable_reconnect_context_v2_rsp {
979 __le32 Flags; /* see above DHANDLE_FLAG_PERSISTENT */
982 struct create_durable_handle_reconnect_v2 {
983 struct create_context ccontext;
985 struct durable_reconnect_context_v2 dcontext;
989 /* See MS-SMB2 2.2.13.2.5 */
990 struct crt_twarp_ctxt {
991 struct create_context ccontext;
997 /* See MS-SMB2 2.2.13.2.9 */
998 struct crt_query_id_ctxt {
999 struct create_context ccontext;
1003 struct crt_sd_ctxt {
1004 struct create_context ccontext;
1010 #define COPY_CHUNK_RES_KEY_SIZE 24
1011 struct resume_key_req {
1012 char ResumeKey[COPY_CHUNK_RES_KEY_SIZE];
1013 __le32 ContextLength; /* MBZ */
1014 char Context[]; /* ignored, Windows sets to 4 bytes of zero */
1017 /* this goes in the ioctl buffer when doing a copychunk request */
1018 struct copychunk_ioctl {
1019 char SourceKey[COPY_CHUNK_RES_KEY_SIZE];
1020 __le32 ChunkCount; /* we are only sending 1 */
1022 /* array will only be one chunk long for us */
1023 __le64 SourceOffset;
1024 __le64 TargetOffset;
1025 __le32 Length; /* how many bytes to copy */
1029 /* this goes in the ioctl buffer when doing FSCTL_SET_ZERO_DATA */
1030 struct file_zero_data_information {
1032 __le64 BeyondFinalZero;
1035 struct copychunk_ioctl_rsp {
1036 __le32 ChunksWritten;
1037 __le32 ChunkBytesWritten;
1038 __le32 TotalBytesWritten;
1041 /* See MS-FSCC 2.3.29 and 2.3.30 */
1042 struct get_retrieval_pointer_count_req {
1043 __le64 StartingVcn; /* virtual cluster number (signed) */
1046 struct get_retrieval_pointer_count_rsp {
1051 * See MS-FSCC 2.3.33 and 2.3.34
1052 * request is the same as get_retrieval_point_count_req struct above
1054 struct smb3_extents {
1056 __le64 Lcn; /* logical cluster number */
1059 struct get_retrieval_pointers_refcount_rsp {
1063 struct smb3_extents extents[];
1066 struct fsctl_set_integrity_information_req {
1067 __le16 ChecksumAlgorithm;
1072 struct fsctl_get_integrity_information_rsp {
1073 __le16 ChecksumAlgorithm;
1076 __le32 ChecksumChunkSizeInBytes;
1077 __le32 ClusterSizeInBytes;
1080 struct file_allocated_range_buffer {
1085 /* Integrity ChecksumAlgorithm choices for above */
1086 #define CHECKSUM_TYPE_NONE 0x0000
1087 #define CHECKSUM_TYPE_CRC64 0x0002
1088 #define CHECKSUM_TYPE_UNCHANGED 0xFFFF /* set only */
1090 /* Integrity flags for above */
1091 #define FSCTL_INTEGRITY_FLAG_CHECKSUM_ENFORCEMENT_OFF 0x00000001
1093 /* Reparse structures - see MS-FSCC 2.1.2 */
1095 /* struct fsctl_reparse_info_req is empty, only response structs (see below) */
1097 struct reparse_data_buffer {
1099 __le16 ReparseDataLength;
1101 __u8 DataBuffer[]; /* Variable Length */
1104 struct reparse_guid_data_buffer {
1106 __le16 ReparseDataLength;
1108 __u8 ReparseGuid[16];
1109 __u8 DataBuffer[]; /* Variable Length */
1112 struct reparse_mount_point_data_buffer {
1114 __le16 ReparseDataLength;
1116 __le16 SubstituteNameOffset;
1117 __le16 SubstituteNameLength;
1118 __le16 PrintNameOffset;
1119 __le16 PrintNameLength;
1120 __u8 PathBuffer[]; /* Variable Length */
1123 #define SYMLINK_FLAG_RELATIVE 0x00000001
1125 struct reparse_symlink_data_buffer {
1127 __le16 ReparseDataLength;
1129 __le16 SubstituteNameOffset;
1130 __le16 SubstituteNameLength;
1131 __le16 PrintNameOffset;
1132 __le16 PrintNameLength;
1134 __u8 PathBuffer[]; /* Variable Length */
1137 /* See MS-FSCC 2.1.2.6 and cifspdu.h for struct reparse_posix_data */
1140 /* See MS-DFSC 2.2.2 */
1141 struct fsctl_get_dfs_referral_req {
1142 __le16 MaxReferralLevel;
1143 __u8 RequestFileName[];
1146 /* DFS response is struct get_dfs_refer_rsp */
1148 /* See MS-SMB2 2.2.31.3 */
1149 struct network_resiliency_req {
1153 /* There is no buffer for the response ie no struct network_resiliency_rsp */
1156 struct validate_negotiate_info_req {
1157 __le32 Capabilities;
1158 __u8 Guid[SMB2_CLIENT_GUID_SIZE];
1159 __le16 SecurityMode;
1160 __le16 DialectCount;
1161 __le16 Dialects[4]; /* BB expand this if autonegotiate > 4 dialects */
1164 struct validate_negotiate_info_rsp {
1165 __le32 Capabilities;
1166 __u8 Guid[SMB2_CLIENT_GUID_SIZE];
1167 __le16 SecurityMode;
1168 __le16 Dialect; /* Dialect in use for the connection */
1171 #define RSS_CAPABLE cpu_to_le32(0x00000001)
1172 #define RDMA_CAPABLE cpu_to_le32(0x00000002)
1174 #define INTERNETWORK cpu_to_le16(0x0002)
1175 #define INTERNETWORKV6 cpu_to_le16(0x0017)
1177 struct network_interface_info_ioctl_rsp {
1178 __le32 Next; /* next interface. zero if this is last one */
1180 __le32 Capability; /* RSS or RDMA Capable */
1187 struct iface_info_ipv4 {
1193 struct iface_info_ipv6 {
1196 __u8 IPv6Address[16];
1200 #define NO_FILE_ID 0xFFFFFFFFFFFFFFFFULL /* general ioctls to srv not to file */
1202 struct compress_ioctl {
1203 __le16 CompressionState; /* See cifspdu.h for possible flag values */
1206 struct duplicate_extents_to_file {
1207 __u64 PersistentFileHandle; /* source file handle, opaque endianness */
1208 __u64 VolatileFileHandle;
1209 __le64 SourceFileOffset;
1210 __le64 TargetFileOffset;
1211 __le64 ByteCount; /* Bytes to be copied */
1215 * Maximum number of iovs we need for an ioctl request.
1216 * [0] : struct smb2_ioctl_req
1219 #define SMB2_IOCTL_IOV_SIZE 2
1221 struct smb2_ioctl_req {
1222 struct smb2_sync_hdr sync_hdr;
1223 __le16 StructureSize; /* Must be 57 */
1226 __u64 PersistentFileId; /* opaque endianness */
1227 __u64 VolatileFileId; /* opaque endianness */
1230 __le32 MaxInputResponse;
1231 __le32 OutputOffset;
1233 __le32 MaxOutputResponse;
1239 struct smb2_ioctl_rsp {
1240 struct smb2_sync_hdr sync_hdr;
1241 __le16 StructureSize; /* Must be 57 */
1244 __u64 PersistentFileId; /* opaque endianness */
1245 __u64 VolatileFileId; /* opaque endianness */
1248 __le32 OutputOffset;
1252 /* char * buffer[] */
1255 /* Currently defined values for close flags */
1256 #define SMB2_CLOSE_FLAG_POSTQUERY_ATTRIB cpu_to_le16(0x0001)
1257 struct smb2_close_req {
1258 struct smb2_sync_hdr sync_hdr;
1259 __le16 StructureSize; /* Must be 24 */
1262 __u64 PersistentFileId; /* opaque endianness */
1263 __u64 VolatileFileId; /* opaque endianness */
1267 * Maximum size of a SMB2_CLOSE response is 64 (smb2 header) + 60 (data)
1269 #define MAX_SMB2_CLOSE_RESPONSE_SIZE 124
1271 struct smb2_close_rsp {
1272 struct smb2_sync_hdr sync_hdr;
1273 __le16 StructureSize; /* 60 */
1276 __le64 CreationTime;
1277 __le64 LastAccessTime;
1278 __le64 LastWriteTime;
1280 __le64 AllocationSize; /* Beginning of FILE_STANDARD_INFO equivalent */
1285 struct smb2_flush_req {
1286 struct smb2_sync_hdr sync_hdr;
1287 __le16 StructureSize; /* Must be 24 */
1290 __u64 PersistentFileId; /* opaque endianness */
1291 __u64 VolatileFileId; /* opaque endianness */
1294 struct smb2_flush_rsp {
1295 struct smb2_sync_hdr sync_hdr;
1296 __le16 StructureSize;
1300 /* For read request Flags field below, following flag is defined for SMB3.02 */
1301 #define SMB2_READFLAG_READ_UNBUFFERED 0x01
1302 #define SMB2_READFLAG_REQUEST_COMPRESSED 0x02 /* See MS-SMB2 2.2.19 */
1304 /* Channel field for read and write: exactly one of following flags can be set*/
1305 #define SMB2_CHANNEL_NONE cpu_to_le32(0x00000000)
1306 #define SMB2_CHANNEL_RDMA_V1 cpu_to_le32(0x00000001) /* SMB3 or later */
1307 #define SMB2_CHANNEL_RDMA_V1_INVALIDATE cpu_to_le32(0x00000002) /* >= SMB3.02 */
1308 #define SMB2_CHANNEL_RDMA_TRANSFORM cpu_to_le32(0x00000003) /* >= SMB3.02, only used on write */
1310 /* SMB2 read request without RFC1001 length at the beginning */
1311 struct smb2_read_plain_req {
1312 struct smb2_sync_hdr sync_hdr;
1313 __le16 StructureSize; /* Must be 49 */
1314 __u8 Padding; /* offset from start of SMB2 header to place read */
1315 __u8 Flags; /* MBZ unless SMB3.02 or later */
1318 __u64 PersistentFileId; /* opaque endianness */
1319 __u64 VolatileFileId; /* opaque endianness */
1320 __le32 MinimumCount;
1321 __le32 Channel; /* MBZ except for SMB3 or later */
1322 __le32 RemainingBytes;
1323 __le16 ReadChannelInfoOffset;
1324 __le16 ReadChannelInfoLength;
1329 #define SMB2_READFLAG_RESPONSE_NONE 0x00000000
1330 #define SMB2_READFLAG_RESPONSE_RDMA_TRANSFORM 0x00000001
1332 struct smb2_read_rsp {
1333 struct smb2_sync_hdr sync_hdr;
1334 __le16 StructureSize; /* Must be 17 */
1338 __le32 DataRemaining;
1343 /* For write request Flags field below the following flags are defined: */
1344 #define SMB2_WRITEFLAG_WRITE_THROUGH 0x00000001 /* SMB2.1 or later */
1345 #define SMB2_WRITEFLAG_WRITE_UNBUFFERED 0x00000002 /* SMB3.02 or later */
1347 struct smb2_write_req {
1348 struct smb2_sync_hdr sync_hdr;
1349 __le16 StructureSize; /* Must be 49 */
1350 __le16 DataOffset; /* offset from start of SMB2 header to write data */
1353 __u64 PersistentFileId; /* opaque endianness */
1354 __u64 VolatileFileId; /* opaque endianness */
1355 __le32 Channel; /* MBZ unless SMB3.02 or later */
1356 __le32 RemainingBytes;
1357 __le16 WriteChannelInfoOffset;
1358 __le16 WriteChannelInfoLength;
1363 struct smb2_write_rsp {
1364 struct smb2_sync_hdr sync_hdr;
1365 __le16 StructureSize; /* Must be 17 */
1369 __le32 DataRemaining;
1375 #define SMB2_WATCH_TREE 0x0001
1377 /* notify completion filter flags. See MS-FSCC 2.6 and MS-SMB2 2.2.35 */
1378 #define FILE_NOTIFY_CHANGE_FILE_NAME 0x00000001
1379 #define FILE_NOTIFY_CHANGE_DIR_NAME 0x00000002
1380 #define FILE_NOTIFY_CHANGE_ATTRIBUTES 0x00000004
1381 #define FILE_NOTIFY_CHANGE_SIZE 0x00000008
1382 #define FILE_NOTIFY_CHANGE_LAST_WRITE 0x00000010
1383 #define FILE_NOTIFY_CHANGE_LAST_ACCESS 0x00000020
1384 #define FILE_NOTIFY_CHANGE_CREATION 0x00000040
1385 #define FILE_NOTIFY_CHANGE_EA 0x00000080
1386 #define FILE_NOTIFY_CHANGE_SECURITY 0x00000100
1387 #define FILE_NOTIFY_CHANGE_STREAM_NAME 0x00000200
1388 #define FILE_NOTIFY_CHANGE_STREAM_SIZE 0x00000400
1389 #define FILE_NOTIFY_CHANGE_STREAM_WRITE 0x00000800
1391 struct smb2_change_notify_req {
1392 struct smb2_sync_hdr sync_hdr;
1393 __le16 StructureSize;
1395 __le32 OutputBufferLength;
1396 __u64 PersistentFileId; /* opaque endianness */
1397 __u64 VolatileFileId; /* opaque endianness */
1398 __le32 CompletionFilter;
1402 struct smb2_change_notify_rsp {
1403 struct smb2_sync_hdr sync_hdr;
1404 __le16 StructureSize; /* Must be 9 */
1405 __le16 OutputBufferOffset;
1406 __le32 OutputBufferLength;
1407 __u8 Buffer[1]; /* array of file notify structs */
1410 #define SMB2_LOCKFLAG_SHARED_LOCK 0x0001
1411 #define SMB2_LOCKFLAG_EXCLUSIVE_LOCK 0x0002
1412 #define SMB2_LOCKFLAG_UNLOCK 0x0004
1413 #define SMB2_LOCKFLAG_FAIL_IMMEDIATELY 0x0010
1415 struct smb2_lock_element {
1422 struct smb2_lock_req {
1423 struct smb2_sync_hdr sync_hdr;
1424 __le16 StructureSize; /* Must be 48 */
1427 * The least significant four bits are the index, the other 28 bits are
1428 * the lock sequence number (0 to 64). See MS-SMB2 2.2.26
1430 __le32 LockSequenceNumber;
1431 __u64 PersistentFileId; /* opaque endianness */
1432 __u64 VolatileFileId; /* opaque endianness */
1433 /* Followed by at least one */
1434 struct smb2_lock_element locks[1];
1437 struct smb2_lock_rsp {
1438 struct smb2_sync_hdr sync_hdr;
1439 __le16 StructureSize; /* Must be 4 */
1443 struct smb2_echo_req {
1444 struct smb2_sync_hdr sync_hdr;
1445 __le16 StructureSize; /* Must be 4 */
1449 struct smb2_echo_rsp {
1450 struct smb2_sync_hdr sync_hdr;
1451 __le16 StructureSize; /* Must be 4 */
1455 /* search (query_directory) Flags field */
1456 #define SMB2_RESTART_SCANS 0x01
1457 #define SMB2_RETURN_SINGLE_ENTRY 0x02
1458 #define SMB2_INDEX_SPECIFIED 0x04
1459 #define SMB2_REOPEN 0x10
1461 #define SMB2_QUERY_DIRECTORY_IOV_SIZE 2
1463 struct smb2_query_directory_req {
1464 struct smb2_sync_hdr sync_hdr;
1465 __le16 StructureSize; /* Must be 33 */
1466 __u8 FileInformationClass;
1469 __u64 PersistentFileId; /* opaque endianness */
1470 __u64 VolatileFileId; /* opaque endianness */
1471 __le16 FileNameOffset;
1472 __le16 FileNameLength;
1473 __le32 OutputBufferLength;
1477 struct smb2_query_directory_rsp {
1478 struct smb2_sync_hdr sync_hdr;
1479 __le16 StructureSize; /* Must be 9 */
1480 __le16 OutputBufferOffset;
1481 __le32 OutputBufferLength;
1485 /* Possible InfoType values */
1486 #define SMB2_O_INFO_FILE 0x01
1487 #define SMB2_O_INFO_FILESYSTEM 0x02
1488 #define SMB2_O_INFO_SECURITY 0x03
1489 #define SMB2_O_INFO_QUOTA 0x04
1491 /* Security info type additionalinfo flags. See MS-SMB2 (2.2.37) or MS-DTYP */
1492 #define OWNER_SECINFO 0x00000001
1493 #define GROUP_SECINFO 0x00000002
1494 #define DACL_SECINFO 0x00000004
1495 #define SACL_SECINFO 0x00000008
1496 #define LABEL_SECINFO 0x00000010
1497 #define ATTRIBUTE_SECINFO 0x00000020
1498 #define SCOPE_SECINFO 0x00000040
1499 #define BACKUP_SECINFO 0x00010000
1500 #define UNPROTECTED_SACL_SECINFO 0x10000000
1501 #define UNPROTECTED_DACL_SECINFO 0x20000000
1502 #define PROTECTED_SACL_SECINFO 0x40000000
1503 #define PROTECTED_DACL_SECINFO 0x80000000
1505 /* Flags used for FileFullEAinfo */
1506 #define SL_RESTART_SCAN 0x00000001
1507 #define SL_RETURN_SINGLE_ENTRY 0x00000002
1508 #define SL_INDEX_SPECIFIED 0x00000004
1510 struct smb2_query_info_req {
1511 struct smb2_sync_hdr sync_hdr;
1512 __le16 StructureSize; /* Must be 41 */
1515 __le32 OutputBufferLength;
1516 __le16 InputBufferOffset;
1518 __le32 InputBufferLength;
1519 __le32 AdditionalInformation;
1521 __u64 PersistentFileId; /* opaque endianness */
1522 __u64 VolatileFileId; /* opaque endianness */
1526 struct smb2_query_info_rsp {
1527 struct smb2_sync_hdr sync_hdr;
1528 __le16 StructureSize; /* Must be 9 */
1529 __le16 OutputBufferOffset;
1530 __le32 OutputBufferLength;
1535 * Maximum number of iovs we need for a set-info request.
1536 * The largest one is rename/hardlink
1537 * [0] : struct smb2_set_info_req + smb2_file_[rename|link]_info
1539 * [2] : compound padding
1541 #define SMB2_SET_INFO_IOV_SIZE 3
1543 struct smb2_set_info_req {
1544 struct smb2_sync_hdr sync_hdr;
1545 __le16 StructureSize; /* Must be 33 */
1548 __le32 BufferLength;
1549 __le16 BufferOffset;
1551 __le32 AdditionalInformation;
1552 __u64 PersistentFileId; /* opaque endianness */
1553 __u64 VolatileFileId; /* opaque endianness */
1557 struct smb2_set_info_rsp {
1558 struct smb2_sync_hdr sync_hdr;
1559 __le16 StructureSize; /* Must be 2 */
1562 struct smb2_oplock_break {
1563 struct smb2_sync_hdr sync_hdr;
1564 __le16 StructureSize; /* Must be 24 */
1568 __u64 PersistentFid;
1572 #define SMB2_NOTIFY_BREAK_LEASE_FLAG_ACK_REQUIRED cpu_to_le32(0x01)
1574 struct smb2_lease_break {
1575 struct smb2_sync_hdr sync_hdr;
1576 __le16 StructureSize; /* Must be 44 */
1580 __le32 CurrentLeaseState;
1581 __le32 NewLeaseState;
1583 __le32 AccessMaskHint;
1584 __le32 ShareMaskHint;
1587 struct smb2_lease_ack {
1588 struct smb2_sync_hdr sync_hdr;
1589 __le16 StructureSize; /* Must be 36 */
1594 __le64 LeaseDuration;
1598 * PDU infolevel structure definitions
1599 * BB consider moving to a different header
1602 /* File System Information Classes */
1603 #define FS_VOLUME_INFORMATION 1 /* Query */
1604 #define FS_LABEL_INFORMATION 2 /* Local only */
1605 #define FS_SIZE_INFORMATION 3 /* Query */
1606 #define FS_DEVICE_INFORMATION 4 /* Query */
1607 #define FS_ATTRIBUTE_INFORMATION 5 /* Query */
1608 #define FS_CONTROL_INFORMATION 6 /* Query, Set */
1609 #define FS_FULL_SIZE_INFORMATION 7 /* Query */
1610 #define FS_OBJECT_ID_INFORMATION 8 /* Query, Set */
1611 #define FS_DRIVER_PATH_INFORMATION 9 /* Local only */
1612 #define FS_VOLUME_FLAGS_INFORMATION 10 /* Local only */
1613 #define FS_SECTOR_SIZE_INFORMATION 11 /* SMB3 or later. Query */
1614 #define FS_POSIX_INFORMATION 100 /* SMB3.1.1 POSIX. Query */
1616 struct smb2_fs_full_size_info {
1617 __le64 TotalAllocationUnits;
1618 __le64 CallerAvailableAllocationUnits;
1619 __le64 ActualAvailableAllocationUnits;
1620 __le32 SectorsPerAllocationUnit;
1621 __le32 BytesPerSector;
1624 #define SSINFO_FLAGS_ALIGNED_DEVICE 0x00000001
1625 #define SSINFO_FLAGS_PARTITION_ALIGNED_ON_DEVICE 0x00000002
1626 #define SSINFO_FLAGS_NO_SEEK_PENALTY 0x00000004
1627 #define SSINFO_FLAGS_TRIM_ENABLED 0x00000008
1629 /* sector size info struct */
1630 struct smb3_fs_ss_info {
1631 __le32 LogicalBytesPerSector;
1632 __le32 PhysicalBytesPerSectorForAtomicity;
1633 __le32 PhysicalBytesPerSectorForPerf;
1634 __le32 FileSystemEffectivePhysicalBytesPerSectorForAtomicity;
1636 __le32 ByteOffsetForSectorAlignment;
1637 __le32 ByteOffsetForPartitionAlignment;
1640 /* volume info struct - see MS-FSCC 2.5.9 */
1641 #define MAX_VOL_LABEL_LEN 32
1642 struct smb3_fs_vol_info {
1643 __le64 VolumeCreationTime;
1644 __u32 VolumeSerialNumber;
1645 __le32 VolumeLabelLength; /* includes trailing null */
1646 __u8 SupportsObjects; /* True if eg like NTFS, supports objects */
1648 __u8 VolumeLabel[]; /* variable len */
1651 /* partial list of QUERY INFO levels */
1652 #define FILE_DIRECTORY_INFORMATION 1
1653 #define FILE_FULL_DIRECTORY_INFORMATION 2
1654 #define FILE_BOTH_DIRECTORY_INFORMATION 3
1655 #define FILE_BASIC_INFORMATION 4
1656 #define FILE_STANDARD_INFORMATION 5
1657 #define FILE_INTERNAL_INFORMATION 6
1658 #define FILE_EA_INFORMATION 7
1659 #define FILE_ACCESS_INFORMATION 8
1660 #define FILE_NAME_INFORMATION 9
1661 #define FILE_RENAME_INFORMATION 10
1662 #define FILE_LINK_INFORMATION 11
1663 #define FILE_NAMES_INFORMATION 12
1664 #define FILE_DISPOSITION_INFORMATION 13
1665 #define FILE_POSITION_INFORMATION 14
1666 #define FILE_FULL_EA_INFORMATION 15
1667 #define FILE_MODE_INFORMATION 16
1668 #define FILE_ALIGNMENT_INFORMATION 17
1669 #define FILE_ALL_INFORMATION 18
1670 #define FILE_ALLOCATION_INFORMATION 19
1671 #define FILE_END_OF_FILE_INFORMATION 20
1672 #define FILE_ALTERNATE_NAME_INFORMATION 21
1673 #define FILE_STREAM_INFORMATION 22
1674 #define FILE_PIPE_INFORMATION 23
1675 #define FILE_PIPE_LOCAL_INFORMATION 24
1676 #define FILE_PIPE_REMOTE_INFORMATION 25
1677 #define FILE_MAILSLOT_QUERY_INFORMATION 26
1678 #define FILE_MAILSLOT_SET_INFORMATION 27
1679 #define FILE_COMPRESSION_INFORMATION 28
1680 #define FILE_OBJECT_ID_INFORMATION 29
1681 /* Number 30 not defined in documents */
1682 #define FILE_MOVE_CLUSTER_INFORMATION 31
1683 #define FILE_QUOTA_INFORMATION 32
1684 #define FILE_REPARSE_POINT_INFORMATION 33
1685 #define FILE_NETWORK_OPEN_INFORMATION 34
1686 #define FILE_ATTRIBUTE_TAG_INFORMATION 35
1687 #define FILE_TRACKING_INFORMATION 36
1688 #define FILEID_BOTH_DIRECTORY_INFORMATION 37
1689 #define FILEID_FULL_DIRECTORY_INFORMATION 38
1690 #define FILE_VALID_DATA_LENGTH_INFORMATION 39
1691 #define FILE_SHORT_NAME_INFORMATION 40
1692 #define FILE_SFIO_RESERVE_INFORMATION 44
1693 #define FILE_SFIO_VOLUME_INFORMATION 45
1694 #define FILE_HARD_LINK_INFORMATION 46
1695 #define FILE_NORMALIZED_NAME_INFORMATION 48
1696 #define FILEID_GLOBAL_TX_DIRECTORY_INFORMATION 50
1697 #define FILE_STANDARD_LINK_INFORMATION 54
1698 #define FILE_ID_INFORMATION 59
1700 struct smb2_file_internal_info {
1702 } __packed; /* level 6 Query */
1704 struct smb2_file_rename_info { /* encoding of request for level 10 */
1705 __u8 ReplaceIfExists; /* 1 = replace existing target with new */
1706 /* 0 = fail if target already exists */
1708 __u64 RootDirectory; /* MBZ for network operations (why says spec?) */
1709 __le32 FileNameLength;
1710 char FileName[]; /* New name to be assigned */
1711 /* padding - overall struct size must be >= 24 so filename + pad >= 6 */
1712 } __packed; /* level 10 Set */
1714 struct smb2_file_link_info { /* encoding of request for level 11 */
1715 __u8 ReplaceIfExists; /* 1 = replace existing link with new */
1716 /* 0 = fail if link already exists */
1718 __u64 RootDirectory; /* MBZ for network operations (why says spec?) */
1719 __le32 FileNameLength;
1720 char FileName[]; /* Name to be assigned to new link */
1721 } __packed; /* level 11 Set */
1723 struct smb2_file_full_ea_info { /* encoding of response for level 15 */
1724 __le32 next_entry_offset;
1726 __u8 ea_name_length;
1727 __le16 ea_value_length;
1728 char ea_data[]; /* \0 terminated name plus value */
1729 } __packed; /* level 15 Set */
1732 * This level 18, although with struct with same name is different from cifs
1733 * level 0x107. Level 0x107 has an extra u64 between AccessFlags and
1734 * CurrentByteOffset.
1736 struct smb2_file_all_info { /* data block encoding of response to level 18 */
1737 __le64 CreationTime; /* Beginning of FILE_BASIC_INFO equivalent */
1738 __le64 LastAccessTime;
1739 __le64 LastWriteTime;
1742 __u32 Pad1; /* End of FILE_BASIC_INFO_INFO equivalent */
1743 __le64 AllocationSize; /* Beginning of FILE_STANDARD_INFO equivalent */
1744 __le64 EndOfFile; /* size ie offset to first free byte in file */
1745 __le32 NumberOfLinks; /* hard links */
1748 __u16 Pad2; /* End of FILE_STANDARD_INFO equivalent */
1752 __le64 CurrentByteOffset;
1754 __le32 AlignmentRequirement;
1755 __le32 FileNameLength;
1757 } __packed; /* level 18 Query */
1759 struct smb2_file_eof_info { /* encoding of request for level 10 */
1760 __le64 EndOfFile; /* new end of file value */
1761 } __packed; /* level 20 Set */
1763 struct smb2_file_reparse_point_info {
1768 struct smb2_file_network_open_info {
1769 __le64 CreationTime;
1770 __le64 LastAccessTime;
1771 __le64 LastWriteTime;
1773 __le64 AllocationSize;
1777 } __packed; /* level 34 Query also similar returned in close rsp and open rsp */
1779 /* See MS-FSCC 2.4.43 */
1780 struct smb2_file_id_information {
1781 __le64 VolumeSerialNumber;
1782 __u64 PersistentFileId; /* opaque endianness */
1783 __u64 VolatileFileId; /* opaque endianness */
1784 } __packed; /* level 59 */
1786 extern char smb2_padding[7];
1788 /* equivalent of the contents of SMB3.1.1 POSIX open context response */
1789 struct create_posix_rsp {
1793 struct cifs_sid owner; /* var-sized on the wire */
1794 struct cifs_sid group; /* var-sized on the wire */
1798 * SMB2-only POSIX info level for query dir
1800 * See posix_info_sid_size(), posix_info_extra_size() and
1801 * posix_info_parse() to help with the handling of this struct.
1803 struct smb2_posix_info {
1804 __le32 NextEntryOffset;
1806 __le64 CreationTime;
1807 __le64 LastAccessTime;
1808 __le64 LastWriteTime;
1811 __le64 AllocationSize;
1812 __le32 DosAttributes;
1816 /* beginning of POSIX Create Context Response */
1821 * var sized owner SID
1822 * var sized group SID
1823 * le32 filenamelength
1828 /* Level 100 query info */
1829 struct smb311_posix_qinfo {
1830 __le64 CreationTime;
1831 __le64 LastAccessTime;
1832 __le64 LastWriteTime;
1835 __le64 AllocationSize;
1836 __le32 DosAttributes;
1840 /* beginning of POSIX Create Context Response */
1846 * var sized owner SID
1847 * var sized group SID
1848 * le32 filenamelength
1854 * Parsed version of the above struct. Allows direct access to the
1855 * variable length fields
1857 struct smb2_posix_info_parsed {
1858 const struct smb2_posix_info *base;
1860 struct cifs_sid owner;
1861 struct cifs_sid group;
1866 #endif /* _SMB2PDU_H */