#ifndef _NETSMB_SMB2_H
#define _NETSMB_SMB2_H
#ifdef __cplusplus
extern "C" {
#endif
#define SMB2_PROTOCOL_ID { 0xFE, 'S', 'M', 'B' }
#define SMB2_HDR_SIZE 64
#define SMB2_HDRLEN SMB2_HDR_SIZE
typedef enum {
SMB2_NEGOTIATE = 0,
SMB2_SESSION_SETUP,
SMB2_LOGOFF,
SMB2_TREE_CONNECT,
SMB2_TREE_DISCONNECT,
SMB2_CREATE,
SMB2_CLOSE,
SMB2_FLUSH,
SMB2_READ,
SMB2_WRITE,
SMB2_LOCK,
SMB2_IOCTL,
SMB2_CANCEL,
SMB2_ECHO,
SMB2_QUERY_DIRECTORY,
SMB2_CHANGE_NOTIFY,
SMB2_QUERY_INFO,
SMB2_SET_INFO,
SMB2_OPLOCK_BREAK,
SMB2_INVALID_CMD,
SMB2__NCMDS
} SMB2_cmd_code;
#define SMB2_FLAGS_SERVER_TO_REDIR 0x00000001
#define SMB2_FLAGS_ASYNC_COMMAND 0x00000002
#define SMB2_FLAGS_RELATED_OPERATIONS 0x00000004
#define SMB2_FLAGS_SIGNED 0x00000008
#define SMB2_SESSION_KEY_LEN 16
#define SMB2_FLAGS_DFS_OPERATIONS 0x10000000
#define SMB2_FLAGS_REPLAY_OPERATION 0x20000000
#define SMB2_NEGOTIATE_SIGNING_ENABLED 0x01
#define SMB2_NEGOTIATE_SIGNING_REQUIRED 0x02
#define SMB2_CAP_DFS 0x00000001
#define SMB2_CAP_DFS 0x00000001
#define SMB2_CAP_LEASING 0x00000002
#define SMB2_CAP_LARGE_MTU 0x00000004
#define SMB2_CAP_MULTI_CHANNEL 0x00000008
#define SMB2_CAP_PERSISTENT_HANDLES 0x00000010
#define SMB2_CAP_DIRECTORY_LEASING 0x00000020
#define SMB2_CAP_ENCRYPTION 0x00000040
#define SMB2_SESSION_FLAG_IS_GUEST 0x0001
#define SMB2_SESSION_FLAG_IS_NULL 0x0002
#define SMB2_SESSION_FLAG_ENCRYPT_DATA 0x0004
#define SMB2_SHARE_TYPE_DISK 0x1
#define SMB2_SHARE_TYPE_PIPE 0x2
#define SMB2_SHARE_TYPE_PRINT 0x3
#define SMB2_SHAREFLAG_MANUAL_CACHING 0x00000000
#define SMB2_SHAREFLAG_AUTO_CACHING 0x00000010
#define SMB2_SHAREFLAG_VDO_CACHING 0x00000020
#define SMB2_SHAREFLAG_NO_CACHING 0x00000030
#define SMB2_SHAREFLAG_DFS 0x00000001
#define SMB2_SHAREFLAG_DFS_ROOT 0x00000002
#define SMB2_SHAREFLAG_RESTRICT_EXCLUSIVE_OPENS 0x00000100
#define SMB2_SHAREFLAG_FORCE_SHARED_DELETE 0x00000200
#define SMB2_SHAREFLAG_ALLOW_NAMESPACE_CACHING 0x00000400
#define SMB2_SHAREFLAG_ACCESS_BASED_DIRECTORY_ENUM 0x00000800
#define SMB2_SHAREFLAG_FORCE_LEVELII_OPLOCK 0x00001000
#define SMB2_SHAREFLAG_ENABLE_HASH_V1 0x00002000
#define SMB2_SHAREFLAG_ENABLE_HASH_V2 0x00004000
#define SMB2_SHAREFLAG_ENCRYPT_DATA 0x00008000
#define SMB2_SHARE_CAP_DFS 0x00000008
#define SMB2_SHARE_CAP_CONTINUOUS_AVAILABILITY 0x00000010
#define SMB2_SHARE_CAP_SCALEOUT 0x00000020
#define SMB2_SHARE_CAP_CLUSTER 0x00000040
#define SMB2_OPLOCK_LEVEL_NONE 0x00
#define SMB2_OPLOCK_LEVEL_II 0x01
#define SMB2_OPLOCK_LEVEL_EXCLUSIVE 0x08
#define SMB2_OPLOCK_LEVEL_BATCH 0x09
#define SMB2_OPLOCK_LEVEL_LEASE 0xFF
#define SMB2_IMPERSONATION_ANONYMOUS 0x00
#define SMB2_IMPERSONATION_IDENTIFICATION 0x01
#define SMB2_IMPERSONATION_IMPERSONATION 0x02
#define SMB2_IMPERSONATION_DELEGATE 0x03
#define SMB2_CREATE_EA_BUFFER 0x45787441
#define SMB2_CREATE_SD_BUFFER 0x53656344
#define SMB2_CREATE_DURABLE_HANDLE_REQUEST 0x44486e51
#define SMB2_CREATE_DURABLE_HANDLE_RECONNECT 0x44486e43
#define SMB2_CREATE_ALLOCATION_SIZE 0x416c5369
#define SMB2_CREATE_QUERY_MAXIMAL_ACCESS 0x4d784163
#define SMB2_CREATE_TIMEWARP_TOKEN 0x54577270
#define SMB2_CREATE_QUERY_ON_DISK_ID 0x51466964
#define SMB2_CREATE_REQUEST_LEASE 0x52714c73
#define SMB2_LEASE_NONE 0x00
#define SMB2_LEASE_READ_CACHING 0x01
#define SMB2_LEASE_HANDLE_CACHING 0x02
#define SMB2_LEASE_WRITE_CACHING 0x04
#define SMB2_NOTIFY_BREAK_LEASE_FLAG_ACK_REQUIRED 0x01
#define SMB2_CLOSE_FLAG_POSTQUERY_ATTRIB 0x0001
#define SMB2_WRITEFLAG_WRITE_THROUGH 0x00000001
#define SMB2_LOCKFLAG_SHARED_LOCK 0x00000001
#define SMB2_LOCKFLAG_EXCLUSIVE_LOCK 0x00000002
#define SMB2_LOCKFLAG_UNLOCK 0x00000004
#define SMB2_LOCKFLAG_FAIL_IMMEDIATELY 0x00000010
#define SMB2_IOCTL_IS_FSCTL 0x00000001
#define SMB2_QDIR_FLAG_RESTART 0x01
#define SMB2_QDIR_FLAG_SINGLE 0x02
#define SMB2_QDIR_FLAG_INDEX 0x04
#define SMB2_QDIR_FLAG_REOPEN 0x10
#define SMB2_0_INFO_FILE 0x01
#define SMB2_0_INFO_FILESYSTEM 0x02
#define SMB2_0_INFO_SECURITY 0x03
#define SMB2_0_INFO_QUOTA 0x04
typedef enum _FS_INFORMATION_CLASS
{
FileFsVolumeInformation = 1,
FileFsLabelInformation = 2,
FileFsSizeInformation = 3,
FileFsDeviceInformation = 4,
FileFsAttributeInformation = 5,
FileFsControlInformation = 6,
FileFsFullSizeInformation = 7,
FileFsObjectIdInformation = 8,
FileFsDriverPathInformation = 9
} FS_INFORMATION_CLASS;
typedef enum _FILE_INFORMATION_CLASS
{
FileDirectoryInformation = 1,
FileFullDirectoryInformation = 2,
FileBothDirectoryInformation = 3,
FileBasicInformation = 4,
FileStandardInformation = 5,
FileInternalInformation = 6,
FileEaInformation = 7,
FileAccessInformation = 8,
FileNameInformation = 9,
FileRenameInformation = 10,
FileLinkInformation = 11,
FileNamesInformation = 12,
FileDispositionInformation = 13,
FilePositionInformation = 14,
FileFullEaInformation = 15,
FileModeInformation = 16,
FileAlignmentInformation = 17,
FileAllInformation = 18,
FileAllocationInformation = 19,
FileEndOfFileInformation = 20,
FileAlternateNameInformation = 21,
FileStreamInformation = 22,
FilePipeInformation = 23,
FilePipeLocalInformation = 24,
FilePipeRemoteInformation = 25,
FileMailslotQueryInformation = 26,
FileMailslotSetInformation = 27,
FileCompressionInformation = 28,
FileObjectIdInformation = 29,
FileMoveClusterInformation = 31,
FileQuotaInformation = 32,
FileReparsePointInformation = 33,
FileNetworkOpenInformation = 34,
FileAttributeTagInformation = 35,
FileTrackingInformation = 36,
FileIdBothDirectoryInformation = 37,
FileIdFullDirectoryInformation = 38,
FileValidDataLengthInformation = 39,
FileShortNameInformation = 40,
FileSfioReserveInformation = 44,
FileSfioVolumeInformation = 45,
FileHardLinkInformation = 46,
FileNormalizedNameInformation = 48,
FileIdGlobalTxDirectoryInformation = 50,
FileStandardLinkInformation = 54
} FILE_INFORMATION_CLASS;
#define SMB2_WATCH_TREE 0x00000001
#define SMB2_TID_UNKNOWN 0
#define SMB2_FID_UNUSED 0xffffffffffffffff
typedef enum _SMB2_DURABLE_HANDLE_FLAGS
{
SMB2_DURABLE_HANDLE_REQUEST = 0x0001,
SMB2_DURABLE_HANDLE_RECONNECT = 0x0002,
SMB2_DURABLE_HANDLE_GRANTED = 0x0004,
SMB2_LEASE_GRANTED = 0x0008
} _SMB2_DURABLE_HANDLE_FLAGS;
struct smb2_durable_handle {
uint64_t fid;
uint64_t flags;
uint64_t lease_key_hi;
uint64_t lease_key_low;
uint32_t lease_state;
uint32_t pad;
};
#ifdef __cplusplus
}
#endif
#endif