4 * Copyright (c) International Business Machines Corp., 2009, 2013
6 * Author(s): Steve French (sfrench@us.ibm.com)
7 * Pavel Shilovsky (pshilovsky@samba.org) 2012
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 {
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_CHAINDED 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 */
166 /* See MS-SMB2 2.2.42.2 */
167 struct compression_pattern_payload_v1 {
174 /* See MS-SMB2 2.2.43 */
175 struct smb2_rdma_transform {
176 __le16 RdmaDescriptorOffset;
177 __le16 RdmaDescriptorLength;
178 __le32 Channel; /* for values see channel description in smb2 read above */
179 __le16 TransformCount;
184 struct smb2_rdma_encryption_transform {
185 __le16 TransformType;
186 __le16 SignatureLength;
189 __u8 Signature[]; /* variable length */
191 /* followed by padding */
195 * SMB2 flag definitions
197 #define SMB2_FLAGS_SERVER_TO_REDIR cpu_to_le32(0x00000001)
198 #define SMB2_FLAGS_ASYNC_COMMAND cpu_to_le32(0x00000002)
199 #define SMB2_FLAGS_RELATED_OPERATIONS cpu_to_le32(0x00000004)
200 #define SMB2_FLAGS_SIGNED cpu_to_le32(0x00000008)
201 #define SMB2_FLAGS_PRIORITY_MASK cpu_to_le32(0x00000070) /* SMB3.1.1 */
202 #define SMB2_FLAGS_DFS_OPERATIONS cpu_to_le32(0x10000000)
203 #define SMB2_FLAGS_REPLAY_OPERATION cpu_to_le32(0x20000000) /* SMB3 & up */
206 * Definitions for SMB2 Protocol Data Units (network frames)
208 * See MS-SMB2.PDF specification for protocol details.
209 * The Naming convention is the lower case version of the SMB2
210 * command code name for the struct. Note that structures must be packed.
214 #define COMPOUND_FID 0xFFFFFFFFFFFFFFFFULL
216 #define SMB2_ERROR_STRUCTURE_SIZE2 cpu_to_le16(9)
218 struct smb2_err_rsp {
219 struct smb2_sync_hdr sync_hdr;
220 __le16 StructureSize;
221 __le16 Reserved; /* MBZ */
222 __le32 ByteCount; /* even if zero, at least one byte follows */
223 __u8 ErrorData[1]; /* variable length */
226 #define SYMLINK_ERROR_TAG 0x4c4d5953
228 struct smb2_symlink_err_rsp {
229 __le32 SymLinkLength;
230 __le32 SymLinkErrorTag;
232 __le16 ReparseDataLength;
233 __le16 UnparsedPathLength;
234 __le16 SubstituteNameOffset;
235 __le16 SubstituteNameLength;
236 __le16 PrintNameOffset;
237 __le16 PrintNameLength;
242 /* SMB 3.1.1 and later dialects. See MS-SMB2 section 2.2.2.1 */
243 struct smb2_error_context_rsp {
244 __le32 ErrorDataLength;
246 __u8 ErrorContextData; /* ErrorDataLength long array */
250 #define SMB2_ERROR_ID_DEFAULT 0x00000000
251 #define SMB2_ERROR_ID_SHARE_REDIRECT cpu_to_le32(0x72645253) /* "rdRS" */
253 /* Defines for Type field below (see MS-SMB2 2.2.2.2.2.1) */
254 #define MOVE_DST_IPADDR_V4 cpu_to_le32(0x00000001)
255 #define MOVE_DST_IPADDR_V6 cpu_to_le32(0x00000002)
257 struct move_dst_ipaddr {
260 __u8 address[16]; /* IPv4 followed by 12 bytes rsvd or IPv6 address */
263 struct share_redirect_error_context_rsp {
264 __le32 StructureSize;
265 __le32 NotificationType;
266 __le32 ResourceNameOffset;
267 __le32 ResourceNameLength;
271 struct move_dst_ipaddr IpAddrMoveList[];
272 /* __u8 ResourceName[] */ /* Name of share as counted Unicode string */
275 #define SMB2_CLIENT_GUID_SIZE 16
277 struct smb2_negotiate_req {
278 struct smb2_sync_hdr sync_hdr;
279 __le16 StructureSize; /* Must be 36 */
282 __le16 Reserved; /* MBZ */
284 __u8 ClientGUID[SMB2_CLIENT_GUID_SIZE];
285 /* In SMB3.02 and earlier next three were MBZ le64 ClientStartTime */
286 __le32 NegotiateContextOffset; /* SMB3.1.1 only. MBZ earlier */
287 __le16 NegotiateContextCount; /* SMB3.1.1 only. MBZ earlier */
289 __le16 Dialects[1]; /* One dialect (vers=) at a time for now */
293 #define SMB10_PROT_ID 0x0000 /* local only, not sent on wire w/CIFS negprot */
294 #define SMB20_PROT_ID 0x0202
295 #define SMB21_PROT_ID 0x0210
296 #define SMB30_PROT_ID 0x0300
297 #define SMB302_PROT_ID 0x0302
298 #define SMB311_PROT_ID 0x0311
299 #define BAD_PROT_ID 0xFFFF
301 /* SecurityMode flags */
302 #define SMB2_NEGOTIATE_SIGNING_ENABLED 0x0001
303 #define SMB2_NEGOTIATE_SIGNING_REQUIRED 0x0002
304 #define SMB2_SEC_MODE_FLAGS_ALL 0x0003
306 /* Capabilities flags */
307 #define SMB2_GLOBAL_CAP_DFS 0x00000001
308 #define SMB2_GLOBAL_CAP_LEASING 0x00000002 /* Resp only New to SMB2.1 */
309 #define SMB2_GLOBAL_CAP_LARGE_MTU 0X00000004 /* Resp only New to SMB2.1 */
310 #define SMB2_GLOBAL_CAP_MULTI_CHANNEL 0x00000008 /* New to SMB3 */
311 #define SMB2_GLOBAL_CAP_PERSISTENT_HANDLES 0x00000010 /* New to SMB3 */
312 #define SMB2_GLOBAL_CAP_DIRECTORY_LEASING 0x00000020 /* New to SMB3 */
313 #define SMB2_GLOBAL_CAP_ENCRYPTION 0x00000040 /* New to SMB3 */
315 #define SMB2_NT_FIND 0x00100000
316 #define SMB2_LARGE_FILES 0x00200000
319 /* Negotiate Contexts - ContextTypes. See MS-SMB2 section 2.2.3.1 for details */
320 #define SMB2_PREAUTH_INTEGRITY_CAPABILITIES cpu_to_le16(1)
321 #define SMB2_ENCRYPTION_CAPABILITIES cpu_to_le16(2)
322 #define SMB2_COMPRESSION_CAPABILITIES cpu_to_le16(3)
323 #define SMB2_NETNAME_NEGOTIATE_CONTEXT_ID cpu_to_le16(5)
324 #define SMB2_TRANSPORT_CAPABILITIES cpu_to_le16(6)
325 #define SMB2_RDMA_TRANSFORM_CAPABILITIES cpu_to_le16(7)
326 #define SMB2_SIGNING_CAPABILITIES cpu_to_le16(8)
327 #define SMB2_POSIX_EXTENSIONS_AVAILABLE cpu_to_le16(0x100)
329 struct smb2_neg_context {
333 /* Followed by array of data */
336 #define SMB311_SALT_SIZE 32
337 /* Hash Algorithm Types */
338 #define SMB2_PREAUTH_INTEGRITY_SHA512 cpu_to_le16(0x0001)
339 #define SMB2_PREAUTH_HASH_SIZE 64
341 #define MIN_PREAUTH_CTXT_DATA_LEN (SMB311_SALT_SIZE + 6)
342 struct smb2_preauth_neg_context {
343 __le16 ContextType; /* 1 */
346 __le16 HashAlgorithmCount; /* 1 */
348 __le16 HashAlgorithms; /* HashAlgorithms[0] since only one defined */
349 __u8 Salt[SMB311_SALT_SIZE];
352 /* Encryption Algorithms Ciphers */
353 #define SMB2_ENCRYPTION_AES128_CCM cpu_to_le16(0x0001)
354 #define SMB2_ENCRYPTION_AES128_GCM cpu_to_le16(0x0002)
355 #define SMB2_ENCRYPTION_AES256_CCM cpu_to_le16(0x0003)
356 #define SMB2_ENCRYPTION_AES256_GCM cpu_to_le16(0x0004)
358 /* Min encrypt context data is one cipher so 2 bytes + 2 byte count field */
359 #define MIN_ENCRYPT_CTXT_DATA_LEN 4
360 struct smb2_encryption_neg_context {
361 __le16 ContextType; /* 2 */
364 /* CipherCount usally 2, but can be 3 when AES256-GCM enabled */
365 __le16 CipherCount; /* AES128-GCM and AES128-CCM by default */
369 /* See MS-SMB2 2.2.3.1.3 */
370 #define SMB3_COMPRESS_NONE cpu_to_le16(0x0000)
371 #define SMB3_COMPRESS_LZNT1 cpu_to_le16(0x0001)
372 #define SMB3_COMPRESS_LZ77 cpu_to_le16(0x0002)
373 #define SMB3_COMPRESS_LZ77_HUFF cpu_to_le16(0x0003)
374 /* Pattern scanning algorithm See MS-SMB2 3.1.4.4.1 */
375 #define SMB3_COMPRESS_PATTERN cpu_to_le16(0x0004) /* Pattern_V1 */
377 /* Compression Flags */
378 #define SMB2_COMPRESSION_CAPABILITIES_FLAG_NONE cpu_to_le32(0x00000000)
379 #define SMB2_COMPRESSION_CAPABILITIES_FLAG_CHAINED cpu_to_le32(0x00000001)
381 struct smb2_compression_capabilities_context {
382 __le16 ContextType; /* 3 */
385 __le16 CompressionAlgorithmCount;
388 __le16 CompressionAlgorithms[3];
392 * For smb2_netname_negotiate_context_id See MS-SMB2 2.2.3.1.4.
393 * Its struct simply contains NetName, an array of Unicode characters
395 struct smb2_netname_neg_context {
396 __le16 ContextType; /* 5 */
399 __le16 NetName[]; /* hostname of target converted to UCS-2 */
403 * For rdma transform capabilities context see MS-SMB2 2.2.3.1.6
407 /* RDMA Transform IDs */
408 #define SMB2_RDMA_TRANSFORM_NONE 0x0000
409 #define SMB2_RDMA_TRANSFORM_ENCRYPTION 0x0001
411 struct smb2_rdma_transform_capabilities_context {
412 __le16 ContextType; /* 7 */
415 __le16 TransformCount;
418 __le16 RDMATransformIds[1];
421 /* Signing algorithms */
422 #define SIGNING_ALG_HMAC_SHA256 0
423 #define SIGNING_ALG_AES_CMAC 1
424 #define SIGNING_ALG_AES_GMAC 2
426 struct smb2_signing_capabilities {
427 __le16 ContextType; /* 8 */
430 __le16 SigningAlgorithmCount;
431 __le16 SigningAlgorithms[];
434 #define POSIX_CTXT_DATA_LEN 16
435 struct smb2_posix_neg_context {
436 __le16 ContextType; /* 0x100 */
439 __u8 Name[16]; /* POSIX ctxt GUID 93AD25509CB411E7B42383DE968BCD7C */
442 struct smb2_negotiate_rsp {
443 struct smb2_sync_hdr sync_hdr;
444 __le16 StructureSize; /* Must be 65 */
446 __le16 DialectRevision;
447 __le16 NegotiateContextCount; /* Prior to SMB3.1.1 was Reserved & MBZ */
450 __le32 MaxTransactSize;
453 __le64 SystemTime; /* MBZ */
454 __le64 ServerStartTime;
455 __le16 SecurityBufferOffset;
456 __le16 SecurityBufferLength;
457 __le32 NegotiateContextOffset; /* Pre:SMB3.1.1 was reserved/ignored */
458 __u8 Buffer[1]; /* variable length GSS security buffer */
462 #define SMB2_SESSION_REQ_FLAG_BINDING 0x01
463 #define SMB2_SESSION_REQ_FLAG_ENCRYPT_DATA 0x04
465 struct smb2_sess_setup_req {
466 struct smb2_sync_hdr sync_hdr;
467 __le16 StructureSize; /* Must be 25 */
472 __le16 SecurityBufferOffset;
473 __le16 SecurityBufferLength;
474 __u64 PreviousSessionId;
475 __u8 Buffer[1]; /* variable length GSS security buffer */
478 /* Currently defined SessionFlags */
479 #define SMB2_SESSION_FLAG_IS_GUEST 0x0001
480 #define SMB2_SESSION_FLAG_IS_NULL 0x0002
481 #define SMB2_SESSION_FLAG_ENCRYPT_DATA 0x0004
482 struct smb2_sess_setup_rsp {
483 struct smb2_sync_hdr sync_hdr;
484 __le16 StructureSize; /* Must be 9 */
486 __le16 SecurityBufferOffset;
487 __le16 SecurityBufferLength;
488 __u8 Buffer[1]; /* variable length GSS security buffer */
491 struct smb2_logoff_req {
492 struct smb2_sync_hdr sync_hdr;
493 __le16 StructureSize; /* Must be 4 */
497 struct smb2_logoff_rsp {
498 struct smb2_sync_hdr sync_hdr;
499 __le16 StructureSize; /* Must be 4 */
503 /* Flags/Reserved for SMB3.1.1 */
504 #define SMB2_TREE_CONNECT_FLAG_CLUSTER_RECONNECT cpu_to_le16(0x0001)
505 #define SMB2_TREE_CONNECT_FLAG_REDIRECT_TO_OWNER cpu_to_le16(0x0002)
506 #define SMB2_TREE_CONNECT_FLAG_EXTENSION_PRESENT cpu_to_le16(0x0004)
508 struct smb2_tree_connect_req {
509 struct smb2_sync_hdr sync_hdr;
510 __le16 StructureSize; /* Must be 9 */
511 __le16 Flags; /* Reserved MBZ for dialects prior to SMB3.1.1 */
514 __u8 Buffer[1]; /* variable length */
517 /* See MS-SMB2 section 2.2.9.2 */
519 #define SMB2_RESERVED_TREE_CONNECT_CONTEXT_ID 0x0000
520 #define SMB2_REMOTED_IDENTITY_TREE_CONNECT_CONTEXT_ID cpu_to_le16(0x0001)
522 struct tree_connect_contexts {
529 /* Remoted identity tree connect context structures - see MS-SMB2 2.2.9.2.1 */
530 struct smb3_blob_data {
535 /* Valid values for Attr */
536 #define SE_GROUP_MANDATORY 0x00000001
537 #define SE_GROUP_ENABLED_BY_DEFAULT 0x00000002
538 #define SE_GROUP_ENABLED 0x00000004
539 #define SE_GROUP_OWNER 0x00000008
540 #define SE_GROUP_USE_FOR_DENY_ONLY 0x00000010
541 #define SE_GROUP_INTEGRITY 0x00000020
542 #define SE_GROUP_INTEGRITY_ENABLED 0x00000040
543 #define SE_GROUP_RESOURCE 0x20000000
544 #define SE_GROUP_LOGON_ID 0xC0000000
546 /* struct sid_attr_data is SidData array in BlobData format then le32 Attr */
548 struct sid_array_data {
550 /* SidAttrList - array of sid_attr_data structs */
553 struct luid_attr_data {
558 * struct privilege_data is the same as BLOB_DATA - see MS-SMB2 2.2.9.2.1.5
559 * but with size of LUID_ATTR_DATA struct and BlobData set to LUID_ATTR DATA
562 struct privilege_array_data {
563 __le16 PrivilegeCount;
564 /* array of privilege_data structs */
567 struct remoted_identity_tcon_context {
568 __le16 TicketType; /* must be 0x0001 */
569 __le16 TicketSize; /* total size of this struct */
570 __le16 User; /* offset to SID_ATTR_DATA struct with user info */
571 __le16 UserName; /* offset to null terminated Unicode username string */
572 __le16 Domain; /* offset to null terminated Unicode domain name */
573 __le16 Groups; /* offset to SID_ARRAY_DATA struct with group info */
574 __le16 RestrictedGroups; /* similar to above */
575 __le16 Privileges; /* offset to PRIVILEGE_ARRAY_DATA struct */
576 __le16 PrimaryGroup; /* offset to SID_ARRAY_DATA struct */
577 __le16 Owner; /* offset to BLOB_DATA struct */
578 __le16 DefaultDacl; /* offset to BLOB_DATA struct */
579 __le16 DeviceGroups; /* offset to SID_ARRAY_DATA struct */
580 __le16 UserClaims; /* offset to BLOB_DATA struct */
581 __le16 DeviceClaims; /* offset to BLOB_DATA struct */
582 __u8 TicketInfo[]; /* variable length buf - remoted identity data */
585 struct smb2_tree_connect_req_extension {
586 __le32 TreeConnectContextOffset;
587 __le16 TreeConnectContextCount;
589 __u8 PathName[]; /* variable sized array */
590 /* followed by array of TreeConnectContexts */
593 struct smb2_tree_connect_rsp {
594 struct smb2_sync_hdr sync_hdr;
595 __le16 StructureSize; /* Must be 16 */
596 __u8 ShareType; /* see below */
598 __le32 ShareFlags; /* see below */
599 __le32 Capabilities; /* see below */
600 __le32 MaximalAccess;
603 /* Possible ShareType values */
604 #define SMB2_SHARE_TYPE_DISK 0x01
605 #define SMB2_SHARE_TYPE_PIPE 0x02
606 #define SMB2_SHARE_TYPE_PRINT 0x03
609 * Possible ShareFlags - exactly one and only one of the first 4 caching flags
610 * must be set (any of the remaining, SHI1005, flags may be set individually
613 #define SMB2_SHAREFLAG_MANUAL_CACHING 0x00000000
614 #define SMB2_SHAREFLAG_AUTO_CACHING 0x00000010
615 #define SMB2_SHAREFLAG_VDO_CACHING 0x00000020
616 #define SMB2_SHAREFLAG_NO_CACHING 0x00000030
617 #define SHI1005_FLAGS_DFS 0x00000001
618 #define SHI1005_FLAGS_DFS_ROOT 0x00000002
619 #define SHI1005_FLAGS_RESTRICT_EXCLUSIVE_OPENS 0x00000100
620 #define SHI1005_FLAGS_FORCE_SHARED_DELETE 0x00000200
621 #define SHI1005_FLAGS_ALLOW_NAMESPACE_CACHING 0x00000400
622 #define SHI1005_FLAGS_ACCESS_BASED_DIRECTORY_ENUM 0x00000800
623 #define SHI1005_FLAGS_FORCE_LEVELII_OPLOCK 0x00001000
624 #define SHI1005_FLAGS_ENABLE_HASH_V1 0x00002000
625 #define SHI1005_FLAGS_ENABLE_HASH_V2 0x00004000
626 #define SHI1005_FLAGS_ENCRYPT_DATA 0x00008000
627 #define SMB2_SHAREFLAG_IDENTITY_REMOTING 0x00040000 /* 3.1.1 */
628 #define SHI1005_FLAGS_ALL 0x0004FF33
630 /* Possible share capabilities */
631 #define SMB2_SHARE_CAP_DFS cpu_to_le32(0x00000008) /* all dialects */
632 #define SMB2_SHARE_CAP_CONTINUOUS_AVAILABILITY cpu_to_le32(0x00000010) /* 3.0 */
633 #define SMB2_SHARE_CAP_SCALEOUT cpu_to_le32(0x00000020) /* 3.0 */
634 #define SMB2_SHARE_CAP_CLUSTER cpu_to_le32(0x00000040) /* 3.0 */
635 #define SMB2_SHARE_CAP_ASYMMETRIC cpu_to_le32(0x00000080) /* 3.02 */
636 #define SMB2_SHARE_CAP_REDIRECT_TO_OWNER cpu_to_le32(0x00000100) /* 3.1.1 */
638 struct smb2_tree_disconnect_req {
639 struct smb2_sync_hdr sync_hdr;
640 __le16 StructureSize; /* Must be 4 */
644 struct smb2_tree_disconnect_rsp {
645 struct smb2_sync_hdr sync_hdr;
646 __le16 StructureSize; /* Must be 4 */
650 /* File Attrubutes */
651 #define FILE_ATTRIBUTE_READONLY 0x00000001
652 #define FILE_ATTRIBUTE_HIDDEN 0x00000002
653 #define FILE_ATTRIBUTE_SYSTEM 0x00000004
654 #define FILE_ATTRIBUTE_DIRECTORY 0x00000010
655 #define FILE_ATTRIBUTE_ARCHIVE 0x00000020
656 #define FILE_ATTRIBUTE_NORMAL 0x00000080
657 #define FILE_ATTRIBUTE_TEMPORARY 0x00000100
658 #define FILE_ATTRIBUTE_SPARSE_FILE 0x00000200
659 #define FILE_ATTRIBUTE_REPARSE_POINT 0x00000400
660 #define FILE_ATTRIBUTE_COMPRESSED 0x00000800
661 #define FILE_ATTRIBUTE_OFFLINE 0x00001000
662 #define FILE_ATTRIBUTE_NOT_CONTENT_INDEXED 0x00002000
663 #define FILE_ATTRIBUTE_ENCRYPTED 0x00004000
664 #define FILE_ATTRIBUTE_INTEGRITY_STREAM 0x00008000
665 #define FILE_ATTRIBUTE_NO_SCRUB_DATA 0x00020000
668 #define SMB2_OPLOCK_LEVEL_NONE 0x00
669 #define SMB2_OPLOCK_LEVEL_II 0x01
670 #define SMB2_OPLOCK_LEVEL_EXCLUSIVE 0x08
671 #define SMB2_OPLOCK_LEVEL_BATCH 0x09
672 #define SMB2_OPLOCK_LEVEL_LEASE 0xFF
673 /* Non-spec internal type */
674 #define SMB2_OPLOCK_LEVEL_NOCHANGE 0x99
676 /* Desired Access Flags */
677 #define FILE_READ_DATA_LE cpu_to_le32(0x00000001)
678 #define FILE_WRITE_DATA_LE cpu_to_le32(0x00000002)
679 #define FILE_APPEND_DATA_LE cpu_to_le32(0x00000004)
680 #define FILE_READ_EA_LE cpu_to_le32(0x00000008)
681 #define FILE_WRITE_EA_LE cpu_to_le32(0x00000010)
682 #define FILE_EXECUTE_LE cpu_to_le32(0x00000020)
683 #define FILE_READ_ATTRIBUTES_LE cpu_to_le32(0x00000080)
684 #define FILE_WRITE_ATTRIBUTES_LE cpu_to_le32(0x00000100)
685 #define FILE_DELETE_LE cpu_to_le32(0x00010000)
686 #define FILE_READ_CONTROL_LE cpu_to_le32(0x00020000)
687 #define FILE_WRITE_DAC_LE cpu_to_le32(0x00040000)
688 #define FILE_WRITE_OWNER_LE cpu_to_le32(0x00080000)
689 #define FILE_SYNCHRONIZE_LE cpu_to_le32(0x00100000)
690 #define FILE_ACCESS_SYSTEM_SECURITY_LE cpu_to_le32(0x01000000)
691 #define FILE_MAXIMAL_ACCESS_LE cpu_to_le32(0x02000000)
692 #define FILE_GENERIC_ALL_LE cpu_to_le32(0x10000000)
693 #define FILE_GENERIC_EXECUTE_LE cpu_to_le32(0x20000000)
694 #define FILE_GENERIC_WRITE_LE cpu_to_le32(0x40000000)
695 #define FILE_GENERIC_READ_LE cpu_to_le32(0x80000000)
697 /* ShareAccess Flags */
698 #define FILE_SHARE_READ_LE cpu_to_le32(0x00000001)
699 #define FILE_SHARE_WRITE_LE cpu_to_le32(0x00000002)
700 #define FILE_SHARE_DELETE_LE cpu_to_le32(0x00000004)
701 #define FILE_SHARE_ALL_LE cpu_to_le32(0x00000007)
703 /* CreateDisposition Flags */
704 #define FILE_SUPERSEDE_LE cpu_to_le32(0x00000000)
705 #define FILE_OPEN_LE cpu_to_le32(0x00000001)
706 #define FILE_CREATE_LE cpu_to_le32(0x00000002)
707 #define FILE_OPEN_IF_LE cpu_to_le32(0x00000003)
708 #define FILE_OVERWRITE_LE cpu_to_le32(0x00000004)
709 #define FILE_OVERWRITE_IF_LE cpu_to_le32(0x00000005)
711 /* CreateOptions Flags */
712 #define FILE_DIRECTORY_FILE_LE cpu_to_le32(0x00000001)
713 /* same as #define CREATE_NOT_FILE_LE cpu_to_le32(0x00000001) */
714 #define FILE_WRITE_THROUGH_LE cpu_to_le32(0x00000002)
715 #define FILE_SEQUENTIAL_ONLY_LE cpu_to_le32(0x00000004)
716 #define FILE_NO_INTERMEDIATE_BUFFERRING_LE cpu_to_le32(0x00000008)
717 #define FILE_SYNCHRONOUS_IO_ALERT_LE cpu_to_le32(0x00000010)
718 #define FILE_SYNCHRONOUS_IO_NON_ALERT_LE cpu_to_le32(0x00000020)
719 #define FILE_NON_DIRECTORY_FILE_LE cpu_to_le32(0x00000040)
720 #define FILE_COMPLETE_IF_OPLOCKED_LE cpu_to_le32(0x00000100)
721 #define FILE_NO_EA_KNOWLEDGE_LE cpu_to_le32(0x00000200)
722 #define FILE_RANDOM_ACCESS_LE cpu_to_le32(0x00000800)
723 #define FILE_DELETE_ON_CLOSE_LE cpu_to_le32(0x00001000)
724 #define FILE_OPEN_BY_FILE_ID_LE cpu_to_le32(0x00002000)
725 #define FILE_OPEN_FOR_BACKUP_INTENT_LE cpu_to_le32(0x00004000)
726 #define FILE_NO_COMPRESSION_LE cpu_to_le32(0x00008000)
727 #define FILE_RESERVE_OPFILTER_LE cpu_to_le32(0x00100000)
728 #define FILE_OPEN_REPARSE_POINT_LE cpu_to_le32(0x00200000)
729 #define FILE_OPEN_NO_RECALL_LE cpu_to_le32(0x00400000)
730 #define FILE_OPEN_FOR_FREE_SPACE_QUERY_LE cpu_to_le32(0x00800000)
732 #define FILE_READ_RIGHTS_LE (FILE_READ_DATA_LE | FILE_READ_EA_LE \
733 | FILE_READ_ATTRIBUTES_LE)
734 #define FILE_WRITE_RIGHTS_LE (FILE_WRITE_DATA_LE | FILE_APPEND_DATA_LE \
735 | FILE_WRITE_EA_LE | FILE_WRITE_ATTRIBUTES_LE)
736 #define FILE_EXEC_RIGHTS_LE (FILE_EXECUTE_LE)
738 /* Impersonation Levels. See MS-WPO section 9.7 and MSDN-IMPERS */
739 #define IL_ANONYMOUS cpu_to_le32(0x00000000)
740 #define IL_IDENTIFICATION cpu_to_le32(0x00000001)
741 #define IL_IMPERSONATION cpu_to_le32(0x00000002)
742 #define IL_DELEGATE cpu_to_le32(0x00000003)
744 /* Create Context Values */
745 #define SMB2_CREATE_EA_BUFFER "ExtA" /* extended attributes */
746 #define SMB2_CREATE_SD_BUFFER "SecD" /* security descriptor */
747 #define SMB2_CREATE_DURABLE_HANDLE_REQUEST "DHnQ"
748 #define SMB2_CREATE_DURABLE_HANDLE_RECONNECT "DHnC"
749 #define SMB2_CREATE_ALLOCATION_SIZE "AISi"
750 #define SMB2_CREATE_QUERY_MAXIMAL_ACCESS_REQUEST "MxAc"
751 #define SMB2_CREATE_TIMEWARP_REQUEST "TWrp"
752 #define SMB2_CREATE_QUERY_ON_DISK_ID "QFid"
753 #define SMB2_CREATE_REQUEST_LEASE "RqLs"
754 #define SMB2_CREATE_DURABLE_HANDLE_REQUEST_V2 "DH2Q"
755 #define SMB2_CREATE_DURABLE_HANDLE_RECONNECT_V2 "DH2C"
756 #define SMB2_CREATE_APP_INSTANCE_ID 0x45BCA66AEFA7F74A9008FA462E144D74
757 #define SMB2_CREATE_APP_INSTANCE_VERSION 0xB982D0B73B56074FA07B524A8116A010
758 #define SVHDX_OPEN_DEVICE_CONTEX 0x9CCBCF9E04C1E643980E158DA1F6EC83
759 #define SMB2_CREATE_TAG_POSIX 0x93AD25509CB411E7B42383DE968BCD7C
761 /* Flag (SMB3 open response) values */
762 #define SMB2_CREATE_FLAG_REPARSEPOINT 0x01
765 * Maximum number of iovs we need for an open/create request.
766 * [0] : struct smb2_create_req
768 * [2] : lease context
769 * [3] : durable context
770 * [4] : posix context
771 * [5] : time warp context
772 * [6] : query id context
773 * [7] : compound padding
775 #define SMB2_CREATE_IOV_SIZE 8
777 struct smb2_create_req {
778 struct smb2_sync_hdr sync_hdr;
779 __le16 StructureSize; /* Must be 57 */
781 __u8 RequestedOplockLevel;
782 __le32 ImpersonationLevel;
783 __le64 SmbCreateFlags;
785 __le32 DesiredAccess;
786 __le32 FileAttributes;
788 __le32 CreateDisposition;
789 __le32 CreateOptions;
792 __le32 CreateContextsOffset;
793 __le32 CreateContextsLength;
798 * Maximum size of a SMB2_CREATE response is 64 (smb2 header) +
799 * 88 (fixed part of create response) + 520 (path) + 208 (contexts) +
800 * 2 bytes of padding.
802 #define MAX_SMB2_CREATE_RESPONSE_SIZE 880
804 struct smb2_create_rsp {
805 struct smb2_sync_hdr sync_hdr;
806 __le16 StructureSize; /* Must be 89 */
808 __u8 Flag; /* 0x01 if reparse point */
811 __le64 LastAccessTime;
812 __le64 LastWriteTime;
814 __le64 AllocationSize;
816 __le32 FileAttributes;
818 __u64 PersistentFileId; /* opaque endianness */
819 __u64 VolatileFileId; /* opaque endianness */
820 __le32 CreateContextsOffset;
821 __le32 CreateContextsLength;
825 struct create_context {
835 #define SMB2_LEASE_READ_CACHING_HE 0x01
836 #define SMB2_LEASE_HANDLE_CACHING_HE 0x02
837 #define SMB2_LEASE_WRITE_CACHING_HE 0x04
839 #define SMB2_LEASE_NONE cpu_to_le32(0x00)
840 #define SMB2_LEASE_READ_CACHING cpu_to_le32(0x01)
841 #define SMB2_LEASE_HANDLE_CACHING cpu_to_le32(0x02)
842 #define SMB2_LEASE_WRITE_CACHING cpu_to_le32(0x04)
844 #define SMB2_LEASE_FLAG_BREAK_IN_PROGRESS cpu_to_le32(0x00000002)
845 #define SMB2_LEASE_FLAG_PARENT_LEASE_KEY_SET cpu_to_le32(0x00000004)
847 #define SMB2_LEASE_KEY_SIZE 16
849 struct lease_context {
850 u8 LeaseKey[SMB2_LEASE_KEY_SIZE];
853 __le64 LeaseDuration;
856 struct lease_context_v2 {
857 u8 LeaseKey[SMB2_LEASE_KEY_SIZE];
860 __le64 LeaseDuration;
861 __le64 ParentLeaseKeyLow;
862 __le64 ParentLeaseKeyHigh;
867 struct create_lease {
868 struct create_context ccontext;
870 struct lease_context lcontext;
873 struct create_lease_v2 {
874 struct create_context ccontext;
876 struct lease_context_v2 lcontext;
880 struct create_durable {
881 struct create_context ccontext;
886 __u64 PersistentFileId;
887 __u64 VolatileFileId;
892 struct create_posix {
893 struct create_context ccontext;
899 /* See MS-SMB2 2.2.13.2.11 */
901 #define SMB2_DHANDLE_FLAG_PERSISTENT 0x00000002
902 struct durable_context_v2 {
909 struct create_durable_v2 {
910 struct create_context ccontext;
912 struct durable_context_v2 dcontext;
915 /* See MS-SMB2 2.2.13.2.12 */
916 struct durable_reconnect_context_v2 {
918 __u64 PersistentFileId;
919 __u64 VolatileFileId;
922 __le32 Flags; /* see above DHANDLE_FLAG_PERSISTENT */
925 /* See MS-SMB2 2.2.14.2.9 */
926 struct create_on_disk_id {
927 struct create_context ccontext;
934 /* See MS-SMB2 2.2.14.2.12 */
935 struct durable_reconnect_context_v2_rsp {
937 __le32 Flags; /* see above DHANDLE_FLAG_PERSISTENT */
940 struct create_durable_handle_reconnect_v2 {
941 struct create_context ccontext;
943 struct durable_reconnect_context_v2 dcontext;
947 /* See MS-SMB2 2.2.13.2.5 */
948 struct crt_twarp_ctxt {
949 struct create_context ccontext;
955 /* See MS-SMB2 2.2.13.2.9 */
956 struct crt_query_id_ctxt {
957 struct create_context ccontext;
962 struct create_context ccontext;
966 /* Followed by at least 4 ACEs */
970 #define COPY_CHUNK_RES_KEY_SIZE 24
971 struct resume_key_req {
972 char ResumeKey[COPY_CHUNK_RES_KEY_SIZE];
973 __le32 ContextLength; /* MBZ */
974 char Context[]; /* ignored, Windows sets to 4 bytes of zero */
977 /* this goes in the ioctl buffer when doing a copychunk request */
978 struct copychunk_ioctl {
979 char SourceKey[COPY_CHUNK_RES_KEY_SIZE];
980 __le32 ChunkCount; /* we are only sending 1 */
982 /* array will only be one chunk long for us */
985 __le32 Length; /* how many bytes to copy */
989 /* this goes in the ioctl buffer when doing FSCTL_SET_ZERO_DATA */
990 struct file_zero_data_information {
992 __le64 BeyondFinalZero;
995 struct copychunk_ioctl_rsp {
996 __le32 ChunksWritten;
997 __le32 ChunkBytesWritten;
998 __le32 TotalBytesWritten;
1001 struct fsctl_set_integrity_information_req {
1002 __le16 ChecksumAlgorithm;
1007 struct fsctl_get_integrity_information_rsp {
1008 __le16 ChecksumAlgorithm;
1011 __le32 ChecksumChunkSizeInBytes;
1012 __le32 ClusterSizeInBytes;
1015 struct file_allocated_range_buffer {
1020 /* Integrity ChecksumAlgorithm choices for above */
1021 #define CHECKSUM_TYPE_NONE 0x0000
1022 #define CHECKSUM_TYPE_CRC64 0x0002
1023 #define CHECKSUM_TYPE_UNCHANGED 0xFFFF /* set only */
1025 /* Integrity flags for above */
1026 #define FSCTL_INTEGRITY_FLAG_CHECKSUM_ENFORCEMENT_OFF 0x00000001
1028 /* Reparse structures - see MS-FSCC 2.1.2 */
1030 /* struct fsctl_reparse_info_req is empty, only response structs (see below) */
1032 struct reparse_data_buffer {
1034 __le16 ReparseDataLength;
1036 __u8 DataBuffer[]; /* Variable Length */
1039 struct reparse_guid_data_buffer {
1041 __le16 ReparseDataLength;
1043 __u8 ReparseGuid[16];
1044 __u8 DataBuffer[]; /* Variable Length */
1047 struct reparse_mount_point_data_buffer {
1049 __le16 ReparseDataLength;
1051 __le16 SubstituteNameOffset;
1052 __le16 SubstituteNameLength;
1053 __le16 PrintNameOffset;
1054 __le16 PrintNameLength;
1055 __u8 PathBuffer[]; /* Variable Length */
1058 #define SYMLINK_FLAG_RELATIVE 0x00000001
1060 struct reparse_symlink_data_buffer {
1062 __le16 ReparseDataLength;
1064 __le16 SubstituteNameOffset;
1065 __le16 SubstituteNameLength;
1066 __le16 PrintNameOffset;
1067 __le16 PrintNameLength;
1069 __u8 PathBuffer[]; /* Variable Length */
1072 /* See MS-FSCC 2.1.2.6 and cifspdu.h for struct reparse_posix_data */
1075 /* See MS-DFSC 2.2.2 */
1076 struct fsctl_get_dfs_referral_req {
1077 __le16 MaxReferralLevel;
1078 __u8 RequestFileName[];
1081 /* DFS response is struct get_dfs_refer_rsp */
1083 /* See MS-SMB2 2.2.31.3 */
1084 struct network_resiliency_req {
1088 /* There is no buffer for the response ie no struct network_resiliency_rsp */
1091 struct validate_negotiate_info_req {
1092 __le32 Capabilities;
1093 __u8 Guid[SMB2_CLIENT_GUID_SIZE];
1094 __le16 SecurityMode;
1095 __le16 DialectCount;
1096 __le16 Dialects[4]; /* BB expand this if autonegotiate > 4 dialects */
1099 struct validate_negotiate_info_rsp {
1100 __le32 Capabilities;
1101 __u8 Guid[SMB2_CLIENT_GUID_SIZE];
1102 __le16 SecurityMode;
1103 __le16 Dialect; /* Dialect in use for the connection */
1106 #define RSS_CAPABLE cpu_to_le32(0x00000001)
1107 #define RDMA_CAPABLE cpu_to_le32(0x00000002)
1109 #define INTERNETWORK cpu_to_le16(0x0002)
1110 #define INTERNETWORKV6 cpu_to_le16(0x0017)
1112 struct network_interface_info_ioctl_rsp {
1113 __le32 Next; /* next interface. zero if this is last one */
1115 __le32 Capability; /* RSS or RDMA Capable */
1122 struct iface_info_ipv4 {
1128 struct iface_info_ipv6 {
1131 __u8 IPv6Address[16];
1135 #define NO_FILE_ID 0xFFFFFFFFFFFFFFFFULL /* general ioctls to srv not to file */
1137 struct compress_ioctl {
1138 __le16 CompressionState; /* See cifspdu.h for possible flag values */
1141 struct duplicate_extents_to_file {
1142 __u64 PersistentFileHandle; /* source file handle, opaque endianness */
1143 __u64 VolatileFileHandle;
1144 __le64 SourceFileOffset;
1145 __le64 TargetFileOffset;
1146 __le64 ByteCount; /* Bytes to be copied */
1150 * Maximum number of iovs we need for an ioctl request.
1151 * [0] : struct smb2_ioctl_req
1154 #define SMB2_IOCTL_IOV_SIZE 2
1156 struct smb2_ioctl_req {
1157 struct smb2_sync_hdr sync_hdr;
1158 __le16 StructureSize; /* Must be 57 */
1161 __u64 PersistentFileId; /* opaque endianness */
1162 __u64 VolatileFileId; /* opaque endianness */
1165 __le32 MaxInputResponse;
1166 __le32 OutputOffset;
1168 __le32 MaxOutputResponse;
1174 struct smb2_ioctl_rsp {
1175 struct smb2_sync_hdr sync_hdr;
1176 __le16 StructureSize; /* Must be 57 */
1179 __u64 PersistentFileId; /* opaque endianness */
1180 __u64 VolatileFileId; /* opaque endianness */
1183 __le32 OutputOffset;
1187 /* char * buffer[] */
1190 /* Currently defined values for close flags */
1191 #define SMB2_CLOSE_FLAG_POSTQUERY_ATTRIB cpu_to_le16(0x0001)
1192 struct smb2_close_req {
1193 struct smb2_sync_hdr sync_hdr;
1194 __le16 StructureSize; /* Must be 24 */
1197 __u64 PersistentFileId; /* opaque endianness */
1198 __u64 VolatileFileId; /* opaque endianness */
1202 * Maximum size of a SMB2_CLOSE response is 64 (smb2 header) + 60 (data)
1204 #define MAX_SMB2_CLOSE_RESPONSE_SIZE 124
1206 struct smb2_close_rsp {
1207 struct smb2_sync_hdr sync_hdr;
1208 __le16 StructureSize; /* 60 */
1211 __le64 CreationTime;
1212 __le64 LastAccessTime;
1213 __le64 LastWriteTime;
1215 __le64 AllocationSize; /* Beginning of FILE_STANDARD_INFO equivalent */
1220 struct smb2_flush_req {
1221 struct smb2_sync_hdr sync_hdr;
1222 __le16 StructureSize; /* Must be 24 */
1225 __u64 PersistentFileId; /* opaque endianness */
1226 __u64 VolatileFileId; /* opaque endianness */
1229 struct smb2_flush_rsp {
1230 struct smb2_sync_hdr sync_hdr;
1231 __le16 StructureSize;
1235 /* For read request Flags field below, following flag is defined for SMB3.02 */
1236 #define SMB2_READFLAG_READ_UNBUFFERED 0x01
1237 #define SMB2_READFLAG_REQUEST_COMPRESSED 0x02 /* See MS-SMB2 2.2.19 */
1239 /* Channel field for read and write: exactly one of following flags can be set*/
1240 #define SMB2_CHANNEL_NONE cpu_to_le32(0x00000000)
1241 #define SMB2_CHANNEL_RDMA_V1 cpu_to_le32(0x00000001) /* SMB3 or later */
1242 #define SMB2_CHANNEL_RDMA_V1_INVALIDATE cpu_to_le32(0x00000002) /* >= SMB3.02 */
1243 #define SMB2_CHANNEL_RDMA_TRANSFORM cpu_to_le32(0x00000003) /* >= SMB3.02, only used on write */
1245 /* SMB2 read request without RFC1001 length at the beginning */
1246 struct smb2_read_plain_req {
1247 struct smb2_sync_hdr sync_hdr;
1248 __le16 StructureSize; /* Must be 49 */
1249 __u8 Padding; /* offset from start of SMB2 header to place read */
1250 __u8 Flags; /* MBZ unless SMB3.02 or later */
1253 __u64 PersistentFileId; /* opaque endianness */
1254 __u64 VolatileFileId; /* opaque endianness */
1255 __le32 MinimumCount;
1256 __le32 Channel; /* MBZ except for SMB3 or later */
1257 __le32 RemainingBytes;
1258 __le16 ReadChannelInfoOffset;
1259 __le16 ReadChannelInfoLength;
1264 #define SMB2_READFLAG_RESPONSE_NONE 0x00000000
1265 #define SMB2_READFLAG_RESPONSE_RDMA_TRANSFORM 0x00000001
1267 struct smb2_read_rsp {
1268 struct smb2_sync_hdr sync_hdr;
1269 __le16 StructureSize; /* Must be 17 */
1273 __le32 DataRemaining;
1278 /* For write request Flags field below the following flags are defined: */
1279 #define SMB2_WRITEFLAG_WRITE_THROUGH 0x00000001 /* SMB2.1 or later */
1280 #define SMB2_WRITEFLAG_WRITE_UNBUFFERED 0x00000002 /* SMB3.02 or later */
1282 struct smb2_write_req {
1283 struct smb2_sync_hdr sync_hdr;
1284 __le16 StructureSize; /* Must be 49 */
1285 __le16 DataOffset; /* offset from start of SMB2 header to write data */
1288 __u64 PersistentFileId; /* opaque endianness */
1289 __u64 VolatileFileId; /* opaque endianness */
1290 __le32 Channel; /* MBZ unless SMB3.02 or later */
1291 __le32 RemainingBytes;
1292 __le16 WriteChannelInfoOffset;
1293 __le16 WriteChannelInfoLength;
1298 struct smb2_write_rsp {
1299 struct smb2_sync_hdr sync_hdr;
1300 __le16 StructureSize; /* Must be 17 */
1304 __le32 DataRemaining;
1310 #define SMB2_WATCH_TREE 0x0001
1312 /* notify completion filter flags. See MS-FSCC 2.6 and MS-SMB2 2.2.35 */
1313 #define FILE_NOTIFY_CHANGE_FILE_NAME 0x00000001
1314 #define FILE_NOTIFY_CHANGE_DIR_NAME 0x00000002
1315 #define FILE_NOTIFY_CHANGE_ATTRIBUTES 0x00000004
1316 #define FILE_NOTIFY_CHANGE_SIZE 0x00000008
1317 #define FILE_NOTIFY_CHANGE_LAST_WRITE 0x00000010
1318 #define FILE_NOTIFY_CHANGE_LAST_ACCESS 0x00000020
1319 #define FILE_NOTIFY_CHANGE_CREATION 0x00000040
1320 #define FILE_NOTIFY_CHANGE_EA 0x00000080
1321 #define FILE_NOTIFY_CHANGE_SECURITY 0x00000100
1322 #define FILE_NOTIFY_CHANGE_STREAM_NAME 0x00000200
1323 #define FILE_NOTIFY_CHANGE_STREAM_SIZE 0x00000400
1324 #define FILE_NOTIFY_CHANGE_STREAM_WRITE 0x00000800
1326 struct smb2_change_notify_req {
1327 struct smb2_sync_hdr sync_hdr;
1328 __le16 StructureSize;
1330 __le32 OutputBufferLength;
1331 __u64 PersistentFileId; /* opaque endianness */
1332 __u64 VolatileFileId; /* opaque endianness */
1333 __le32 CompletionFilter;
1337 struct smb2_change_notify_rsp {
1338 struct smb2_sync_hdr sync_hdr;
1339 __le16 StructureSize; /* Must be 9 */
1340 __le16 OutputBufferOffset;
1341 __le32 OutputBufferLength;
1342 __u8 Buffer[1]; /* array of file notify structs */
1345 #define SMB2_LOCKFLAG_SHARED_LOCK 0x0001
1346 #define SMB2_LOCKFLAG_EXCLUSIVE_LOCK 0x0002
1347 #define SMB2_LOCKFLAG_UNLOCK 0x0004
1348 #define SMB2_LOCKFLAG_FAIL_IMMEDIATELY 0x0010
1350 struct smb2_lock_element {
1357 struct smb2_lock_req {
1358 struct smb2_sync_hdr sync_hdr;
1359 __le16 StructureSize; /* Must be 48 */
1362 __u64 PersistentFileId; /* opaque endianness */
1363 __u64 VolatileFileId; /* opaque endianness */
1364 /* Followed by at least one */
1365 struct smb2_lock_element locks[1];
1368 struct smb2_lock_rsp {
1369 struct smb2_sync_hdr sync_hdr;
1370 __le16 StructureSize; /* Must be 4 */
1374 struct smb2_echo_req {
1375 struct smb2_sync_hdr sync_hdr;
1376 __le16 StructureSize; /* Must be 4 */
1380 struct smb2_echo_rsp {
1381 struct smb2_sync_hdr sync_hdr;
1382 __le16 StructureSize; /* Must be 4 */
1386 /* search (query_directory) Flags field */
1387 #define SMB2_RESTART_SCANS 0x01
1388 #define SMB2_RETURN_SINGLE_ENTRY 0x02
1389 #define SMB2_INDEX_SPECIFIED 0x04
1390 #define SMB2_REOPEN 0x10
1392 #define SMB2_QUERY_DIRECTORY_IOV_SIZE 2
1394 struct smb2_query_directory_req {
1395 struct smb2_sync_hdr sync_hdr;
1396 __le16 StructureSize; /* Must be 33 */
1397 __u8 FileInformationClass;
1400 __u64 PersistentFileId; /* opaque endianness */
1401 __u64 VolatileFileId; /* opaque endianness */
1402 __le16 FileNameOffset;
1403 __le16 FileNameLength;
1404 __le32 OutputBufferLength;
1408 struct smb2_query_directory_rsp {
1409 struct smb2_sync_hdr sync_hdr;
1410 __le16 StructureSize; /* Must be 9 */
1411 __le16 OutputBufferOffset;
1412 __le32 OutputBufferLength;
1416 /* Possible InfoType values */
1417 #define SMB2_O_INFO_FILE 0x01
1418 #define SMB2_O_INFO_FILESYSTEM 0x02
1419 #define SMB2_O_INFO_SECURITY 0x03
1420 #define SMB2_O_INFO_QUOTA 0x04
1422 /* Security info type additionalinfo flags. See MS-SMB2 (2.2.37) or MS-DTYP */
1423 #define OWNER_SECINFO 0x00000001
1424 #define GROUP_SECINFO 0x00000002
1425 #define DACL_SECINFO 0x00000004
1426 #define SACL_SECINFO 0x00000008
1427 #define LABEL_SECINFO 0x00000010
1428 #define ATTRIBUTE_SECINFO 0x00000020
1429 #define SCOPE_SECINFO 0x00000040
1430 #define BACKUP_SECINFO 0x00010000
1431 #define UNPROTECTED_SACL_SECINFO 0x10000000
1432 #define UNPROTECTED_DACL_SECINFO 0x20000000
1433 #define PROTECTED_SACL_SECINFO 0x40000000
1434 #define PROTECTED_DACL_SECINFO 0x80000000
1436 /* Flags used for FileFullEAinfo */
1437 #define SL_RESTART_SCAN 0x00000001
1438 #define SL_RETURN_SINGLE_ENTRY 0x00000002
1439 #define SL_INDEX_SPECIFIED 0x00000004
1441 struct smb2_query_info_req {
1442 struct smb2_sync_hdr sync_hdr;
1443 __le16 StructureSize; /* Must be 41 */
1446 __le32 OutputBufferLength;
1447 __le16 InputBufferOffset;
1449 __le32 InputBufferLength;
1450 __le32 AdditionalInformation;
1452 __u64 PersistentFileId; /* opaque endianness */
1453 __u64 VolatileFileId; /* opaque endianness */
1457 struct smb2_query_info_rsp {
1458 struct smb2_sync_hdr sync_hdr;
1459 __le16 StructureSize; /* Must be 9 */
1460 __le16 OutputBufferOffset;
1461 __le32 OutputBufferLength;
1466 * Maximum number of iovs we need for a set-info request.
1467 * The largest one is rename/hardlink
1468 * [0] : struct smb2_set_info_req + smb2_file_[rename|link]_info
1470 * [2] : compound padding
1472 #define SMB2_SET_INFO_IOV_SIZE 3
1474 struct smb2_set_info_req {
1475 struct smb2_sync_hdr sync_hdr;
1476 __le16 StructureSize; /* Must be 33 */
1479 __le32 BufferLength;
1480 __le16 BufferOffset;
1482 __le32 AdditionalInformation;
1483 __u64 PersistentFileId; /* opaque endianness */
1484 __u64 VolatileFileId; /* opaque endianness */
1488 struct smb2_set_info_rsp {
1489 struct smb2_sync_hdr sync_hdr;
1490 __le16 StructureSize; /* Must be 2 */
1493 struct smb2_oplock_break {
1494 struct smb2_sync_hdr sync_hdr;
1495 __le16 StructureSize; /* Must be 24 */
1499 __u64 PersistentFid;
1503 #define SMB2_NOTIFY_BREAK_LEASE_FLAG_ACK_REQUIRED cpu_to_le32(0x01)
1505 struct smb2_lease_break {
1506 struct smb2_sync_hdr sync_hdr;
1507 __le16 StructureSize; /* Must be 44 */
1511 __le32 CurrentLeaseState;
1512 __le32 NewLeaseState;
1514 __le32 AccessMaskHint;
1515 __le32 ShareMaskHint;
1518 struct smb2_lease_ack {
1519 struct smb2_sync_hdr sync_hdr;
1520 __le16 StructureSize; /* Must be 36 */
1525 __le64 LeaseDuration;
1529 * PDU infolevel structure definitions
1530 * BB consider moving to a different header
1533 /* File System Information Classes */
1534 #define FS_VOLUME_INFORMATION 1 /* Query */
1535 #define FS_LABEL_INFORMATION 2 /* Local only */
1536 #define FS_SIZE_INFORMATION 3 /* Query */
1537 #define FS_DEVICE_INFORMATION 4 /* Query */
1538 #define FS_ATTRIBUTE_INFORMATION 5 /* Query */
1539 #define FS_CONTROL_INFORMATION 6 /* Query, Set */
1540 #define FS_FULL_SIZE_INFORMATION 7 /* Query */
1541 #define FS_OBJECT_ID_INFORMATION 8 /* Query, Set */
1542 #define FS_DRIVER_PATH_INFORMATION 9 /* Local only */
1543 #define FS_VOLUME_FLAGS_INFORMATION 10 /* Local only */
1544 #define FS_SECTOR_SIZE_INFORMATION 11 /* SMB3 or later. Query */
1545 #define FS_POSIX_INFORMATION 100 /* SMB3.1.1 POSIX. Query */
1547 struct smb2_fs_full_size_info {
1548 __le64 TotalAllocationUnits;
1549 __le64 CallerAvailableAllocationUnits;
1550 __le64 ActualAvailableAllocationUnits;
1551 __le32 SectorsPerAllocationUnit;
1552 __le32 BytesPerSector;
1555 #define SSINFO_FLAGS_ALIGNED_DEVICE 0x00000001
1556 #define SSINFO_FLAGS_PARTITION_ALIGNED_ON_DEVICE 0x00000002
1557 #define SSINFO_FLAGS_NO_SEEK_PENALTY 0x00000004
1558 #define SSINFO_FLAGS_TRIM_ENABLED 0x00000008
1560 /* sector size info struct */
1561 struct smb3_fs_ss_info {
1562 __le32 LogicalBytesPerSector;
1563 __le32 PhysicalBytesPerSectorForAtomicity;
1564 __le32 PhysicalBytesPerSectorForPerf;
1565 __le32 FileSystemEffectivePhysicalBytesPerSectorForAtomicity;
1567 __le32 ByteOffsetForSectorAlignment;
1568 __le32 ByteOffsetForPartitionAlignment;
1571 /* volume info struct - see MS-FSCC 2.5.9 */
1572 #define MAX_VOL_LABEL_LEN 32
1573 struct smb3_fs_vol_info {
1574 __le64 VolumeCreationTime;
1575 __u32 VolumeSerialNumber;
1576 __le32 VolumeLabelLength; /* includes trailing null */
1577 __u8 SupportsObjects; /* True if eg like NTFS, supports objects */
1579 __u8 VolumeLabel[]; /* variable len */
1582 /* partial list of QUERY INFO levels */
1583 #define FILE_DIRECTORY_INFORMATION 1
1584 #define FILE_FULL_DIRECTORY_INFORMATION 2
1585 #define FILE_BOTH_DIRECTORY_INFORMATION 3
1586 #define FILE_BASIC_INFORMATION 4
1587 #define FILE_STANDARD_INFORMATION 5
1588 #define FILE_INTERNAL_INFORMATION 6
1589 #define FILE_EA_INFORMATION 7
1590 #define FILE_ACCESS_INFORMATION 8
1591 #define FILE_NAME_INFORMATION 9
1592 #define FILE_RENAME_INFORMATION 10
1593 #define FILE_LINK_INFORMATION 11
1594 #define FILE_NAMES_INFORMATION 12
1595 #define FILE_DISPOSITION_INFORMATION 13
1596 #define FILE_POSITION_INFORMATION 14
1597 #define FILE_FULL_EA_INFORMATION 15
1598 #define FILE_MODE_INFORMATION 16
1599 #define FILE_ALIGNMENT_INFORMATION 17
1600 #define FILE_ALL_INFORMATION 18
1601 #define FILE_ALLOCATION_INFORMATION 19
1602 #define FILE_END_OF_FILE_INFORMATION 20
1603 #define FILE_ALTERNATE_NAME_INFORMATION 21
1604 #define FILE_STREAM_INFORMATION 22
1605 #define FILE_PIPE_INFORMATION 23
1606 #define FILE_PIPE_LOCAL_INFORMATION 24
1607 #define FILE_PIPE_REMOTE_INFORMATION 25
1608 #define FILE_MAILSLOT_QUERY_INFORMATION 26
1609 #define FILE_MAILSLOT_SET_INFORMATION 27
1610 #define FILE_COMPRESSION_INFORMATION 28
1611 #define FILE_OBJECT_ID_INFORMATION 29
1612 /* Number 30 not defined in documents */
1613 #define FILE_MOVE_CLUSTER_INFORMATION 31
1614 #define FILE_QUOTA_INFORMATION 32
1615 #define FILE_REPARSE_POINT_INFORMATION 33
1616 #define FILE_NETWORK_OPEN_INFORMATION 34
1617 #define FILE_ATTRIBUTE_TAG_INFORMATION 35
1618 #define FILE_TRACKING_INFORMATION 36
1619 #define FILEID_BOTH_DIRECTORY_INFORMATION 37
1620 #define FILEID_FULL_DIRECTORY_INFORMATION 38
1621 #define FILE_VALID_DATA_LENGTH_INFORMATION 39
1622 #define FILE_SHORT_NAME_INFORMATION 40
1623 #define FILE_SFIO_RESERVE_INFORMATION 44
1624 #define FILE_SFIO_VOLUME_INFORMATION 45
1625 #define FILE_HARD_LINK_INFORMATION 46
1626 #define FILE_NORMALIZED_NAME_INFORMATION 48
1627 #define FILEID_GLOBAL_TX_DIRECTORY_INFORMATION 50
1628 #define FILE_STANDARD_LINK_INFORMATION 54
1629 #define FILE_ID_INFORMATION 59
1631 struct smb2_file_internal_info {
1633 } __packed; /* level 6 Query */
1635 struct smb2_file_rename_info { /* encoding of request for level 10 */
1636 __u8 ReplaceIfExists; /* 1 = replace existing target with new */
1637 /* 0 = fail if target already exists */
1639 __u64 RootDirectory; /* MBZ for network operations (why says spec?) */
1640 __le32 FileNameLength;
1641 char FileName[]; /* New name to be assigned */
1642 } __packed; /* level 10 Set */
1644 struct smb2_file_link_info { /* encoding of request for level 11 */
1645 __u8 ReplaceIfExists; /* 1 = replace existing link with new */
1646 /* 0 = fail if link already exists */
1648 __u64 RootDirectory; /* MBZ for network operations (why says spec?) */
1649 __le32 FileNameLength;
1650 char FileName[]; /* Name to be assigned to new link */
1651 } __packed; /* level 11 Set */
1653 struct smb2_file_full_ea_info { /* encoding of response for level 15 */
1654 __le32 next_entry_offset;
1656 __u8 ea_name_length;
1657 __le16 ea_value_length;
1658 char ea_data[]; /* \0 terminated name plus value */
1659 } __packed; /* level 15 Set */
1662 * This level 18, although with struct with same name is different from cifs
1663 * level 0x107. Level 0x107 has an extra u64 between AccessFlags and
1664 * CurrentByteOffset.
1666 struct smb2_file_all_info { /* data block encoding of response to level 18 */
1667 __le64 CreationTime; /* Beginning of FILE_BASIC_INFO equivalent */
1668 __le64 LastAccessTime;
1669 __le64 LastWriteTime;
1672 __u32 Pad1; /* End of FILE_BASIC_INFO_INFO equivalent */
1673 __le64 AllocationSize; /* Beginning of FILE_STANDARD_INFO equivalent */
1674 __le64 EndOfFile; /* size ie offset to first free byte in file */
1675 __le32 NumberOfLinks; /* hard links */
1678 __u16 Pad2; /* End of FILE_STANDARD_INFO equivalent */
1682 __le64 CurrentByteOffset;
1684 __le32 AlignmentRequirement;
1685 __le32 FileNameLength;
1687 } __packed; /* level 18 Query */
1689 struct smb2_file_eof_info { /* encoding of request for level 10 */
1690 __le64 EndOfFile; /* new end of file value */
1691 } __packed; /* level 20 Set */
1693 struct smb2_file_network_open_info {
1694 __le64 CreationTime;
1695 __le64 LastAccessTime;
1696 __le64 LastWriteTime;
1698 __le64 AllocationSize;
1702 } __packed; /* level 34 Query also similar returned in close rsp and open rsp */
1704 /* See MS-FSCC 2.4.43 */
1705 struct smb2_file_id_information {
1706 __le64 VolumeSerialNumber;
1707 __u64 PersistentFileId; /* opaque endianness */
1708 __u64 VolatileFileId; /* opaque endianness */
1709 } __packed; /* level 59 */
1711 extern char smb2_padding[7];
1713 /* equivalent of the contents of SMB3.1.1 POSIX open context response */
1714 struct create_posix_rsp {
1718 struct cifs_sid owner; /* var-sized on the wire */
1719 struct cifs_sid group; /* var-sized on the wire */
1723 * SMB2-only POSIX info level for query dir
1725 * See posix_info_sid_size(), posix_info_extra_size() and
1726 * posix_info_parse() to help with the handling of this struct.
1728 struct smb2_posix_info {
1729 __le32 NextEntryOffset;
1731 __le64 CreationTime;
1732 __le64 LastAccessTime;
1733 __le64 LastWriteTime;
1736 __le64 AllocationSize;
1737 __le32 DosAttributes;
1741 /* beginning of POSIX Create Context Response */
1746 * var sized owner SID
1747 * var sized group SID
1748 * le32 filenamelength
1753 /* Level 100 query info */
1754 struct smb311_posix_qinfo {
1755 __le64 CreationTime;
1756 __le64 LastAccessTime;
1757 __le64 LastWriteTime;
1760 __le64 AllocationSize;
1761 __le32 DosAttributes;
1765 /* beginning of POSIX Create Context Response */
1771 * var sized owner SID
1772 * var sized group SID
1773 * le32 filenamelength
1779 * Parsed version of the above struct. Allows direct access to the
1780 * variable length fields
1782 struct smb2_posix_info_parsed {
1783 const struct smb2_posix_info *base;
1785 struct cifs_sid owner;
1786 struct cifs_sid group;
1791 #endif /* _SMB2PDU_H */