123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322
#ifndef _SMB2PDU_H
#define _SMB2PDU_H
#include <net/sock.h>
#include "cifsacl.h"
#define SMB2_TRANSFORM_HEADER_SIZE 52
#define MAX_SMB2_HDR_SIZE 204
#define SMB2_READWRITE_PDU_HEADER_SIZE (48 + sizeof(struct smb2_hdr))
#define COMPOUND_FID 0xFFFFFFFFFFFFFFFFULL
#define SMB2_SYMLINK_STRUCT_SIZE \
(sizeof(struct smb2_err_rsp) + sizeof(struct smb2_symlink_err_rsp))
#define SYMLINK_ERROR_TAG 0x4c4d5953
struct smb2_symlink_err_rsp {
__le32 SymLinkLength;
__le32 SymLinkErrorTag;
__le32 ReparseTag;
__le16 ReparseDataLength;
__le16 UnparsedPathLength;
__le16 SubstituteNameOffset;
__le16 SubstituteNameLength;
__le16 PrintNameOffset;
__le16 PrintNameLength;
__le32 Flags;
__u8 PathBuffer[];
} __packed;
struct smb2_error_context_rsp {
__le32 ErrorDataLength;
__le32 ErrorId;
__u8 ErrorContextData[] __counted_by_le(ErrorDataLength);
} __packed;
#define SMB2_ERROR_ID_DEFAULT 0x00000000
#define SMB2_ERROR_ID_SHARE_REDIRECT cpu_to_le32(0x72645253) /* "rdRS" */
#define MOVE_DST_IPADDR_V4 cpu_to_le32(0x00000001)
#define MOVE_DST_IPADDR_V6 cpu_to_le32(0x00000002)
struct move_dst_ipaddr {
__le32 Type;
__u32 Reserved;
__u8 address[16];
} __packed;
struct share_redirect_error_context_rsp {
__le32 StructureSize;
__le32 NotificationType;
__le32 ResourceNameOffset;
__le32 ResourceNameLength;
__le16 Reserved;
__le16 TargetType;
__le32 IPAddrCount;
struct move_dst_ipaddr IpAddrMoveList[];
} __packed;
#define SMB2_CREATE_IOV_SIZE 9
#define MAX_SMB2_CREATE_RESPONSE_SIZE 880
#define SMB2_LEASE_READ_CACHING_HE 0x01
#define SMB2_LEASE_HANDLE_CACHING_HE 0x02
#define SMB2_LEASE_WRITE_CACHING_HE 0x04
struct crt_twarp_ctxt {
struct create_context_hdr ccontext;
__u8 Name[8];
__le64 Timestamp;
} __packed;
struct crt_query_id_ctxt {
struct create_context_hdr ccontext;
__u8 Name[8];
} __packed;
struct crt_sd_ctxt {
struct create_context_hdr ccontext;
__u8 Name[8];
struct smb3_sd sd;
} __packed;
struct get_retrieval_pointer_count_req {
__le64 StartingVcn;
} __packed;
struct get_retrieval_pointer_count_rsp {
__le32 ExtentCount;
} __packed;
struct smb3_extents {
__le64 NextVcn;
__le64 Lcn;
} __packed;
struct get_retrieval_pointers_refcount_rsp {
__le32 ExtentCount;
__u32 Reserved;
__le64 StartingVcn;
struct smb3_extents extents[];
} __packed;
struct fsctl_get_dfs_referral_req {
__le16 MaxReferralLevel;
__u8 RequestFileName[];
} __packed;
struct network_resiliency_req {
__le32 Timeout;
__le32 Reserved;
} __packed;
#define NO_FILE_ID 0xFFFFFFFFFFFFFFFFULL /* general ioctls to srv not to file */
#define SMB2_IOCTL_IOV_SIZE 2
#define SMB2_QUERY_INFO_IOV_SIZE 2
struct smb2_file_full_ea_info {
__le32 next_entry_offset;
__u8 flags;
__u8 ea_name_length;
__le16 ea_value_length;
char ea_data[];
} __packed;
struct smb2_file_reparse_point_info {
__le64 IndexNumber;
__le32 Tag;
} __packed;
struct smb2_file_id_information {
__le64 VolumeSerialNumber;
__u64 PersistentFileId;
__u64 VolatileFileId;
} __packed;
struct smb2_file_id_extd_directory_info {
__le32 NextEntryOffset;
__u32 FileIndex;
__le64 CreationTime;
__le64 LastAccessTime;
__le64 LastWriteTime;
__le64 ChangeTime;
__le64 EndOfFile;
__le64 AllocationSize;
__le32 FileAttributes;
__le32 FileNameLength;
__le32 EaSize;
__le32 ReparsePointTag;
__le64 UniqueId;
char FileName[];
} __packed;
extern char smb2_padding[7];
struct create_posix_rsp {
u32 nlink;
u32 reparse_tag;
u32 mode;
struct smb_sid owner;
struct smb_sid group;
} __packed;
#define SMB2_QUERY_DIRECTORY_IOV_SIZE 2
struct smb2_posix_info {
__le32 NextEntryOffset;
__u32 Ignored;
__le64 CreationTime;
__le64 LastAccessTime;
__le64 LastWriteTime;
__le64 ChangeTime;
__le64 EndOfFile;
__le64 AllocationSize;
__le32 DosAttributes;
__le64 Inode;
__le32 DeviceId;
__le32 Zero;
__le32 HardLinks;
__le32 ReparseTag;
__le32 Mode;
} __packed;
struct smb2_posix_info_parsed {
const struct smb2_posix_info *base;
size_t size;
struct smb_sid owner;
struct smb_sid group;
int name_len;
const u8 *name;
};
struct smb2_create_ea_ctx {
struct create_context_hdr ctx;
__u8 name[8];
struct smb2_file_full_ea_info ea;
} __packed;
#define SMB2_WSL_XATTR_UID "$LXUID"
#define SMB2_WSL_XATTR_GID "$LXGID"
#define SMB2_WSL_XATTR_MODE "$LXMOD"
#define SMB2_WSL_XATTR_DEV "$LXDEV"
#define SMB2_WSL_XATTR_NAME_LEN 6
#define SMB2_WSL_NUM_XATTRS 4
#define SMB2_WSL_XATTR_UID_SIZE 4
#define SMB2_WSL_XATTR_GID_SIZE 4
#define SMB2_WSL_XATTR_MODE_SIZE 4
#define SMB2_WSL_XATTR_DEV_SIZE 8
#define SMB2_WSL_MIN_QUERY_EA_RESP_SIZE \
(ALIGN((SMB2_WSL_NUM_XATTRS - 1) * \
(SMB2_WSL_XATTR_NAME_LEN + 1 + \
sizeof(struct smb2_file_full_ea_info)), 4) + \
SMB2_WSL_XATTR_NAME_LEN + 1 + sizeof(struct smb2_file_full_ea_info))
#define SMB2_WSL_MAX_QUERY_EA_RESP_SIZE \
(ALIGN(SMB2_WSL_MIN_QUERY_EA_RESP_SIZE + \
SMB2_WSL_XATTR_UID_SIZE + \
SMB2_WSL_XATTR_GID_SIZE + \
SMB2_WSL_XATTR_MODE_SIZE + \
SMB2_WSL_XATTR_DEV_SIZE, 4))
#endif /* _SMB2PDU_H */