1 /* SPDX-License-Identifier: LGPL-2.1 */
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
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 SMB2_SYMLINK_STRUCT_SIZE \
60 (sizeof(struct smb2_err_rsp) + sizeof(struct smb2_symlink_err_rsp))
62 #define SYMLINK_ERROR_TAG 0x4c4d5953
64 struct smb2_symlink_err_rsp {
66 __le32 SymLinkErrorTag;
68 __le16 ReparseDataLength;
69 __le16 UnparsedPathLength;
70 __le16 SubstituteNameOffset;
71 __le16 SubstituteNameLength;
72 __le16 PrintNameOffset;
73 __le16 PrintNameLength;
78 /* SMB 3.1.1 and later dialects. See MS-SMB2 section 2.2.2.1 */
79 struct smb2_error_context_rsp {
80 __le32 ErrorDataLength;
82 __u8 ErrorContextData; /* ErrorDataLength long array */
86 #define SMB2_ERROR_ID_DEFAULT 0x00000000
87 #define SMB2_ERROR_ID_SHARE_REDIRECT cpu_to_le32(0x72645253) /* "rdRS" */
89 /* Defines for Type field below (see MS-SMB2 2.2.2.2.2.1) */
90 #define MOVE_DST_IPADDR_V4 cpu_to_le32(0x00000001)
91 #define MOVE_DST_IPADDR_V6 cpu_to_le32(0x00000002)
93 struct move_dst_ipaddr {
96 __u8 address[16]; /* IPv4 followed by 12 bytes rsvd or IPv6 address */
99 struct share_redirect_error_context_rsp {
100 __le32 StructureSize;
101 __le32 NotificationType;
102 __le32 ResourceNameOffset;
103 __le32 ResourceNameLength;
107 struct move_dst_ipaddr IpAddrMoveList[];
108 /* __u8 ResourceName[] */ /* Name of share as counted Unicode string */
112 * Maximum number of iovs we need for an open/create request.
113 * [0] : struct smb2_create_req
115 * [2] : lease context
116 * [3] : durable context
117 * [4] : posix context
118 * [5] : time warp context
119 * [6] : query id context
120 * [7] : compound padding
122 #define SMB2_CREATE_IOV_SIZE 8
125 * Maximum size of a SMB2_CREATE response is 64 (smb2 header) +
126 * 88 (fixed part of create response) + 520 (path) + 208 (contexts) +
127 * 2 bytes of padding.
129 #define MAX_SMB2_CREATE_RESPONSE_SIZE 880
131 #define SMB2_LEASE_READ_CACHING_HE 0x01
132 #define SMB2_LEASE_HANDLE_CACHING_HE 0x02
133 #define SMB2_LEASE_WRITE_CACHING_HE 0x04
135 struct create_durable {
136 struct create_context ccontext;
141 __u64 PersistentFileId;
142 __u64 VolatileFileId;
147 /* See MS-SMB2 2.2.13.2.11 */
149 #define SMB2_DHANDLE_FLAG_PERSISTENT 0x00000002
150 struct durable_context_v2 {
157 struct create_durable_v2 {
158 struct create_context ccontext;
160 struct durable_context_v2 dcontext;
163 /* See MS-SMB2 2.2.13.2.12 */
164 struct durable_reconnect_context_v2 {
166 __u64 PersistentFileId;
167 __u64 VolatileFileId;
170 __le32 Flags; /* see above DHANDLE_FLAG_PERSISTENT */
173 /* See MS-SMB2 2.2.14.2.9 */
174 struct create_on_disk_id {
175 struct create_context ccontext;
182 /* See MS-SMB2 2.2.14.2.12 */
183 struct durable_reconnect_context_v2_rsp {
185 __le32 Flags; /* see above DHANDLE_FLAG_PERSISTENT */
188 struct create_durable_handle_reconnect_v2 {
189 struct create_context ccontext;
191 struct durable_reconnect_context_v2 dcontext;
195 /* See MS-SMB2 2.2.13.2.5 */
196 struct crt_twarp_ctxt {
197 struct create_context ccontext;
203 /* See MS-SMB2 2.2.13.2.9 */
204 struct crt_query_id_ctxt {
205 struct create_context ccontext;
210 struct create_context ccontext;
216 #define COPY_CHUNK_RES_KEY_SIZE 24
217 struct resume_key_req {
218 char ResumeKey[COPY_CHUNK_RES_KEY_SIZE];
219 __le32 ContextLength; /* MBZ */
220 char Context[]; /* ignored, Windows sets to 4 bytes of zero */
223 /* this goes in the ioctl buffer when doing a copychunk request */
224 struct copychunk_ioctl {
225 char SourceKey[COPY_CHUNK_RES_KEY_SIZE];
226 __le32 ChunkCount; /* we are only sending 1 */
228 /* array will only be one chunk long for us */
231 __le32 Length; /* how many bytes to copy */
235 struct copychunk_ioctl_rsp {
236 __le32 ChunksWritten;
237 __le32 ChunkBytesWritten;
238 __le32 TotalBytesWritten;
241 /* See MS-FSCC 2.3.29 and 2.3.30 */
242 struct get_retrieval_pointer_count_req {
243 __le64 StartingVcn; /* virtual cluster number (signed) */
246 struct get_retrieval_pointer_count_rsp {
251 * See MS-FSCC 2.3.33 and 2.3.34
252 * request is the same as get_retrieval_point_count_req struct above
254 struct smb3_extents {
256 __le64 Lcn; /* logical cluster number */
259 struct get_retrieval_pointers_refcount_rsp {
263 struct smb3_extents extents[];
266 /* See MS-DFSC 2.2.2 */
267 struct fsctl_get_dfs_referral_req {
268 __le16 MaxReferralLevel;
269 __u8 RequestFileName[];
272 /* DFS response is struct get_dfs_refer_rsp */
274 /* See MS-SMB2 2.2.31.3 */
275 struct network_resiliency_req {
279 /* There is no buffer for the response ie no struct network_resiliency_rsp */
281 #define RSS_CAPABLE cpu_to_le32(0x00000001)
282 #define RDMA_CAPABLE cpu_to_le32(0x00000002)
284 #define INTERNETWORK cpu_to_le16(0x0002)
285 #define INTERNETWORKV6 cpu_to_le16(0x0017)
287 struct network_interface_info_ioctl_rsp {
288 __le32 Next; /* next interface. zero if this is last one */
290 __le32 Capability; /* RSS or RDMA Capable */
297 struct iface_info_ipv4 {
303 struct iface_info_ipv6 {
306 __u8 IPv6Address[16];
310 #define NO_FILE_ID 0xFFFFFFFFFFFFFFFFULL /* general ioctls to srv not to file */
312 struct compress_ioctl {
313 __le16 CompressionState; /* See cifspdu.h for possible flag values */
317 * Maximum number of iovs we need for an ioctl request.
318 * [0] : struct smb2_ioctl_req
321 #define SMB2_IOCTL_IOV_SIZE 2
324 * PDU query infolevel structure definitions
325 * BB consider moving to a different header
328 struct smb2_file_full_ea_info { /* encoding of response for level 15 */
329 __le32 next_entry_offset;
332 __le16 ea_value_length;
333 char ea_data[]; /* \0 terminated name plus value */
334 } __packed; /* level 15 Set */
336 struct smb2_file_reparse_point_info {
341 struct smb2_file_network_open_info {
342 struct_group(network_open_info,
344 __le64 LastAccessTime;
345 __le64 LastWriteTime;
347 __le64 AllocationSize;
352 } __packed; /* level 34 Query also similar returned in close rsp and open rsp */
354 /* See MS-FSCC 2.4.21 */
355 struct smb2_file_id_information {
356 __le64 VolumeSerialNumber;
357 __u64 PersistentFileId; /* opaque endianness */
358 __u64 VolatileFileId; /* opaque endianness */
359 } __packed; /* level 59 */
361 /* See MS-FSCC 2.4.18 */
362 struct smb2_file_id_extd_directory_info {
363 __le32 NextEntryOffset;
366 __le64 LastAccessTime;
367 __le64 LastWriteTime;
370 __le64 AllocationSize;
371 __le32 FileAttributes;
372 __le32 FileNameLength;
373 __le32 EaSize; /* EA size */
374 __le32 ReparsePointTag; /* valid if FILE_ATTR_REPARSE_POINT set in FileAttributes */
375 __le64 UniqueId; /* inode num - le since Samba puts ino in low 32 bit */
377 } __packed; /* level 60 */
379 extern char smb2_padding[7];
381 /* equivalent of the contents of SMB3.1.1 POSIX open context response */
382 struct create_posix_rsp {
386 struct cifs_sid owner; /* var-sized on the wire */
387 struct cifs_sid group; /* var-sized on the wire */
390 #define SMB2_QUERY_DIRECTORY_IOV_SIZE 2
393 * SMB2-only POSIX info level for query dir
395 * See posix_info_sid_size(), posix_info_extra_size() and
396 * posix_info_parse() to help with the handling of this struct.
398 struct smb2_posix_info {
399 __le32 NextEntryOffset;
402 __le64 LastAccessTime;
403 __le64 LastWriteTime;
406 __le64 AllocationSize;
407 __le32 DosAttributes;
411 /* beginning of POSIX Create Context Response */
416 * var sized owner SID
417 * var sized group SID
418 * le32 filenamelength
424 * Parsed version of the above struct. Allows direct access to the
425 * variable length fields
427 struct smb2_posix_info_parsed {
428 const struct smb2_posix_info *base;
430 struct cifs_sid owner;
431 struct cifs_sid group;
436 #endif /* _SMB2PDU_H */