1 /* SPDX-License-Identifier: LGPL-2.1 */
4 * Copyright (c) International Business Machines Corp., 2009, 2013
17 /* 52 transform hdr + 64 hdr + 88 create rsp */
18 #define SMB2_TRANSFORM_HEADER_SIZE 52
19 #define MAX_SMB2_HDR_SIZE 204
21 /* The total header size for SMB2 read and write */
22 #define SMB2_READWRITE_PDU_HEADER_SIZE (48 + sizeof(struct smb2_hdr))
24 /* See MS-SMB2 2.2.43 */
25 struct smb2_rdma_transform {
26 __le16 RdmaDescriptorOffset;
27 __le16 RdmaDescriptorLength;
28 __le32 Channel; /* for values see channel description in smb2 read above */
29 __le16 TransformCount;
35 #define SMB2_RDMA_TRANSFORM_TYPE_ENCRYPTION 0x0001
36 #define SMB2_RDMA_TRANSFORM_TYPE_SIGNING 0x0002
38 struct smb2_rdma_crypto_transform {
40 __le16 SignatureLength;
43 __u8 Signature[]; /* variable length */
45 /* followed by padding */
49 * Definitions for SMB2 Protocol Data Units (network frames)
51 * See MS-SMB2.PDF specification for protocol details.
52 * The Naming convention is the lower case version of the SMB2
53 * command code name for the struct. Note that structures must be packed.
57 #define COMPOUND_FID 0xFFFFFFFFFFFFFFFFULL
59 #define SYMLINK_ERROR_TAG 0x4c4d5953
61 struct smb2_symlink_err_rsp {
63 __le32 SymLinkErrorTag;
65 __le16 ReparseDataLength;
66 __le16 UnparsedPathLength;
67 __le16 SubstituteNameOffset;
68 __le16 SubstituteNameLength;
69 __le16 PrintNameOffset;
70 __le16 PrintNameLength;
75 /* SMB 3.1.1 and later dialects. See MS-SMB2 section 2.2.2.1 */
76 struct smb2_error_context_rsp {
77 __le32 ErrorDataLength;
79 __u8 ErrorContextData; /* ErrorDataLength long array */
83 #define SMB2_ERROR_ID_DEFAULT 0x00000000
84 #define SMB2_ERROR_ID_SHARE_REDIRECT cpu_to_le32(0x72645253) /* "rdRS" */
86 /* Defines for Type field below (see MS-SMB2 2.2.2.2.2.1) */
87 #define MOVE_DST_IPADDR_V4 cpu_to_le32(0x00000001)
88 #define MOVE_DST_IPADDR_V6 cpu_to_le32(0x00000002)
90 struct move_dst_ipaddr {
93 __u8 address[16]; /* IPv4 followed by 12 bytes rsvd or IPv6 address */
96 struct share_redirect_error_context_rsp {
98 __le32 NotificationType;
99 __le32 ResourceNameOffset;
100 __le32 ResourceNameLength;
104 struct move_dst_ipaddr IpAddrMoveList[];
105 /* __u8 ResourceName[] */ /* Name of share as counted Unicode string */
109 * Maximum number of iovs we need for an open/create request.
110 * [0] : struct smb2_create_req
112 * [2] : lease context
113 * [3] : durable context
114 * [4] : posix context
115 * [5] : time warp context
116 * [6] : query id context
117 * [7] : compound padding
119 #define SMB2_CREATE_IOV_SIZE 8
122 * Maximum size of a SMB2_CREATE response is 64 (smb2 header) +
123 * 88 (fixed part of create response) + 520 (path) + 208 (contexts) +
124 * 2 bytes of padding.
126 #define MAX_SMB2_CREATE_RESPONSE_SIZE 880
128 #define SMB2_LEASE_READ_CACHING_HE 0x01
129 #define SMB2_LEASE_HANDLE_CACHING_HE 0x02
130 #define SMB2_LEASE_WRITE_CACHING_HE 0x04
132 struct create_durable {
133 struct create_context ccontext;
138 __u64 PersistentFileId;
139 __u64 VolatileFileId;
144 /* See MS-SMB2 2.2.13.2.11 */
146 #define SMB2_DHANDLE_FLAG_PERSISTENT 0x00000002
147 struct durable_context_v2 {
154 struct create_durable_v2 {
155 struct create_context ccontext;
157 struct durable_context_v2 dcontext;
160 /* See MS-SMB2 2.2.13.2.12 */
161 struct durable_reconnect_context_v2 {
163 __u64 PersistentFileId;
164 __u64 VolatileFileId;
167 __le32 Flags; /* see above DHANDLE_FLAG_PERSISTENT */
170 /* See MS-SMB2 2.2.14.2.9 */
171 struct create_on_disk_id {
172 struct create_context ccontext;
179 /* See MS-SMB2 2.2.14.2.12 */
180 struct durable_reconnect_context_v2_rsp {
182 __le32 Flags; /* see above DHANDLE_FLAG_PERSISTENT */
185 struct create_durable_handle_reconnect_v2 {
186 struct create_context ccontext;
188 struct durable_reconnect_context_v2 dcontext;
192 /* See MS-SMB2 2.2.13.2.5 */
193 struct crt_twarp_ctxt {
194 struct create_context ccontext;
200 /* See MS-SMB2 2.2.13.2.9 */
201 struct crt_query_id_ctxt {
202 struct create_context ccontext;
207 struct create_context ccontext;
213 #define COPY_CHUNK_RES_KEY_SIZE 24
214 struct resume_key_req {
215 char ResumeKey[COPY_CHUNK_RES_KEY_SIZE];
216 __le32 ContextLength; /* MBZ */
217 char Context[]; /* ignored, Windows sets to 4 bytes of zero */
220 /* this goes in the ioctl buffer when doing a copychunk request */
221 struct copychunk_ioctl {
222 char SourceKey[COPY_CHUNK_RES_KEY_SIZE];
223 __le32 ChunkCount; /* we are only sending 1 */
225 /* array will only be one chunk long for us */
228 __le32 Length; /* how many bytes to copy */
232 struct copychunk_ioctl_rsp {
233 __le32 ChunksWritten;
234 __le32 ChunkBytesWritten;
235 __le32 TotalBytesWritten;
238 /* See MS-FSCC 2.3.29 and 2.3.30 */
239 struct get_retrieval_pointer_count_req {
240 __le64 StartingVcn; /* virtual cluster number (signed) */
243 struct get_retrieval_pointer_count_rsp {
248 * See MS-FSCC 2.3.33 and 2.3.34
249 * request is the same as get_retrieval_point_count_req struct above
251 struct smb3_extents {
253 __le64 Lcn; /* logical cluster number */
256 struct get_retrieval_pointers_refcount_rsp {
260 struct smb3_extents extents[];
263 struct fsctl_set_integrity_information_req {
264 __le16 ChecksumAlgorithm;
269 struct fsctl_get_integrity_information_rsp {
270 __le16 ChecksumAlgorithm;
273 __le32 ChecksumChunkSizeInBytes;
274 __le32 ClusterSizeInBytes;
277 /* Integrity ChecksumAlgorithm choices for above */
278 #define CHECKSUM_TYPE_NONE 0x0000
279 #define CHECKSUM_TYPE_CRC64 0x0002
280 #define CHECKSUM_TYPE_UNCHANGED 0xFFFF /* set only */
282 /* Integrity flags for above */
283 #define FSCTL_INTEGRITY_FLAG_CHECKSUM_ENFORCEMENT_OFF 0x00000001
285 /* See MS-DFSC 2.2.2 */
286 struct fsctl_get_dfs_referral_req {
287 __le16 MaxReferralLevel;
288 __u8 RequestFileName[];
291 /* DFS response is struct get_dfs_refer_rsp */
293 /* See MS-SMB2 2.2.31.3 */
294 struct network_resiliency_req {
298 /* There is no buffer for the response ie no struct network_resiliency_rsp */
300 #define RSS_CAPABLE cpu_to_le32(0x00000001)
301 #define RDMA_CAPABLE cpu_to_le32(0x00000002)
303 #define INTERNETWORK cpu_to_le16(0x0002)
304 #define INTERNETWORKV6 cpu_to_le16(0x0017)
306 struct network_interface_info_ioctl_rsp {
307 __le32 Next; /* next interface. zero if this is last one */
309 __le32 Capability; /* RSS or RDMA Capable */
316 struct iface_info_ipv4 {
322 struct iface_info_ipv6 {
325 __u8 IPv6Address[16];
329 #define NO_FILE_ID 0xFFFFFFFFFFFFFFFFULL /* general ioctls to srv not to file */
331 struct compress_ioctl {
332 __le16 CompressionState; /* See cifspdu.h for possible flag values */
336 * Maximum number of iovs we need for an ioctl request.
337 * [0] : struct smb2_ioctl_req
340 #define SMB2_IOCTL_IOV_SIZE 2
343 * PDU query infolevel structure definitions
344 * BB consider moving to a different header
347 struct smb2_file_full_ea_info { /* encoding of response for level 15 */
348 __le32 next_entry_offset;
351 __le16 ea_value_length;
352 char ea_data[]; /* \0 terminated name plus value */
353 } __packed; /* level 15 Set */
355 struct smb2_file_reparse_point_info {
360 struct smb2_file_network_open_info {
362 __le64 LastAccessTime;
363 __le64 LastWriteTime;
365 __le64 AllocationSize;
369 } __packed; /* level 34 Query also similar returned in close rsp and open rsp */
371 /* See MS-FSCC 2.4.21 */
372 struct smb2_file_id_information {
373 __le64 VolumeSerialNumber;
374 __u64 PersistentFileId; /* opaque endianness */
375 __u64 VolatileFileId; /* opaque endianness */
376 } __packed; /* level 59 */
378 /* See MS-FSCC 2.4.18 */
379 struct smb2_file_id_extd_directory_info {
380 __le32 NextEntryOffset;
383 __le64 LastAccessTime;
384 __le64 LastWriteTime;
387 __le64 AllocationSize;
388 __le32 FileAttributes;
389 __le32 FileNameLength;
390 __le32 EaSize; /* EA size */
391 __le32 ReparsePointTag; /* valid if FILE_ATTR_REPARSE_POINT set in FileAttributes */
392 __le64 UniqueId; /* inode num - le since Samba puts ino in low 32 bit */
394 } __packed; /* level 60 */
396 extern char smb2_padding[7];
398 /* equivalent of the contents of SMB3.1.1 POSIX open context response */
399 struct create_posix_rsp {
403 struct cifs_sid owner; /* var-sized on the wire */
404 struct cifs_sid group; /* var-sized on the wire */
407 #define SMB2_QUERY_DIRECTORY_IOV_SIZE 2
410 * SMB2-only POSIX info level for query dir
412 * See posix_info_sid_size(), posix_info_extra_size() and
413 * posix_info_parse() to help with the handling of this struct.
415 struct smb2_posix_info {
416 __le32 NextEntryOffset;
419 __le64 LastAccessTime;
420 __le64 LastWriteTime;
423 __le64 AllocationSize;
424 __le32 DosAttributes;
428 /* beginning of POSIX Create Context Response */
433 * var sized owner SID
434 * var sized group SID
435 * le32 filenamelength
441 * Parsed version of the above struct. Allows direct access to the
442 * variable length fields
444 struct smb2_posix_info_parsed {
445 const struct smb2_posix_info *base;
447 struct cifs_sid owner;
448 struct cifs_sid group;
453 #endif /* _SMB2PDU_H */