0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef _SMB2PDU_H
0012 #define _SMB2PDU_H
0013
0014 #include <net/sock.h>
0015 #include "cifsacl.h"
0016
0017
0018 #define SMB2_TRANSFORM_HEADER_SIZE 52
0019 #define MAX_SMB2_HDR_SIZE 204
0020
0021
0022 #define SMB2_READWRITE_PDU_HEADER_SIZE (48 + sizeof(struct smb2_hdr))
0023
0024
0025 struct smb2_rdma_transform {
0026 __le16 RdmaDescriptorOffset;
0027 __le16 RdmaDescriptorLength;
0028 __le32 Channel;
0029 __le16 TransformCount;
0030 __le16 Reserved1;
0031 __le32 Reserved2;
0032 } __packed;
0033
0034
0035 #define SMB2_RDMA_TRANSFORM_TYPE_ENCRYPTION 0x0001
0036 #define SMB2_RDMA_TRANSFORM_TYPE_SIGNING 0x0002
0037
0038 struct smb2_rdma_crypto_transform {
0039 __le16 TransformType;
0040 __le16 SignatureLength;
0041 __le16 NonceLength;
0042 __u16 Reserved;
0043 __u8 Signature[];
0044
0045
0046 } __packed;
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057 #define COMPOUND_FID 0xFFFFFFFFFFFFFFFFULL
0058
0059 #define SYMLINK_ERROR_TAG 0x4c4d5953
0060
0061 struct smb2_symlink_err_rsp {
0062 __le32 SymLinkLength;
0063 __le32 SymLinkErrorTag;
0064 __le32 ReparseTag;
0065 __le16 ReparseDataLength;
0066 __le16 UnparsedPathLength;
0067 __le16 SubstituteNameOffset;
0068 __le16 SubstituteNameLength;
0069 __le16 PrintNameOffset;
0070 __le16 PrintNameLength;
0071 __le32 Flags;
0072 __u8 PathBuffer[];
0073 } __packed;
0074
0075
0076 struct smb2_error_context_rsp {
0077 __le32 ErrorDataLength;
0078 __le32 ErrorId;
0079 __u8 ErrorContextData;
0080 } __packed;
0081
0082
0083 #define SMB2_ERROR_ID_DEFAULT 0x00000000
0084 #define SMB2_ERROR_ID_SHARE_REDIRECT cpu_to_le32(0x72645253)
0085
0086
0087 #define MOVE_DST_IPADDR_V4 cpu_to_le32(0x00000001)
0088 #define MOVE_DST_IPADDR_V6 cpu_to_le32(0x00000002)
0089
0090 struct move_dst_ipaddr {
0091 __le32 Type;
0092 __u32 Reserved;
0093 __u8 address[16];
0094 } __packed;
0095
0096 struct share_redirect_error_context_rsp {
0097 __le32 StructureSize;
0098 __le32 NotificationType;
0099 __le32 ResourceNameOffset;
0100 __le32 ResourceNameLength;
0101 __le16 Reserved;
0102 __le16 TargetType;
0103 __le32 IPAddrCount;
0104 struct move_dst_ipaddr IpAddrMoveList[];
0105
0106 } __packed;
0107
0108
0109
0110
0111
0112
0113
0114
0115
0116
0117
0118
0119 #define SMB2_CREATE_IOV_SIZE 8
0120
0121
0122
0123
0124
0125
0126 #define MAX_SMB2_CREATE_RESPONSE_SIZE 880
0127
0128 #define SMB2_LEASE_READ_CACHING_HE 0x01
0129 #define SMB2_LEASE_HANDLE_CACHING_HE 0x02
0130 #define SMB2_LEASE_WRITE_CACHING_HE 0x04
0131
0132 struct create_durable {
0133 struct create_context ccontext;
0134 __u8 Name[8];
0135 union {
0136 __u8 Reserved[16];
0137 struct {
0138 __u64 PersistentFileId;
0139 __u64 VolatileFileId;
0140 } Fid;
0141 } Data;
0142 } __packed;
0143
0144
0145
0146 #define SMB2_DHANDLE_FLAG_PERSISTENT 0x00000002
0147 struct durable_context_v2 {
0148 __le32 Timeout;
0149 __le32 Flags;
0150 __u64 Reserved;
0151 __u8 CreateGuid[16];
0152 } __packed;
0153
0154 struct create_durable_v2 {
0155 struct create_context ccontext;
0156 __u8 Name[8];
0157 struct durable_context_v2 dcontext;
0158 } __packed;
0159
0160
0161 struct durable_reconnect_context_v2 {
0162 struct {
0163 __u64 PersistentFileId;
0164 __u64 VolatileFileId;
0165 } Fid;
0166 __u8 CreateGuid[16];
0167 __le32 Flags;
0168 } __packed;
0169
0170
0171 struct create_on_disk_id {
0172 struct create_context ccontext;
0173 __u8 Name[8];
0174 __le64 DiskFileId;
0175 __le64 VolumeId;
0176 __u32 Reserved[4];
0177 } __packed;
0178
0179
0180 struct durable_reconnect_context_v2_rsp {
0181 __le32 Timeout;
0182 __le32 Flags;
0183 } __packed;
0184
0185 struct create_durable_handle_reconnect_v2 {
0186 struct create_context ccontext;
0187 __u8 Name[8];
0188 struct durable_reconnect_context_v2 dcontext;
0189 __u8 Pad[4];
0190 } __packed;
0191
0192
0193 struct crt_twarp_ctxt {
0194 struct create_context ccontext;
0195 __u8 Name[8];
0196 __le64 Timestamp;
0197
0198 } __packed;
0199
0200
0201 struct crt_query_id_ctxt {
0202 struct create_context ccontext;
0203 __u8 Name[8];
0204 } __packed;
0205
0206 struct crt_sd_ctxt {
0207 struct create_context ccontext;
0208 __u8 Name[8];
0209 struct smb3_sd sd;
0210 } __packed;
0211
0212
0213 #define COPY_CHUNK_RES_KEY_SIZE 24
0214 struct resume_key_req {
0215 char ResumeKey[COPY_CHUNK_RES_KEY_SIZE];
0216 __le32 ContextLength;
0217 char Context[];
0218 } __packed;
0219
0220
0221 struct copychunk_ioctl {
0222 char SourceKey[COPY_CHUNK_RES_KEY_SIZE];
0223 __le32 ChunkCount;
0224 __le32 Reserved;
0225
0226 __le64 SourceOffset;
0227 __le64 TargetOffset;
0228 __le32 Length;
0229 __u32 Reserved2;
0230 } __packed;
0231
0232 struct copychunk_ioctl_rsp {
0233 __le32 ChunksWritten;
0234 __le32 ChunkBytesWritten;
0235 __le32 TotalBytesWritten;
0236 } __packed;
0237
0238
0239 struct get_retrieval_pointer_count_req {
0240 __le64 StartingVcn;
0241 } __packed;
0242
0243 struct get_retrieval_pointer_count_rsp {
0244 __le32 ExtentCount;
0245 } __packed;
0246
0247
0248
0249
0250
0251 struct smb3_extents {
0252 __le64 NextVcn;
0253 __le64 Lcn;
0254 } __packed;
0255
0256 struct get_retrieval_pointers_refcount_rsp {
0257 __le32 ExtentCount;
0258 __u32 Reserved;
0259 __le64 StartingVcn;
0260 struct smb3_extents extents[];
0261 } __packed;
0262
0263
0264 struct fsctl_get_dfs_referral_req {
0265 __le16 MaxReferralLevel;
0266 __u8 RequestFileName[];
0267 } __packed;
0268
0269
0270
0271
0272 struct network_resiliency_req {
0273 __le32 Timeout;
0274 __le32 Reserved;
0275 } __packed;
0276
0277
0278 #define RSS_CAPABLE cpu_to_le32(0x00000001)
0279 #define RDMA_CAPABLE cpu_to_le32(0x00000002)
0280
0281 #define INTERNETWORK cpu_to_le16(0x0002)
0282 #define INTERNETWORKV6 cpu_to_le16(0x0017)
0283
0284 struct network_interface_info_ioctl_rsp {
0285 __le32 Next;
0286 __le32 IfIndex;
0287 __le32 Capability;
0288 __le32 Reserved;
0289 __le64 LinkSpeed;
0290 __le16 Family;
0291 __u8 Buffer[126];
0292 } __packed;
0293
0294 struct iface_info_ipv4 {
0295 __be16 Port;
0296 __be32 IPv4Address;
0297 __be64 Reserved;
0298 } __packed;
0299
0300 struct iface_info_ipv6 {
0301 __be16 Port;
0302 __be32 FlowInfo;
0303 __u8 IPv6Address[16];
0304 __be32 ScopeId;
0305 } __packed;
0306
0307 #define NO_FILE_ID 0xFFFFFFFFFFFFFFFFULL
0308
0309 struct compress_ioctl {
0310 __le16 CompressionState;
0311 } __packed;
0312
0313
0314
0315
0316
0317
0318 #define SMB2_IOCTL_IOV_SIZE 2
0319
0320
0321
0322
0323
0324
0325 struct smb2_file_full_ea_info {
0326 __le32 next_entry_offset;
0327 __u8 flags;
0328 __u8 ea_name_length;
0329 __le16 ea_value_length;
0330 char ea_data[];
0331 } __packed;
0332
0333 struct smb2_file_reparse_point_info {
0334 __le64 IndexNumber;
0335 __le32 Tag;
0336 } __packed;
0337
0338 struct smb2_file_network_open_info {
0339 __le64 CreationTime;
0340 __le64 LastAccessTime;
0341 __le64 LastWriteTime;
0342 __le64 ChangeTime;
0343 __le64 AllocationSize;
0344 __le64 EndOfFile;
0345 __le32 Attributes;
0346 __le32 Reserved;
0347 } __packed;
0348
0349
0350 struct smb2_file_id_information {
0351 __le64 VolumeSerialNumber;
0352 __u64 PersistentFileId;
0353 __u64 VolatileFileId;
0354 } __packed;
0355
0356
0357 struct smb2_file_id_extd_directory_info {
0358 __le32 NextEntryOffset;
0359 __u32 FileIndex;
0360 __le64 CreationTime;
0361 __le64 LastAccessTime;
0362 __le64 LastWriteTime;
0363 __le64 ChangeTime;
0364 __le64 EndOfFile;
0365 __le64 AllocationSize;
0366 __le32 FileAttributes;
0367 __le32 FileNameLength;
0368 __le32 EaSize;
0369 __le32 ReparsePointTag;
0370 __le64 UniqueId;
0371 char FileName[1];
0372 } __packed;
0373
0374 extern char smb2_padding[7];
0375
0376
0377 struct create_posix_rsp {
0378 u32 nlink;
0379 u32 reparse_tag;
0380 u32 mode;
0381 struct cifs_sid owner;
0382 struct cifs_sid group;
0383 } __packed;
0384
0385 #define SMB2_QUERY_DIRECTORY_IOV_SIZE 2
0386
0387
0388
0389
0390
0391
0392
0393 struct smb2_posix_info {
0394 __le32 NextEntryOffset;
0395 __u32 Ignored;
0396 __le64 CreationTime;
0397 __le64 LastAccessTime;
0398 __le64 LastWriteTime;
0399 __le64 ChangeTime;
0400 __le64 EndOfFile;
0401 __le64 AllocationSize;
0402 __le32 DosAttributes;
0403 __le64 Inode;
0404 __le32 DeviceId;
0405 __le32 Zero;
0406
0407 __le32 HardLinks;
0408 __le32 ReparseTag;
0409 __le32 Mode;
0410
0411
0412
0413
0414
0415
0416 } __packed;
0417
0418
0419
0420
0421
0422 struct smb2_posix_info_parsed {
0423 const struct smb2_posix_info *base;
0424 size_t size;
0425 struct cifs_sid owner;
0426 struct cifs_sid group;
0427 int name_len;
0428 const u8 *name;
0429 };
0430
0431 #endif