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_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 */
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 /* we currently do not request AES256_CCM since presumably GCM faster */
356 #define SMB2_ENCRYPTION_AES256_CCM cpu_to_le16(0x0003)
357 #define SMB2_ENCRYPTION_AES256_GCM cpu_to_le16(0x0004)
359 /* Min encrypt context data is one cipher so 2 bytes + 2 byte count field */
360 #define MIN_ENCRYPT_CTXT_DATA_LEN 4
361 struct smb2_encryption_neg_context {
362 __le16 ContextType; /* 2 */
365 /* CipherCount usally 2, but can be 3 when AES256-GCM enabled */
366 __le16 CipherCount; /* AES128-GCM and AES128-CCM by default */
370 /* See MS-SMB2 2.2.3.1.3 */
371 #define SMB3_COMPRESS_NONE cpu_to_le16(0x0000)
372 #define SMB3_COMPRESS_LZNT1 cpu_to_le16(0x0001)
373 #define SMB3_COMPRESS_LZ77 cpu_to_le16(0x0002)
374 #define SMB3_COMPRESS_LZ77_HUFF cpu_to_le16(0x0003)
375 /* Pattern scanning algorithm See MS-SMB2 3.1.4.4.1 */
376 #define SMB3_COMPRESS_PATTERN cpu_to_le16(0x0004) /* Pattern_V1 */
378 /* Compression Flags */
379 #define SMB2_COMPRESSION_CAPABILITIES_FLAG_NONE cpu_to_le32(0x00000000)
380 #define SMB2_COMPRESSION_CAPABILITIES_FLAG_CHAINED cpu_to_le32(0x00000001)
382 struct smb2_compression_capabilities_context {
383 __le16 ContextType; /* 3 */
386 __le16 CompressionAlgorithmCount;
389 __le16 CompressionAlgorithms[3];
393 * For smb2_netname_negotiate_context_id See MS-SMB2 2.2.3.1.4.
394 * Its struct simply contains NetName, an array of Unicode characters
396 struct smb2_netname_neg_context {
397 __le16 ContextType; /* 5 */
400 __le16 NetName[]; /* hostname of target converted to UCS-2 */
404 * For rdma transform capabilities context see MS-SMB2 2.2.3.1.6
408 /* RDMA Transform IDs */
409 #define SMB2_RDMA_TRANSFORM_NONE 0x0000
410 #define SMB2_RDMA_TRANSFORM_ENCRYPTION 0x0001
412 struct smb2_rdma_transform_capabilities_context {
413 __le16 ContextType; /* 7 */
416 __le16 TransformCount;
419 __le16 RDMATransformIds[1];
422 /* Signing algorithms */
423 #define SIGNING_ALG_HMAC_SHA256 0
424 #define SIGNING_ALG_AES_CMAC 1
425 #define SIGNING_ALG_AES_GMAC 2
427 struct smb2_signing_capabilities {
428 __le16 ContextType; /* 8 */
431 __le16 SigningAlgorithmCount;
432 __le16 SigningAlgorithms[];
435 #define POSIX_CTXT_DATA_LEN 16
436 struct smb2_posix_neg_context {
437 __le16 ContextType; /* 0x100 */
440 __u8 Name[16]; /* POSIX ctxt GUID 93AD25509CB411E7B42383DE968BCD7C */
443 struct smb2_negotiate_rsp {
444 struct smb2_sync_hdr sync_hdr;
445 __le16 StructureSize; /* Must be 65 */
447 __le16 DialectRevision;
448 __le16 NegotiateContextCount; /* Prior to SMB3.1.1 was Reserved & MBZ */
451 __le32 MaxTransactSize;
454 __le64 SystemTime; /* MBZ */
455 __le64 ServerStartTime;
456 __le16 SecurityBufferOffset;
457 __le16 SecurityBufferLength;
458 __le32 NegotiateContextOffset; /* Pre:SMB3.1.1 was reserved/ignored */
459 __u8 Buffer[1]; /* variable length GSS security buffer */
463 #define SMB2_SESSION_REQ_FLAG_BINDING 0x01
464 #define SMB2_SESSION_REQ_FLAG_ENCRYPT_DATA 0x04
466 struct smb2_sess_setup_req {
467 struct smb2_sync_hdr sync_hdr;
468 __le16 StructureSize; /* Must be 25 */
473 __le16 SecurityBufferOffset;
474 __le16 SecurityBufferLength;
475 __u64 PreviousSessionId;
476 __u8 Buffer[1]; /* variable length GSS security buffer */
479 /* Currently defined SessionFlags */
480 #define SMB2_SESSION_FLAG_IS_GUEST 0x0001
481 #define SMB2_SESSION_FLAG_IS_NULL 0x0002
482 #define SMB2_SESSION_FLAG_ENCRYPT_DATA 0x0004
483 struct smb2_sess_setup_rsp {
484 struct smb2_sync_hdr sync_hdr;
485 __le16 StructureSize; /* Must be 9 */
487 __le16 SecurityBufferOffset;
488 __le16 SecurityBufferLength;
489 __u8 Buffer[1]; /* variable length GSS security buffer */
492 struct smb2_logoff_req {
493 struct smb2_sync_hdr sync_hdr;
494 __le16 StructureSize; /* Must be 4 */
498 struct smb2_logoff_rsp {
499 struct smb2_sync_hdr sync_hdr;
500 __le16 StructureSize; /* Must be 4 */
504 /* Flags/Reserved for SMB3.1.1 */
505 #define SMB2_TREE_CONNECT_FLAG_CLUSTER_RECONNECT cpu_to_le16(0x0001)
506 #define SMB2_TREE_CONNECT_FLAG_REDIRECT_TO_OWNER cpu_to_le16(0x0002)
507 #define SMB2_TREE_CONNECT_FLAG_EXTENSION_PRESENT cpu_to_le16(0x0004)
509 struct smb2_tree_connect_req {
510 struct smb2_sync_hdr sync_hdr;
511 __le16 StructureSize; /* Must be 9 */
512 __le16 Flags; /* Reserved MBZ for dialects prior to SMB3.1.1 */
515 __u8 Buffer[1]; /* variable length */
518 /* See MS-SMB2 section 2.2.9.2 */
520 #define SMB2_RESERVED_TREE_CONNECT_CONTEXT_ID 0x0000
521 #define SMB2_REMOTED_IDENTITY_TREE_CONNECT_CONTEXT_ID cpu_to_le16(0x0001)
523 struct tree_connect_contexts {
530 /* Remoted identity tree connect context structures - see MS-SMB2 2.2.9.2.1 */
531 struct smb3_blob_data {
536 /* Valid values for Attr */
537 #define SE_GROUP_MANDATORY 0x00000001
538 #define SE_GROUP_ENABLED_BY_DEFAULT 0x00000002
539 #define SE_GROUP_ENABLED 0x00000004
540 #define SE_GROUP_OWNER 0x00000008
541 #define SE_GROUP_USE_FOR_DENY_ONLY 0x00000010
542 #define SE_GROUP_INTEGRITY 0x00000020
543 #define SE_GROUP_INTEGRITY_ENABLED 0x00000040
544 #define SE_GROUP_RESOURCE 0x20000000
545 #define SE_GROUP_LOGON_ID 0xC0000000
547 /* struct sid_attr_data is SidData array in BlobData format then le32 Attr */
549 struct sid_array_data {
551 /* SidAttrList - array of sid_attr_data structs */
554 struct luid_attr_data {
559 * struct privilege_data is the same as BLOB_DATA - see MS-SMB2 2.2.9.2.1.5
560 * but with size of LUID_ATTR_DATA struct and BlobData set to LUID_ATTR DATA
563 struct privilege_array_data {
564 __le16 PrivilegeCount;
565 /* array of privilege_data structs */
568 struct remoted_identity_tcon_context {
569 __le16 TicketType; /* must be 0x0001 */
570 __le16 TicketSize; /* total size of this struct */
571 __le16 User; /* offset to SID_ATTR_DATA struct with user info */
572 __le16 UserName; /* offset to null terminated Unicode username string */
573 __le16 Domain; /* offset to null terminated Unicode domain name */
574 __le16 Groups; /* offset to SID_ARRAY_DATA struct with group info */
575 __le16 RestrictedGroups; /* similar to above */
576 __le16 Privileges; /* offset to PRIVILEGE_ARRAY_DATA struct */
577 __le16 PrimaryGroup; /* offset to SID_ARRAY_DATA struct */
578 __le16 Owner; /* offset to BLOB_DATA struct */
579 __le16 DefaultDacl; /* offset to BLOB_DATA struct */
580 __le16 DeviceGroups; /* offset to SID_ARRAY_DATA struct */
581 __le16 UserClaims; /* offset to BLOB_DATA struct */
582 __le16 DeviceClaims; /* offset to BLOB_DATA struct */
583 __u8 TicketInfo[]; /* variable length buf - remoted identity data */
586 struct smb2_tree_connect_req_extension {
587 __le32 TreeConnectContextOffset;
588 __le16 TreeConnectContextCount;
590 __u8 PathName[]; /* variable sized array */
591 /* followed by array of TreeConnectContexts */
594 struct smb2_tree_connect_rsp {
595 struct smb2_sync_hdr sync_hdr;
596 __le16 StructureSize; /* Must be 16 */
597 __u8 ShareType; /* see below */
599 __le32 ShareFlags; /* see below */
600 __le32 Capabilities; /* see below */
601 __le32 MaximalAccess;
604 /* Possible ShareType values */
605 #define SMB2_SHARE_TYPE_DISK 0x01
606 #define SMB2_SHARE_TYPE_PIPE 0x02
607 #define SMB2_SHARE_TYPE_PRINT 0x03
610 * Possible ShareFlags - exactly one and only one of the first 4 caching flags
611 * must be set (any of the remaining, SHI1005, flags may be set individually
614 #define SMB2_SHAREFLAG_MANUAL_CACHING 0x00000000
615 #define SMB2_SHAREFLAG_AUTO_CACHING 0x00000010
616 #define SMB2_SHAREFLAG_VDO_CACHING 0x00000020
617 #define SMB2_SHAREFLAG_NO_CACHING 0x00000030
618 #define SHI1005_FLAGS_DFS 0x00000001
619 #define SHI1005_FLAGS_DFS_ROOT 0x00000002
620 #define SHI1005_FLAGS_RESTRICT_EXCLUSIVE_OPENS 0x00000100
621 #define SHI1005_FLAGS_FORCE_SHARED_DELETE 0x00000200
622 #define SHI1005_FLAGS_ALLOW_NAMESPACE_CACHING 0x00000400
623 #define SHI1005_FLAGS_ACCESS_BASED_DIRECTORY_ENUM 0x00000800
624 #define SHI1005_FLAGS_FORCE_LEVELII_OPLOCK 0x00001000
625 #define SHI1005_FLAGS_ENABLE_HASH_V1 0x00002000
626 #define SHI1005_FLAGS_ENABLE_HASH_V2 0x00004000
627 #define SHI1005_FLAGS_ENCRYPT_DATA 0x00008000
628 #define SMB2_SHAREFLAG_IDENTITY_REMOTING 0x00040000 /* 3.1.1 */
629 #define SHI1005_FLAGS_ALL 0x0004FF33
631 /* Possible share capabilities */
632 #define SMB2_SHARE_CAP_DFS cpu_to_le32(0x00000008) /* all dialects */
633 #define SMB2_SHARE_CAP_CONTINUOUS_AVAILABILITY cpu_to_le32(0x00000010) /* 3.0 */
634 #define SMB2_SHARE_CAP_SCALEOUT cpu_to_le32(0x00000020) /* 3.0 */
635 #define SMB2_SHARE_CAP_CLUSTER cpu_to_le32(0x00000040) /* 3.0 */
636 #define SMB2_SHARE_CAP_ASYMMETRIC cpu_to_le32(0x00000080) /* 3.02 */
637 #define SMB2_SHARE_CAP_REDIRECT_TO_OWNER cpu_to_le32(0x00000100) /* 3.1.1 */
639 struct smb2_tree_disconnect_req {
640 struct smb2_sync_hdr sync_hdr;
641 __le16 StructureSize; /* Must be 4 */
645 struct smb2_tree_disconnect_rsp {
646 struct smb2_sync_hdr sync_hdr;
647 __le16 StructureSize; /* Must be 4 */
651 /* File Attrubutes */
652 #define FILE_ATTRIBUTE_READONLY 0x00000001
653 #define FILE_ATTRIBUTE_HIDDEN 0x00000002
654 #define FILE_ATTRIBUTE_SYSTEM 0x00000004
655 #define FILE_ATTRIBUTE_DIRECTORY 0x00000010
656 #define FILE_ATTRIBUTE_ARCHIVE 0x00000020
657 #define FILE_ATTRIBUTE_NORMAL 0x00000080
658 #define FILE_ATTRIBUTE_TEMPORARY 0x00000100
659 #define FILE_ATTRIBUTE_SPARSE_FILE 0x00000200
660 #define FILE_ATTRIBUTE_REPARSE_POINT 0x00000400
661 #define FILE_ATTRIBUTE_COMPRESSED 0x00000800
662 #define FILE_ATTRIBUTE_OFFLINE 0x00001000
663 #define FILE_ATTRIBUTE_NOT_CONTENT_INDEXED 0x00002000
664 #define FILE_ATTRIBUTE_ENCRYPTED 0x00004000
665 #define FILE_ATTRIBUTE_INTEGRITY_STREAM 0x00008000
666 #define FILE_ATTRIBUTE_NO_SCRUB_DATA 0x00020000
669 #define SMB2_OPLOCK_LEVEL_NONE 0x00
670 #define SMB2_OPLOCK_LEVEL_II 0x01
671 #define SMB2_OPLOCK_LEVEL_EXCLUSIVE 0x08
672 #define SMB2_OPLOCK_LEVEL_BATCH 0x09
673 #define SMB2_OPLOCK_LEVEL_LEASE 0xFF
674 /* Non-spec internal type */
675 #define SMB2_OPLOCK_LEVEL_NOCHANGE 0x99
677 /* Desired Access Flags */
678 #define FILE_READ_DATA_LE cpu_to_le32(0x00000001)
679 #define FILE_WRITE_DATA_LE cpu_to_le32(0x00000002)
680 #define FILE_APPEND_DATA_LE cpu_to_le32(0x00000004)
681 #define FILE_READ_EA_LE cpu_to_le32(0x00000008)
682 #define FILE_WRITE_EA_LE cpu_to_le32(0x00000010)
683 #define FILE_EXECUTE_LE cpu_to_le32(0x00000020)
684 #define FILE_READ_ATTRIBUTES_LE cpu_to_le32(0x00000080)
685 #define FILE_WRITE_ATTRIBUTES_LE cpu_to_le32(0x00000100)
686 #define FILE_DELETE_LE cpu_to_le32(0x00010000)
687 #define FILE_READ_CONTROL_LE cpu_to_le32(0x00020000)
688 #define FILE_WRITE_DAC_LE cpu_to_le32(0x00040000)
689 #define FILE_WRITE_OWNER_LE cpu_to_le32(0x00080000)
690 #define FILE_SYNCHRONIZE_LE cpu_to_le32(0x00100000)
691 #define FILE_ACCESS_SYSTEM_SECURITY_LE cpu_to_le32(0x01000000)
692 #define FILE_MAXIMAL_ACCESS_LE cpu_to_le32(0x02000000)
693 #define FILE_GENERIC_ALL_LE cpu_to_le32(0x10000000)
694 #define FILE_GENERIC_EXECUTE_LE cpu_to_le32(0x20000000)
695 #define FILE_GENERIC_WRITE_LE cpu_to_le32(0x40000000)
696 #define FILE_GENERIC_READ_LE cpu_to_le32(0x80000000)
698 /* ShareAccess Flags */
699 #define FILE_SHARE_READ_LE cpu_to_le32(0x00000001)
700 #define FILE_SHARE_WRITE_LE cpu_to_le32(0x00000002)
701 #define FILE_SHARE_DELETE_LE cpu_to_le32(0x00000004)
702 #define FILE_SHARE_ALL_LE cpu_to_le32(0x00000007)
704 /* CreateDisposition Flags */
705 #define FILE_SUPERSEDE_LE cpu_to_le32(0x00000000)
706 #define FILE_OPEN_LE cpu_to_le32(0x00000001)
707 #define FILE_CREATE_LE cpu_to_le32(0x00000002)
708 #define FILE_OPEN_IF_LE cpu_to_le32(0x00000003)
709 #define FILE_OVERWRITE_LE cpu_to_le32(0x00000004)
710 #define FILE_OVERWRITE_IF_LE cpu_to_le32(0x00000005)
712 /* CreateOptions Flags */
713 #define FILE_DIRECTORY_FILE_LE cpu_to_le32(0x00000001)
714 /* same as #define CREATE_NOT_FILE_LE cpu_to_le32(0x00000001) */
715 #define FILE_WRITE_THROUGH_LE cpu_to_le32(0x00000002)
716 #define FILE_SEQUENTIAL_ONLY_LE cpu_to_le32(0x00000004)
717 #define FILE_NO_INTERMEDIATE_BUFFERRING_LE cpu_to_le32(0x00000008)
718 #define FILE_SYNCHRONOUS_IO_ALERT_LE cpu_to_le32(0x00000010)
719 #define FILE_SYNCHRONOUS_IO_NON_ALERT_LE cpu_to_le32(0x00000020)
720 #define FILE_NON_DIRECTORY_FILE_LE cpu_to_le32(0x00000040)
721 #define FILE_COMPLETE_IF_OPLOCKED_LE cpu_to_le32(0x00000100)
722 #define FILE_NO_EA_KNOWLEDGE_LE cpu_to_le32(0x00000200)
723 #define FILE_RANDOM_ACCESS_LE cpu_to_le32(0x00000800)
724 #define FILE_DELETE_ON_CLOSE_LE cpu_to_le32(0x00001000)
725 #define FILE_OPEN_BY_FILE_ID_LE cpu_to_le32(0x00002000)
726 #define FILE_OPEN_FOR_BACKUP_INTENT_LE cpu_to_le32(0x00004000)
727 #define FILE_NO_COMPRESSION_LE cpu_to_le32(0x00008000)
728 #define FILE_RESERVE_OPFILTER_LE cpu_to_le32(0x00100000)
729 #define FILE_OPEN_REPARSE_POINT_LE cpu_to_le32(0x00200000)
730 #define FILE_OPEN_NO_RECALL_LE cpu_to_le32(0x00400000)
731 #define FILE_OPEN_FOR_FREE_SPACE_QUERY_LE cpu_to_le32(0x00800000)
733 #define FILE_READ_RIGHTS_LE (FILE_READ_DATA_LE | FILE_READ_EA_LE \
734 | FILE_READ_ATTRIBUTES_LE)
735 #define FILE_WRITE_RIGHTS_LE (FILE_WRITE_DATA_LE | FILE_APPEND_DATA_LE \
736 | FILE_WRITE_EA_LE | FILE_WRITE_ATTRIBUTES_LE)
737 #define FILE_EXEC_RIGHTS_LE (FILE_EXECUTE_LE)
739 /* Impersonation Levels. See MS-WPO section 9.7 and MSDN-IMPERS */
740 #define IL_ANONYMOUS cpu_to_le32(0x00000000)
741 #define IL_IDENTIFICATION cpu_to_le32(0x00000001)
742 #define IL_IMPERSONATION cpu_to_le32(0x00000002)
743 #define IL_DELEGATE cpu_to_le32(0x00000003)
745 /* Create Context Values */
746 #define SMB2_CREATE_EA_BUFFER "ExtA" /* extended attributes */
747 #define SMB2_CREATE_SD_BUFFER "SecD" /* security descriptor */
748 #define SMB2_CREATE_DURABLE_HANDLE_REQUEST "DHnQ"
749 #define SMB2_CREATE_DURABLE_HANDLE_RECONNECT "DHnC"
750 #define SMB2_CREATE_ALLOCATION_SIZE "AISi"
751 #define SMB2_CREATE_QUERY_MAXIMAL_ACCESS_REQUEST "MxAc"
752 #define SMB2_CREATE_TIMEWARP_REQUEST "TWrp"
753 #define SMB2_CREATE_QUERY_ON_DISK_ID "QFid"
754 #define SMB2_CREATE_REQUEST_LEASE "RqLs"
755 #define SMB2_CREATE_DURABLE_HANDLE_REQUEST_V2 "DH2Q"
756 #define SMB2_CREATE_DURABLE_HANDLE_RECONNECT_V2 "DH2C"
757 #define SMB2_CREATE_APP_INSTANCE_ID 0x45BCA66AEFA7F74A9008FA462E144D74
758 #define SMB2_CREATE_APP_INSTANCE_VERSION 0xB982D0B73B56074FA07B524A8116A010
759 #define SVHDX_OPEN_DEVICE_CONTEX 0x9CCBCF9E04C1E643980E158DA1F6EC83
760 #define SMB2_CREATE_TAG_POSIX 0x93AD25509CB411E7B42383DE968BCD7C
762 /* Flag (SMB3 open response) values */
763 #define SMB2_CREATE_FLAG_REPARSEPOINT 0x01
766 * Maximum number of iovs we need for an open/create request.
767 * [0] : struct smb2_create_req
769 * [2] : lease context
770 * [3] : durable context
771 * [4] : posix context
772 * [5] : time warp context
773 * [6] : query id context
774 * [7] : compound padding
776 #define SMB2_CREATE_IOV_SIZE 8
778 struct smb2_create_req {
779 struct smb2_sync_hdr sync_hdr;
780 __le16 StructureSize; /* Must be 57 */
782 __u8 RequestedOplockLevel;
783 __le32 ImpersonationLevel;
784 __le64 SmbCreateFlags;
786 __le32 DesiredAccess;
787 __le32 FileAttributes;
789 __le32 CreateDisposition;
790 __le32 CreateOptions;
793 __le32 CreateContextsOffset;
794 __le32 CreateContextsLength;
799 * Maximum size of a SMB2_CREATE response is 64 (smb2 header) +
800 * 88 (fixed part of create response) + 520 (path) + 208 (contexts) +
801 * 2 bytes of padding.
803 #define MAX_SMB2_CREATE_RESPONSE_SIZE 880
805 struct smb2_create_rsp {
806 struct smb2_sync_hdr sync_hdr;
807 __le16 StructureSize; /* Must be 89 */
809 __u8 Flag; /* 0x01 if reparse point */
812 __le64 LastAccessTime;
813 __le64 LastWriteTime;
815 __le64 AllocationSize;
817 __le32 FileAttributes;
819 __u64 PersistentFileId; /* opaque endianness */
820 __u64 VolatileFileId; /* opaque endianness */
821 __le32 CreateContextsOffset;
822 __le32 CreateContextsLength;
826 struct create_context {
836 #define SMB2_LEASE_READ_CACHING_HE 0x01
837 #define SMB2_LEASE_HANDLE_CACHING_HE 0x02
838 #define SMB2_LEASE_WRITE_CACHING_HE 0x04
840 #define SMB2_LEASE_NONE cpu_to_le32(0x00)
841 #define SMB2_LEASE_READ_CACHING cpu_to_le32(0x01)
842 #define SMB2_LEASE_HANDLE_CACHING cpu_to_le32(0x02)
843 #define SMB2_LEASE_WRITE_CACHING cpu_to_le32(0x04)
845 #define SMB2_LEASE_FLAG_BREAK_IN_PROGRESS cpu_to_le32(0x00000002)
846 #define SMB2_LEASE_FLAG_PARENT_LEASE_KEY_SET cpu_to_le32(0x00000004)
848 #define SMB2_LEASE_KEY_SIZE 16
850 struct lease_context {
851 u8 LeaseKey[SMB2_LEASE_KEY_SIZE];
854 __le64 LeaseDuration;
857 struct lease_context_v2 {
858 u8 LeaseKey[SMB2_LEASE_KEY_SIZE];
861 __le64 LeaseDuration;
862 __le64 ParentLeaseKeyLow;
863 __le64 ParentLeaseKeyHigh;
868 struct create_lease {
869 struct create_context ccontext;
871 struct lease_context lcontext;
874 struct create_lease_v2 {
875 struct create_context ccontext;
877 struct lease_context_v2 lcontext;
881 struct create_durable {
882 struct create_context ccontext;
887 __u64 PersistentFileId;
888 __u64 VolatileFileId;
893 struct create_posix {
894 struct create_context ccontext;
900 /* See MS-SMB2 2.2.13.2.11 */
902 #define SMB2_DHANDLE_FLAG_PERSISTENT 0x00000002
903 struct durable_context_v2 {
910 struct create_durable_v2 {
911 struct create_context ccontext;
913 struct durable_context_v2 dcontext;
916 /* See MS-SMB2 2.2.13.2.12 */
917 struct durable_reconnect_context_v2 {
919 __u64 PersistentFileId;
920 __u64 VolatileFileId;
923 __le32 Flags; /* see above DHANDLE_FLAG_PERSISTENT */
926 /* See MS-SMB2 2.2.14.2.9 */
927 struct create_on_disk_id {
928 struct create_context ccontext;
935 /* See MS-SMB2 2.2.14.2.12 */
936 struct durable_reconnect_context_v2_rsp {
938 __le32 Flags; /* see above DHANDLE_FLAG_PERSISTENT */
941 struct create_durable_handle_reconnect_v2 {
942 struct create_context ccontext;
944 struct durable_reconnect_context_v2 dcontext;
948 /* See MS-SMB2 2.2.13.2.5 */
949 struct crt_twarp_ctxt {
950 struct create_context ccontext;
956 /* See MS-SMB2 2.2.13.2.9 */
957 struct crt_query_id_ctxt {
958 struct create_context ccontext;
963 struct create_context ccontext;
967 /* Followed by at least 4 ACEs */
971 #define COPY_CHUNK_RES_KEY_SIZE 24
972 struct resume_key_req {
973 char ResumeKey[COPY_CHUNK_RES_KEY_SIZE];
974 __le32 ContextLength; /* MBZ */
975 char Context[]; /* ignored, Windows sets to 4 bytes of zero */
978 /* this goes in the ioctl buffer when doing a copychunk request */
979 struct copychunk_ioctl {
980 char SourceKey[COPY_CHUNK_RES_KEY_SIZE];
981 __le32 ChunkCount; /* we are only sending 1 */
983 /* array will only be one chunk long for us */
986 __le32 Length; /* how many bytes to copy */
990 /* this goes in the ioctl buffer when doing FSCTL_SET_ZERO_DATA */
991 struct file_zero_data_information {
993 __le64 BeyondFinalZero;
996 struct copychunk_ioctl_rsp {
997 __le32 ChunksWritten;
998 __le32 ChunkBytesWritten;
999 __le32 TotalBytesWritten;
1002 struct fsctl_set_integrity_information_req {
1003 __le16 ChecksumAlgorithm;
1008 struct fsctl_get_integrity_information_rsp {
1009 __le16 ChecksumAlgorithm;
1012 __le32 ChecksumChunkSizeInBytes;
1013 __le32 ClusterSizeInBytes;
1016 struct file_allocated_range_buffer {
1021 /* Integrity ChecksumAlgorithm choices for above */
1022 #define CHECKSUM_TYPE_NONE 0x0000
1023 #define CHECKSUM_TYPE_CRC64 0x0002
1024 #define CHECKSUM_TYPE_UNCHANGED 0xFFFF /* set only */
1026 /* Integrity flags for above */
1027 #define FSCTL_INTEGRITY_FLAG_CHECKSUM_ENFORCEMENT_OFF 0x00000001
1029 /* Reparse structures - see MS-FSCC 2.1.2 */
1031 /* struct fsctl_reparse_info_req is empty, only response structs (see below) */
1033 struct reparse_data_buffer {
1035 __le16 ReparseDataLength;
1037 __u8 DataBuffer[]; /* Variable Length */
1040 struct reparse_guid_data_buffer {
1042 __le16 ReparseDataLength;
1044 __u8 ReparseGuid[16];
1045 __u8 DataBuffer[]; /* Variable Length */
1048 struct reparse_mount_point_data_buffer {
1050 __le16 ReparseDataLength;
1052 __le16 SubstituteNameOffset;
1053 __le16 SubstituteNameLength;
1054 __le16 PrintNameOffset;
1055 __le16 PrintNameLength;
1056 __u8 PathBuffer[]; /* Variable Length */
1059 #define SYMLINK_FLAG_RELATIVE 0x00000001
1061 struct reparse_symlink_data_buffer {
1063 __le16 ReparseDataLength;
1065 __le16 SubstituteNameOffset;
1066 __le16 SubstituteNameLength;
1067 __le16 PrintNameOffset;
1068 __le16 PrintNameLength;
1070 __u8 PathBuffer[]; /* Variable Length */
1073 /* See MS-FSCC 2.1.2.6 and cifspdu.h for struct reparse_posix_data */
1076 /* See MS-DFSC 2.2.2 */
1077 struct fsctl_get_dfs_referral_req {
1078 __le16 MaxReferralLevel;
1079 __u8 RequestFileName[];
1082 /* DFS response is struct get_dfs_refer_rsp */
1084 /* See MS-SMB2 2.2.31.3 */
1085 struct network_resiliency_req {
1089 /* There is no buffer for the response ie no struct network_resiliency_rsp */
1092 struct validate_negotiate_info_req {
1093 __le32 Capabilities;
1094 __u8 Guid[SMB2_CLIENT_GUID_SIZE];
1095 __le16 SecurityMode;
1096 __le16 DialectCount;
1097 __le16 Dialects[4]; /* BB expand this if autonegotiate > 4 dialects */
1100 struct validate_negotiate_info_rsp {
1101 __le32 Capabilities;
1102 __u8 Guid[SMB2_CLIENT_GUID_SIZE];
1103 __le16 SecurityMode;
1104 __le16 Dialect; /* Dialect in use for the connection */
1107 #define RSS_CAPABLE cpu_to_le32(0x00000001)
1108 #define RDMA_CAPABLE cpu_to_le32(0x00000002)
1110 #define INTERNETWORK cpu_to_le16(0x0002)
1111 #define INTERNETWORKV6 cpu_to_le16(0x0017)
1113 struct network_interface_info_ioctl_rsp {
1114 __le32 Next; /* next interface. zero if this is last one */
1116 __le32 Capability; /* RSS or RDMA Capable */
1123 struct iface_info_ipv4 {
1129 struct iface_info_ipv6 {
1132 __u8 IPv6Address[16];
1136 #define NO_FILE_ID 0xFFFFFFFFFFFFFFFFULL /* general ioctls to srv not to file */
1138 struct compress_ioctl {
1139 __le16 CompressionState; /* See cifspdu.h for possible flag values */
1142 struct duplicate_extents_to_file {
1143 __u64 PersistentFileHandle; /* source file handle, opaque endianness */
1144 __u64 VolatileFileHandle;
1145 __le64 SourceFileOffset;
1146 __le64 TargetFileOffset;
1147 __le64 ByteCount; /* Bytes to be copied */
1151 * Maximum number of iovs we need for an ioctl request.
1152 * [0] : struct smb2_ioctl_req
1155 #define SMB2_IOCTL_IOV_SIZE 2
1157 struct smb2_ioctl_req {
1158 struct smb2_sync_hdr sync_hdr;
1159 __le16 StructureSize; /* Must be 57 */
1162 __u64 PersistentFileId; /* opaque endianness */
1163 __u64 VolatileFileId; /* opaque endianness */
1166 __le32 MaxInputResponse;
1167 __le32 OutputOffset;
1169 __le32 MaxOutputResponse;
1175 struct smb2_ioctl_rsp {
1176 struct smb2_sync_hdr sync_hdr;
1177 __le16 StructureSize; /* Must be 57 */
1180 __u64 PersistentFileId; /* opaque endianness */
1181 __u64 VolatileFileId; /* opaque endianness */
1184 __le32 OutputOffset;
1188 /* char * buffer[] */
1191 /* Currently defined values for close flags */
1192 #define SMB2_CLOSE_FLAG_POSTQUERY_ATTRIB cpu_to_le16(0x0001)
1193 struct smb2_close_req {
1194 struct smb2_sync_hdr sync_hdr;
1195 __le16 StructureSize; /* Must be 24 */
1198 __u64 PersistentFileId; /* opaque endianness */
1199 __u64 VolatileFileId; /* opaque endianness */
1203 * Maximum size of a SMB2_CLOSE response is 64 (smb2 header) + 60 (data)
1205 #define MAX_SMB2_CLOSE_RESPONSE_SIZE 124
1207 struct smb2_close_rsp {
1208 struct smb2_sync_hdr sync_hdr;
1209 __le16 StructureSize; /* 60 */
1212 __le64 CreationTime;
1213 __le64 LastAccessTime;
1214 __le64 LastWriteTime;
1216 __le64 AllocationSize; /* Beginning of FILE_STANDARD_INFO equivalent */
1221 struct smb2_flush_req {
1222 struct smb2_sync_hdr sync_hdr;
1223 __le16 StructureSize; /* Must be 24 */
1226 __u64 PersistentFileId; /* opaque endianness */
1227 __u64 VolatileFileId; /* opaque endianness */
1230 struct smb2_flush_rsp {
1231 struct smb2_sync_hdr sync_hdr;
1232 __le16 StructureSize;
1236 /* For read request Flags field below, following flag is defined for SMB3.02 */
1237 #define SMB2_READFLAG_READ_UNBUFFERED 0x01
1238 #define SMB2_READFLAG_REQUEST_COMPRESSED 0x02 /* See MS-SMB2 2.2.19 */
1240 /* Channel field for read and write: exactly one of following flags can be set*/
1241 #define SMB2_CHANNEL_NONE cpu_to_le32(0x00000000)
1242 #define SMB2_CHANNEL_RDMA_V1 cpu_to_le32(0x00000001) /* SMB3 or later */
1243 #define SMB2_CHANNEL_RDMA_V1_INVALIDATE cpu_to_le32(0x00000002) /* >= SMB3.02 */
1244 #define SMB2_CHANNEL_RDMA_TRANSFORM cpu_to_le32(0x00000003) /* >= SMB3.02, only used on write */
1246 /* SMB2 read request without RFC1001 length at the beginning */
1247 struct smb2_read_plain_req {
1248 struct smb2_sync_hdr sync_hdr;
1249 __le16 StructureSize; /* Must be 49 */
1250 __u8 Padding; /* offset from start of SMB2 header to place read */
1251 __u8 Flags; /* MBZ unless SMB3.02 or later */
1254 __u64 PersistentFileId; /* opaque endianness */
1255 __u64 VolatileFileId; /* opaque endianness */
1256 __le32 MinimumCount;
1257 __le32 Channel; /* MBZ except for SMB3 or later */
1258 __le32 RemainingBytes;
1259 __le16 ReadChannelInfoOffset;
1260 __le16 ReadChannelInfoLength;
1265 #define SMB2_READFLAG_RESPONSE_NONE 0x00000000
1266 #define SMB2_READFLAG_RESPONSE_RDMA_TRANSFORM 0x00000001
1268 struct smb2_read_rsp {
1269 struct smb2_sync_hdr sync_hdr;
1270 __le16 StructureSize; /* Must be 17 */
1274 __le32 DataRemaining;
1279 /* For write request Flags field below the following flags are defined: */
1280 #define SMB2_WRITEFLAG_WRITE_THROUGH 0x00000001 /* SMB2.1 or later */
1281 #define SMB2_WRITEFLAG_WRITE_UNBUFFERED 0x00000002 /* SMB3.02 or later */
1283 struct smb2_write_req {
1284 struct smb2_sync_hdr sync_hdr;
1285 __le16 StructureSize; /* Must be 49 */
1286 __le16 DataOffset; /* offset from start of SMB2 header to write data */
1289 __u64 PersistentFileId; /* opaque endianness */
1290 __u64 VolatileFileId; /* opaque endianness */
1291 __le32 Channel; /* MBZ unless SMB3.02 or later */
1292 __le32 RemainingBytes;
1293 __le16 WriteChannelInfoOffset;
1294 __le16 WriteChannelInfoLength;
1299 struct smb2_write_rsp {
1300 struct smb2_sync_hdr sync_hdr;
1301 __le16 StructureSize; /* Must be 17 */
1305 __le32 DataRemaining;
1311 #define SMB2_WATCH_TREE 0x0001
1313 /* notify completion filter flags. See MS-FSCC 2.6 and MS-SMB2 2.2.35 */
1314 #define FILE_NOTIFY_CHANGE_FILE_NAME 0x00000001
1315 #define FILE_NOTIFY_CHANGE_DIR_NAME 0x00000002
1316 #define FILE_NOTIFY_CHANGE_ATTRIBUTES 0x00000004
1317 #define FILE_NOTIFY_CHANGE_SIZE 0x00000008
1318 #define FILE_NOTIFY_CHANGE_LAST_WRITE 0x00000010
1319 #define FILE_NOTIFY_CHANGE_LAST_ACCESS 0x00000020
1320 #define FILE_NOTIFY_CHANGE_CREATION 0x00000040
1321 #define FILE_NOTIFY_CHANGE_EA 0x00000080
1322 #define FILE_NOTIFY_CHANGE_SECURITY 0x00000100
1323 #define FILE_NOTIFY_CHANGE_STREAM_NAME 0x00000200
1324 #define FILE_NOTIFY_CHANGE_STREAM_SIZE 0x00000400
1325 #define FILE_NOTIFY_CHANGE_STREAM_WRITE 0x00000800
1327 struct smb2_change_notify_req {
1328 struct smb2_sync_hdr sync_hdr;
1329 __le16 StructureSize;
1331 __le32 OutputBufferLength;
1332 __u64 PersistentFileId; /* opaque endianness */
1333 __u64 VolatileFileId; /* opaque endianness */
1334 __le32 CompletionFilter;
1338 struct smb2_change_notify_rsp {
1339 struct smb2_sync_hdr sync_hdr;
1340 __le16 StructureSize; /* Must be 9 */
1341 __le16 OutputBufferOffset;
1342 __le32 OutputBufferLength;
1343 __u8 Buffer[1]; /* array of file notify structs */
1346 #define SMB2_LOCKFLAG_SHARED_LOCK 0x0001
1347 #define SMB2_LOCKFLAG_EXCLUSIVE_LOCK 0x0002
1348 #define SMB2_LOCKFLAG_UNLOCK 0x0004
1349 #define SMB2_LOCKFLAG_FAIL_IMMEDIATELY 0x0010
1351 struct smb2_lock_element {
1358 struct smb2_lock_req {
1359 struct smb2_sync_hdr sync_hdr;
1360 __le16 StructureSize; /* Must be 48 */
1363 __u64 PersistentFileId; /* opaque endianness */
1364 __u64 VolatileFileId; /* opaque endianness */
1365 /* Followed by at least one */
1366 struct smb2_lock_element locks[1];
1369 struct smb2_lock_rsp {
1370 struct smb2_sync_hdr sync_hdr;
1371 __le16 StructureSize; /* Must be 4 */
1375 struct smb2_echo_req {
1376 struct smb2_sync_hdr sync_hdr;
1377 __le16 StructureSize; /* Must be 4 */
1381 struct smb2_echo_rsp {
1382 struct smb2_sync_hdr sync_hdr;
1383 __le16 StructureSize; /* Must be 4 */
1387 /* search (query_directory) Flags field */
1388 #define SMB2_RESTART_SCANS 0x01
1389 #define SMB2_RETURN_SINGLE_ENTRY 0x02
1390 #define SMB2_INDEX_SPECIFIED 0x04
1391 #define SMB2_REOPEN 0x10
1393 #define SMB2_QUERY_DIRECTORY_IOV_SIZE 2
1395 struct smb2_query_directory_req {
1396 struct smb2_sync_hdr sync_hdr;
1397 __le16 StructureSize; /* Must be 33 */
1398 __u8 FileInformationClass;
1401 __u64 PersistentFileId; /* opaque endianness */
1402 __u64 VolatileFileId; /* opaque endianness */
1403 __le16 FileNameOffset;
1404 __le16 FileNameLength;
1405 __le32 OutputBufferLength;
1409 struct smb2_query_directory_rsp {
1410 struct smb2_sync_hdr sync_hdr;
1411 __le16 StructureSize; /* Must be 9 */
1412 __le16 OutputBufferOffset;
1413 __le32 OutputBufferLength;
1417 /* Possible InfoType values */
1418 #define SMB2_O_INFO_FILE 0x01
1419 #define SMB2_O_INFO_FILESYSTEM 0x02
1420 #define SMB2_O_INFO_SECURITY 0x03
1421 #define SMB2_O_INFO_QUOTA 0x04
1423 /* Security info type additionalinfo flags. See MS-SMB2 (2.2.37) or MS-DTYP */
1424 #define OWNER_SECINFO 0x00000001
1425 #define GROUP_SECINFO 0x00000002
1426 #define DACL_SECINFO 0x00000004
1427 #define SACL_SECINFO 0x00000008
1428 #define LABEL_SECINFO 0x00000010
1429 #define ATTRIBUTE_SECINFO 0x00000020
1430 #define SCOPE_SECINFO 0x00000040
1431 #define BACKUP_SECINFO 0x00010000
1432 #define UNPROTECTED_SACL_SECINFO 0x10000000
1433 #define UNPROTECTED_DACL_SECINFO 0x20000000
1434 #define PROTECTED_SACL_SECINFO 0x40000000
1435 #define PROTECTED_DACL_SECINFO 0x80000000
1437 /* Flags used for FileFullEAinfo */
1438 #define SL_RESTART_SCAN 0x00000001
1439 #define SL_RETURN_SINGLE_ENTRY 0x00000002
1440 #define SL_INDEX_SPECIFIED 0x00000004
1442 struct smb2_query_info_req {
1443 struct smb2_sync_hdr sync_hdr;
1444 __le16 StructureSize; /* Must be 41 */
1447 __le32 OutputBufferLength;
1448 __le16 InputBufferOffset;
1450 __le32 InputBufferLength;
1451 __le32 AdditionalInformation;
1453 __u64 PersistentFileId; /* opaque endianness */
1454 __u64 VolatileFileId; /* opaque endianness */
1458 struct smb2_query_info_rsp {
1459 struct smb2_sync_hdr sync_hdr;
1460 __le16 StructureSize; /* Must be 9 */
1461 __le16 OutputBufferOffset;
1462 __le32 OutputBufferLength;
1467 * Maximum number of iovs we need for a set-info request.
1468 * The largest one is rename/hardlink
1469 * [0] : struct smb2_set_info_req + smb2_file_[rename|link]_info
1471 * [2] : compound padding
1473 #define SMB2_SET_INFO_IOV_SIZE 3
1475 struct smb2_set_info_req {
1476 struct smb2_sync_hdr sync_hdr;
1477 __le16 StructureSize; /* Must be 33 */
1480 __le32 BufferLength;
1481 __le16 BufferOffset;
1483 __le32 AdditionalInformation;
1484 __u64 PersistentFileId; /* opaque endianness */
1485 __u64 VolatileFileId; /* opaque endianness */
1489 struct smb2_set_info_rsp {
1490 struct smb2_sync_hdr sync_hdr;
1491 __le16 StructureSize; /* Must be 2 */
1494 struct smb2_oplock_break {
1495 struct smb2_sync_hdr sync_hdr;
1496 __le16 StructureSize; /* Must be 24 */
1500 __u64 PersistentFid;
1504 #define SMB2_NOTIFY_BREAK_LEASE_FLAG_ACK_REQUIRED cpu_to_le32(0x01)
1506 struct smb2_lease_break {
1507 struct smb2_sync_hdr sync_hdr;
1508 __le16 StructureSize; /* Must be 44 */
1512 __le32 CurrentLeaseState;
1513 __le32 NewLeaseState;
1515 __le32 AccessMaskHint;
1516 __le32 ShareMaskHint;
1519 struct smb2_lease_ack {
1520 struct smb2_sync_hdr sync_hdr;
1521 __le16 StructureSize; /* Must be 36 */
1526 __le64 LeaseDuration;
1530 * PDU infolevel structure definitions
1531 * BB consider moving to a different header
1534 /* File System Information Classes */
1535 #define FS_VOLUME_INFORMATION 1 /* Query */
1536 #define FS_LABEL_INFORMATION 2 /* Local only */
1537 #define FS_SIZE_INFORMATION 3 /* Query */
1538 #define FS_DEVICE_INFORMATION 4 /* Query */
1539 #define FS_ATTRIBUTE_INFORMATION 5 /* Query */
1540 #define FS_CONTROL_INFORMATION 6 /* Query, Set */
1541 #define FS_FULL_SIZE_INFORMATION 7 /* Query */
1542 #define FS_OBJECT_ID_INFORMATION 8 /* Query, Set */
1543 #define FS_DRIVER_PATH_INFORMATION 9 /* Local only */
1544 #define FS_VOLUME_FLAGS_INFORMATION 10 /* Local only */
1545 #define FS_SECTOR_SIZE_INFORMATION 11 /* SMB3 or later. Query */
1546 #define FS_POSIX_INFORMATION 100 /* SMB3.1.1 POSIX. Query */
1548 struct smb2_fs_full_size_info {
1549 __le64 TotalAllocationUnits;
1550 __le64 CallerAvailableAllocationUnits;
1551 __le64 ActualAvailableAllocationUnits;
1552 __le32 SectorsPerAllocationUnit;
1553 __le32 BytesPerSector;
1556 #define SSINFO_FLAGS_ALIGNED_DEVICE 0x00000001
1557 #define SSINFO_FLAGS_PARTITION_ALIGNED_ON_DEVICE 0x00000002
1558 #define SSINFO_FLAGS_NO_SEEK_PENALTY 0x00000004
1559 #define SSINFO_FLAGS_TRIM_ENABLED 0x00000008
1561 /* sector size info struct */
1562 struct smb3_fs_ss_info {
1563 __le32 LogicalBytesPerSector;
1564 __le32 PhysicalBytesPerSectorForAtomicity;
1565 __le32 PhysicalBytesPerSectorForPerf;
1566 __le32 FileSystemEffectivePhysicalBytesPerSectorForAtomicity;
1568 __le32 ByteOffsetForSectorAlignment;
1569 __le32 ByteOffsetForPartitionAlignment;
1572 /* volume info struct - see MS-FSCC 2.5.9 */
1573 #define MAX_VOL_LABEL_LEN 32
1574 struct smb3_fs_vol_info {
1575 __le64 VolumeCreationTime;
1576 __u32 VolumeSerialNumber;
1577 __le32 VolumeLabelLength; /* includes trailing null */
1578 __u8 SupportsObjects; /* True if eg like NTFS, supports objects */
1580 __u8 VolumeLabel[]; /* variable len */
1583 /* partial list of QUERY INFO levels */
1584 #define FILE_DIRECTORY_INFORMATION 1
1585 #define FILE_FULL_DIRECTORY_INFORMATION 2
1586 #define FILE_BOTH_DIRECTORY_INFORMATION 3
1587 #define FILE_BASIC_INFORMATION 4
1588 #define FILE_STANDARD_INFORMATION 5
1589 #define FILE_INTERNAL_INFORMATION 6
1590 #define FILE_EA_INFORMATION 7
1591 #define FILE_ACCESS_INFORMATION 8
1592 #define FILE_NAME_INFORMATION 9
1593 #define FILE_RENAME_INFORMATION 10
1594 #define FILE_LINK_INFORMATION 11
1595 #define FILE_NAMES_INFORMATION 12
1596 #define FILE_DISPOSITION_INFORMATION 13
1597 #define FILE_POSITION_INFORMATION 14
1598 #define FILE_FULL_EA_INFORMATION 15
1599 #define FILE_MODE_INFORMATION 16
1600 #define FILE_ALIGNMENT_INFORMATION 17
1601 #define FILE_ALL_INFORMATION 18
1602 #define FILE_ALLOCATION_INFORMATION 19
1603 #define FILE_END_OF_FILE_INFORMATION 20
1604 #define FILE_ALTERNATE_NAME_INFORMATION 21
1605 #define FILE_STREAM_INFORMATION 22
1606 #define FILE_PIPE_INFORMATION 23
1607 #define FILE_PIPE_LOCAL_INFORMATION 24
1608 #define FILE_PIPE_REMOTE_INFORMATION 25
1609 #define FILE_MAILSLOT_QUERY_INFORMATION 26
1610 #define FILE_MAILSLOT_SET_INFORMATION 27
1611 #define FILE_COMPRESSION_INFORMATION 28
1612 #define FILE_OBJECT_ID_INFORMATION 29
1613 /* Number 30 not defined in documents */
1614 #define FILE_MOVE_CLUSTER_INFORMATION 31
1615 #define FILE_QUOTA_INFORMATION 32
1616 #define FILE_REPARSE_POINT_INFORMATION 33
1617 #define FILE_NETWORK_OPEN_INFORMATION 34
1618 #define FILE_ATTRIBUTE_TAG_INFORMATION 35
1619 #define FILE_TRACKING_INFORMATION 36
1620 #define FILEID_BOTH_DIRECTORY_INFORMATION 37
1621 #define FILEID_FULL_DIRECTORY_INFORMATION 38
1622 #define FILE_VALID_DATA_LENGTH_INFORMATION 39
1623 #define FILE_SHORT_NAME_INFORMATION 40
1624 #define FILE_SFIO_RESERVE_INFORMATION 44
1625 #define FILE_SFIO_VOLUME_INFORMATION 45
1626 #define FILE_HARD_LINK_INFORMATION 46
1627 #define FILE_NORMALIZED_NAME_INFORMATION 48
1628 #define FILEID_GLOBAL_TX_DIRECTORY_INFORMATION 50
1629 #define FILE_STANDARD_LINK_INFORMATION 54
1630 #define FILE_ID_INFORMATION 59
1632 struct smb2_file_internal_info {
1634 } __packed; /* level 6 Query */
1636 struct smb2_file_rename_info { /* encoding of request for level 10 */
1637 __u8 ReplaceIfExists; /* 1 = replace existing target with new */
1638 /* 0 = fail if target already exists */
1640 __u64 RootDirectory; /* MBZ for network operations (why says spec?) */
1641 __le32 FileNameLength;
1642 char FileName[]; /* New name to be assigned */
1643 } __packed; /* level 10 Set */
1645 struct smb2_file_link_info { /* encoding of request for level 11 */
1646 __u8 ReplaceIfExists; /* 1 = replace existing link with new */
1647 /* 0 = fail if link already exists */
1649 __u64 RootDirectory; /* MBZ for network operations (why says spec?) */
1650 __le32 FileNameLength;
1651 char FileName[]; /* Name to be assigned to new link */
1652 } __packed; /* level 11 Set */
1654 struct smb2_file_full_ea_info { /* encoding of response for level 15 */
1655 __le32 next_entry_offset;
1657 __u8 ea_name_length;
1658 __le16 ea_value_length;
1659 char ea_data[]; /* \0 terminated name plus value */
1660 } __packed; /* level 15 Set */
1663 * This level 18, although with struct with same name is different from cifs
1664 * level 0x107. Level 0x107 has an extra u64 between AccessFlags and
1665 * CurrentByteOffset.
1667 struct smb2_file_all_info { /* data block encoding of response to level 18 */
1668 __le64 CreationTime; /* Beginning of FILE_BASIC_INFO equivalent */
1669 __le64 LastAccessTime;
1670 __le64 LastWriteTime;
1673 __u32 Pad1; /* End of FILE_BASIC_INFO_INFO equivalent */
1674 __le64 AllocationSize; /* Beginning of FILE_STANDARD_INFO equivalent */
1675 __le64 EndOfFile; /* size ie offset to first free byte in file */
1676 __le32 NumberOfLinks; /* hard links */
1679 __u16 Pad2; /* End of FILE_STANDARD_INFO equivalent */
1683 __le64 CurrentByteOffset;
1685 __le32 AlignmentRequirement;
1686 __le32 FileNameLength;
1688 } __packed; /* level 18 Query */
1690 struct smb2_file_eof_info { /* encoding of request for level 10 */
1691 __le64 EndOfFile; /* new end of file value */
1692 } __packed; /* level 20 Set */
1694 struct smb2_file_network_open_info {
1695 __le64 CreationTime;
1696 __le64 LastAccessTime;
1697 __le64 LastWriteTime;
1699 __le64 AllocationSize;
1703 } __packed; /* level 34 Query also similar returned in close rsp and open rsp */
1705 /* See MS-FSCC 2.4.43 */
1706 struct smb2_file_id_information {
1707 __le64 VolumeSerialNumber;
1708 __u64 PersistentFileId; /* opaque endianness */
1709 __u64 VolatileFileId; /* opaque endianness */
1710 } __packed; /* level 59 */
1712 extern char smb2_padding[7];
1714 /* equivalent of the contents of SMB3.1.1 POSIX open context response */
1715 struct create_posix_rsp {
1719 struct cifs_sid owner; /* var-sized on the wire */
1720 struct cifs_sid group; /* var-sized on the wire */
1724 * SMB2-only POSIX info level for query dir
1726 * See posix_info_sid_size(), posix_info_extra_size() and
1727 * posix_info_parse() to help with the handling of this struct.
1729 struct smb2_posix_info {
1730 __le32 NextEntryOffset;
1732 __le64 CreationTime;
1733 __le64 LastAccessTime;
1734 __le64 LastWriteTime;
1737 __le64 AllocationSize;
1738 __le32 DosAttributes;
1742 /* beginning of POSIX Create Context Response */
1747 * var sized owner SID
1748 * var sized group SID
1749 * le32 filenamelength
1754 /* Level 100 query info */
1755 struct smb311_posix_qinfo {
1756 __le64 CreationTime;
1757 __le64 LastAccessTime;
1758 __le64 LastWriteTime;
1761 __le64 AllocationSize;
1762 __le32 DosAttributes;
1766 /* beginning of POSIX Create Context Response */
1772 * var sized owner SID
1773 * var sized group SID
1774 * le32 filenamelength
1780 * Parsed version of the above struct. Allows direct access to the
1781 * variable length fields
1783 struct smb2_posix_info_parsed {
1784 const struct smb2_posix_info *base;
1786 struct cifs_sid owner;
1787 struct cifs_sid group;
1792 #endif /* _SMB2PDU_H */