linux/fs/smb/client/cifspdu.h

/* SPDX-License-Identifier: LGPL-2.1 */
/*
 *
 *   Copyright (c) International Business Machines  Corp., 2002,2009
 *   Author(s): Steve French ([email protected])
 *
 */

#ifndef _CIFSPDU_H
#define _CIFSPDU_H

#include <net/sock.h>
#include <asm/unaligned.h>
#include "../common/smbfsctl.h"

#define CIFS_PROT
#define POSIX_PROT
#define BAD_PROT

/* SMB command codes:
 * Note some commands have minimal (wct=0,bcc=0), or uninteresting, responses
 * (ie which include no useful data other than the SMB error code itself).
 * This can allow us to avoid response buffer allocations and copy in some cases
 */
#define SMB_COM_CREATE_DIRECTORY
#define SMB_COM_DELETE_DIRECTORY
#define SMB_COM_CLOSE
#define SMB_COM_FLUSH
#define SMB_COM_DELETE
#define SMB_COM_RENAME
#define SMB_COM_QUERY_INFORMATION
#define SMB_COM_SETATTR
#define SMB_COM_LOCKING_ANDX
#define SMB_COM_COPY
#define SMB_COM_ECHO
#define SMB_COM_OPEN_ANDX
#define SMB_COM_READ_ANDX
#define SMB_COM_WRITE_ANDX
#define SMB_COM_TRANSACTION2
#define SMB_COM_TRANSACTION2_SECONDARY
#define SMB_COM_FIND_CLOSE2
#define SMB_COM_TREE_DISCONNECT
#define SMB_COM_NEGOTIATE
#define SMB_COM_SESSION_SETUP_ANDX
#define SMB_COM_LOGOFF_ANDX
#define SMB_COM_TREE_CONNECT_ANDX
#define SMB_COM_NT_TRANSACT
#define SMB_COM_NT_TRANSACT_SECONDARY
#define SMB_COM_NT_CREATE_ANDX
#define SMB_COM_NT_CANCEL
#define SMB_COM_NT_RENAME

/* Transact2 subcommand codes */
#define TRANS2_OPEN
#define TRANS2_FIND_FIRST
#define TRANS2_FIND_NEXT
#define TRANS2_QUERY_FS_INFORMATION
#define TRANS2_SET_FS_INFORMATION
#define TRANS2_QUERY_PATH_INFORMATION
#define TRANS2_SET_PATH_INFORMATION
#define TRANS2_QUERY_FILE_INFORMATION
#define TRANS2_SET_FILE_INFORMATION
#define TRANS2_GET_DFS_REFERRAL
#define TRANS2_REPORT_DFS_INCOSISTENCY

/* SMB Transact (Named Pipe) subcommand codes */
#define TRANS_SET_NMPIPE_STATE
#define TRANS_RAW_READ_NMPIPE
#define TRANS_QUERY_NMPIPE_STATE
#define TRANS_QUERY_NMPIPE_INFO
#define TRANS_PEEK_NMPIPE
#define TRANS_TRANSACT_NMPIPE
#define TRANS_RAW_WRITE_NMPIPE
#define TRANS_READ_NMPIPE
#define TRANS_WRITE_NMPIPE
#define TRANS_WAIT_NMPIPE
#define TRANS_CALL_NMPIPE

/* NT Transact subcommand codes */
#define NT_TRANSACT_CREATE
#define NT_TRANSACT_IOCTL
#define NT_TRANSACT_SET_SECURITY_DESC
#define NT_TRANSACT_NOTIFY_CHANGE
#define NT_TRANSACT_RENAME
#define NT_TRANSACT_QUERY_SECURITY_DESC
#define NT_TRANSACT_GET_USER_QUOTA
#define NT_TRANSACT_SET_USER_QUOTA

#define MAX_CIFS_SMALL_BUFFER_SIZE
/* future chained NTCreateXReadX bigger, but for time being NTCreateX biggest */
/* among the requests (NTCreateX response is bigger with wct of 34) */
#define MAX_CIFS_HDR_SIZE
#define CIFS_SMALL_PATH

/* internal cifs vfs structures */
/*****************************************************************
 * All constants go here
 *****************************************************************
 */

/*
 * Starting value for maximum SMB size negotiation
 */
#define CIFS_MAX_MSGSIZE

/*
 * Size of encrypted user password in bytes
 */
#define CIFS_ENCPWD_SIZE

/*
 * Size of the crypto key returned on the negotiate SMB in bytes
 */
#define CIFS_CRYPTO_KEY_SIZE

/*
 * Size of the ntlm client response
 */
#define CIFS_AUTH_RESP_SIZE

/*
 * Size of the session key (crypto key encrypted with the password
 */
#define CIFS_SESS_KEY_SIZE

#define CIFS_SERVER_CHALLENGE_SIZE
#define CIFS_HMAC_MD5_HASH_SIZE
#define CIFS_CPHTXT_SIZE
#define CIFS_NTHASH_SIZE

/*
 * Maximum user name length
 */
#define CIFS_UNLEN

/*
 * Flags on SMB open
 */
#define SMBOPEN_WRITE_THROUGH
#define SMBOPEN_DENY_ALL
#define SMBOPEN_DENY_WRITE
#define SMBOPEN_DENY_READ
#define SMBOPEN_DENY_NONE
#define SMBOPEN_READ
#define SMBOPEN_WRITE
#define SMBOPEN_READWRITE
#define SMBOPEN_EXECUTE

#define SMBOPEN_OCREATE
#define SMBOPEN_OTRUNC
#define SMBOPEN_OAPPEND

/*
 * SMB flag definitions
 */
#define SMBFLG_EXTD_LOCK
#define SMBFLG_RCV_POSTED
#define SMBFLG_RSVD
#define SMBFLG_CASELESS
#define SMBFLG_CANONICAL_PATH_FORMAT
#define SMBFLG_OLD_OPLOCK
#define SMBFLG_OLD_OPLOCK_NOTIFY
#define SMBFLG_RESPONSE

/*
 * SMB flag2 definitions
 */
#define SMBFLG2_KNOWS_LONG_NAMES
#define SMBFLG2_KNOWS_EAS
#define SMBFLG2_SECURITY_SIGNATURE
#define SMBFLG2_COMPRESSED
#define SMBFLG2_SECURITY_SIGNATURE_REQUIRED
#define SMBFLG2_IS_LONG_NAME
#define SMBFLG2_REPARSE_PATH
#define SMBFLG2_EXT_SEC
#define SMBFLG2_DFS
#define SMBFLG2_PAGING_IO
#define SMBFLG2_ERR_STATUS
#define SMBFLG2_UNICODE

/*
 * These are the file access permission bits defined in CIFS for the
 * NTCreateAndX as well as the level 0x107
 * TRANS2_QUERY_PATH_INFORMATION API.  The level 0x107, SMB_QUERY_FILE_ALL_INFO
 * responds with the AccessFlags.
 * The AccessFlags specifies the access permissions a caller has to the
 * file and can have any suitable combination of the following values:
 */

#define FILE_READ_DATA
#define FILE_WRITE_DATA
#define FILE_APPEND_DATA
#define FILE_READ_EA
					  /* with the file can be read        */
#define FILE_WRITE_EA
					  /* with the file can be written     */
#define FILE_EXECUTE
					  /* the file using system paging I/O */
#define FILE_DELETE_CHILD
#define FILE_READ_ATTRIBUTES
					  /* file can be read                 */
#define FILE_WRITE_ATTRIBUTES
					  /* file can be written              */
#define DELETE
#define READ_CONTROL
					  /* ownership associated with the    */
					  /* file can be read                 */
#define WRITE_DAC
					  /* ownership associated with the    */
					  /* file can be written.             */
#define WRITE_OWNER
					  /* with the file can be written     */
#define SYNCHRONIZE
					  /* synchronize with the completion  */
					  /* of an input/output request       */
#define SYSTEM_SECURITY
					  /* can be read and changed          */
#define GENERIC_ALL
#define GENERIC_EXECUTE
#define GENERIC_WRITE
#define GENERIC_READ
					 /* In summary - Relevant file       */
					 /* access flags from CIFS are       */
					 /* file_read_data, file_write_data  */
					 /* file_execute, file_read_attributes*/
					 /* write_dac, and delete.           */

#define FILE_READ_RIGHTS
#define FILE_WRITE_RIGHTS
#define FILE_EXEC_RIGHTS

#define SET_FILE_READ_RIGHTS
#define SET_FILE_WRITE_RIGHTS
#define SET_FILE_EXEC_RIGHTS

#define SET_MINIMUM_RIGHTS


/*
 * Invalid readdir handle
 */
#define CIFS_NO_HANDLE

#define NO_CHANGE_64

/* IPC$ in ASCII */
#define CIFS_IPC_RESOURCE

/* IPC$ in Unicode */
#define CIFS_IPC_UNICODE_RESOURCE

/* Unicode Null terminate 2 bytes of 0 */
#define UNICODE_NULL
#define ASCII_NULL

/*
 * Server type values (returned on EnumServer API
 */
#define CIFS_SV_TYPE_DC
#define CIFS_SV_TYPE_BACKDC

/*
 * Alias type flags (From EnumAlias API call
 */
#define CIFS_ALIAS_TYPE_FILE
#define CIFS_SHARE_TYPE_FILE

/*
 * File Attribute flags
 */
#define ATTR_READONLY
#define ATTR_HIDDEN
#define ATTR_SYSTEM
#define ATTR_VOLUME
#define ATTR_DIRECTORY
#define ATTR_ARCHIVE
#define ATTR_DEVICE
#define ATTR_NORMAL
#define ATTR_TEMPORARY
#define ATTR_SPARSE
#define ATTR_REPARSE
#define ATTR_COMPRESSED
#define ATTR_OFFLINE
#define ATTR_NOT_CONTENT_INDEXED
#define ATTR_ENCRYPTED
#define ATTR_POSIX_SEMANTICS
#define ATTR_BACKUP_SEMANTICS
#define ATTR_DELETE_ON_CLOSE
#define ATTR_SEQUENTIAL_SCAN
#define ATTR_RANDOM_ACCESS
#define ATTR_NO_BUFFERING
#define ATTR_WRITE_THROUGH

/* ShareAccess flags */
#define FILE_NO_SHARE
#define FILE_SHARE_READ
#define FILE_SHARE_WRITE
#define FILE_SHARE_DELETE
#define FILE_SHARE_ALL

/* CreateDisposition flags, similar to CreateAction as well */
#define FILE_SUPERSEDE
#define FILE_OPEN
#define FILE_CREATE
#define FILE_OPEN_IF
#define FILE_OVERWRITE
#define FILE_OVERWRITE_IF

/* CreateOptions */
#define CREATE_NOT_FILE
#define CREATE_WRITE_THROUGH
#define CREATE_SEQUENTIAL
#define CREATE_NO_BUFFER
#define CREATE_SYNC_ALERT
#define CREATE_ASYNC_ALERT
#define CREATE_NOT_DIR
#define CREATE_TREE_CONNECTION
#define CREATE_COMPLETE_IF_OPLK
#define CREATE_NO_EA_KNOWLEDGE
#define CREATE_EIGHT_DOT_THREE
#define CREATE_OPEN_FOR_RECOVERY
#define CREATE_RANDOM_ACCESS
#define CREATE_DELETE_ON_CLOSE
#define CREATE_OPEN_BY_ID
#define CREATE_OPEN_BACKUP_INTENT
#define CREATE_NO_COMPRESSION
#define CREATE_RESERVE_OPFILTER
#define OPEN_REPARSE_POINT
#define OPEN_NO_RECALL
#define OPEN_FREE_SPACE_QUERY
#define CREATE_OPTIONS_MASK
#define CREATE_OPTION_READONLY
#define CREATE_OPTION_SPECIAL

/* ImpersonationLevel flags */
#define SECURITY_ANONYMOUS
#define SECURITY_IDENTIFICATION
#define SECURITY_IMPERSONATION
#define SECURITY_DELEGATION

/* SecurityFlags */
#define SECURITY_CONTEXT_TRACKING
#define SECURITY_EFFECTIVE_ONLY

/*
 * Default PID value, used in all SMBs where the PID is not important
 */
#define CIFS_DFT_PID

/*
 * We use the same routine for Copy and Move SMBs.  This flag is used to
 * distinguish
 */
#define CIFS_COPY_OP
#define CIFS_RENAME_OP

#define GETU16(var)
#define GETU32(var)

struct smb_hdr {} __attribute__((packed));

/* given a pointer to an smb_hdr, retrieve a void pointer to the ByteCount */
static inline void *
BCC(struct smb_hdr *smb)
{}

/* given a pointer to an smb_hdr retrieve the pointer to the byte area */
#define pByteArea(smb_var)

/* get the unconverted ByteCount for a SMB packet and return it */
static inline __u16
get_bcc(struct smb_hdr *hdr)
{}

/* set the ByteCount for a SMB packet in little-endian */
static inline void
put_bcc(__u16 count, struct smb_hdr *hdr)
{}

/*
 * Computer Name Length (since Netbios name was length 16 with last byte 0x20)
 * No longer as important, now that TCP names are more commonly used to
 * resolve hosts.
 */
#define CNLEN

/*
 * Share Name Length (SNLEN)
 * Note:  This length was limited by the SMB used to get
 *        the Share info.   NetShareEnum only returned 13
 *        chars, including the null termination.
 * This was removed because it no longer is limiting.
 */

/*
 * Comment Length
 */
#define MAXCOMMENTLEN

/*
 * The OS/2 maximum path name
 */
#define MAX_PATHCONF

/*
 *  SMB frame definitions  (following must be packed structs)
 *  See the SNIA CIFS Specification for details.
 *
 *  The Naming convention is the lower case version of the
 *  smb command code name for the struct and this is typedef to the
 *  uppercase version of the same name with the prefix SMB_ removed
 *  for brevity.  Although typedefs are not commonly used for
 *  structure definitions in the Linux kernel, their use in the
 *  CIFS standards document, which this code is based on, may
 *  make this one of the cases where typedefs for structures make
 *  sense to improve readability for readers of the standards doc.
 *  Typedefs can always be removed later if they are too distracting
 *  and they are only used for the CIFSs PDUs themselves, not
 *  internal cifs vfs structures
 *
 */

NEGOTIATE_REQ;

#define MIN_TZ_ADJ

#define READ_RAW_ENABLE
#define WRITE_RAW_ENABLE
#define RAW_ENABLE
#define SMB1_CLIENT_GUID_SIZE
NEGOTIATE_RSP;

/* SecurityMode bits */
#define SECMODE_USER
#define SECMODE_PW_ENCRYPT
#define SECMODE_SIGN_ENABLED
#define SECMODE_SIGN_REQUIRED

/* Negotiate response Capabilities */
#define CAP_RAW_MODE
#define CAP_MPX_MODE
#define CAP_UNICODE
#define CAP_LARGE_FILES
#define CAP_NT_SMBS
#define CAP_RPC_REMOTE_APIS
#define CAP_STATUS32
#define CAP_LEVEL_II_OPLOCKS
#define CAP_LOCK_AND_READ
#define CAP_NT_FIND
#define CAP_DFS
#define CAP_INFOLEVEL_PASSTHRU
#define CAP_LARGE_READ_X
#define CAP_LARGE_WRITE_X
#define CAP_LWIO
#define CAP_UNIX
#define CAP_COMPRESSED_DATA
#define CAP_DYNAMIC_REAUTH
#define CAP_PERSISTENT_HANDLES
#define CAP_EXTENDED_SECURITY

SESSION_SETUP_ANDX;

/* format of NLTMv2 Response ie "case sensitive password" hash when NTLMv2 */

#define NTLMSSP_SERVER_TYPE
#define NTLMSSP_DOMAIN_TYPE
#define NTLMSSP_FQ_DOMAIN_TYPE
#define NTLMSSP_DNS_DOMAIN_TYPE
#define NTLMSSP_DNS_PARENT_TYPE

struct ntlmssp2_name {} __attribute__((packed));

struct ntlmv2_resp {} __attribute__((packed));


#define CIFS_NETWORK_OPSYS

/* Capabilities bits (for NTLM SessSetup request) */
#define CAP_UNICODE
#define CAP_LARGE_FILES
#define CAP_NT_SMBS
#define CAP_STATUS32
#define CAP_LEVEL_II_OPLOCKS
#define CAP_NT_FIND
#define CAP_BULK_TRANSFER
#define CAP_EXTENDED_SECURITY

/* Action bits */
#define GUEST_LOGIN

TCONX_REQ;

TCONX_RSP;

TCONX_RSP_EXT;


/* tree connect Flags */
#define DISCONNECT_TID
#define TCON_EXTENDED_SIGNATURES
#define TCON_EXTENDED_SECINFO

/* OptionalSupport bits */
#define SMB_SUPPORT_SEARCH_BITS
#define SMB_SHARE_IS_IN_DFS
#define SMB_CSC_MASK
/* CSC flags defined as follows */
#define SMB_CSC_CACHE_MANUAL_REINT
#define SMB_CSC_CACHE_AUTO_REINT
#define SMB_CSC_CACHE_VDO
#define SMB_CSC_NO_CACHING
#define SMB_UNIQUE_FILE_NAME
#define SMB_EXTENDED_SIGNATURES

/* services
 *
 * A:       ie disk
 * LPT1:    ie printer
 * IPC      ie named pipe
 * COMM
 * ?????    ie any type
 *
 */

ECHO_REQ;

ECHO_RSP;

LOGOFF_ANDX_REQ;

LOGOFF_ANDX_RSP;

TREE_DISCONNECT;

CLOSE_REQ;

CLOSE_RSP;

FLUSH_REQ;

FINDCLOSE_REQ;

/* OpenFlags */
#define REQ_MORE_INFO
#define REQ_OPLOCK
#define REQ_BATCHOPLOCK
#define REQ_OPENDIRONLY
#define REQ_EXTENDED_INFO

/* File type */
#define DISK_TYPE
#define BYTE_PIPE_TYPE
#define MESSAGE_PIPE_TYPE
#define PRINTER_TYPE
#define COMM_DEV_TYPE
#define UNKNOWN_TYPE

/* Device Type or File Status Flags */
#define NO_EAS
#define NO_SUBSTREAMS
#define NO_REPARSETAG
/* following flags can apply if pipe */
#define ICOUNT_MASK
#define PIPE_READ_MODE
#define NAMED_PIPE_TYPE
#define PIPE_END_POINT
#define BLOCKING_NAMED_PIPE

OPEN_REQ;

/* open response: oplock levels */
#define OPLOCK_NONE
#define OPLOCK_EXCLUSIVE
#define OPLOCK_BATCH
#define OPLOCK_READ

/* open response for CreateAction shifted left */
#define CIFS_CREATE_ACTION

OPEN_RSP;

OPEN_RSP_EXT;


/* format of legacy open request */
OPENX_REQ;

OPENX_RSP;

/* For encoding of POSIX Open Request - see trans2 function 0x209 data struct */

/* Legacy write request for older servers */
WRITEX_REQ;

WRITE_REQ;

WRITE_RSP;

/* legacy read request for older servers */
READX_REQ;

READ_REQ;

READ_RSP;

LOCKING_ANDX_RANGE;

#define LOCKING_ANDX_SHARED_LOCK
#define LOCKING_ANDX_OPLOCK_RELEASE
#define LOCKING_ANDX_CHANGE_LOCKTYPE
#define LOCKING_ANDX_CANCEL_LOCK
#define LOCKING_ANDX_LARGE_FILES

LOCK_REQ;

/* lock type */
#define CIFS_RDLCK
#define CIFS_WRLCK
#define CIFS_UNLCK
CIFS_POSIX_LOCK;

LOCK_RSP;

RENAME_REQ;

	/* copy request flags */
#define COPY_MUST_BE_FILE
#define COPY_MUST_BE_DIR
#define COPY_TARGET_MODE_ASCII
#define COPY_SOURCE_MODE_ASCII
#define COPY_VERIFY_WRITES
#define COPY_TREE

COPY_REQ;

COPY_RSP;

#define CREATE_HARD_LINK
#define MOVEFILE_COPY_ALLOWED
#define MOVEFILE_REPLACE_EXISTING

NT_RENAME_REQ;

RENAME_RSP;

DELETE_FILE_REQ;

DELETE_FILE_RSP;

DELETE_DIRECTORY_REQ;

DELETE_DIRECTORY_RSP;

CREATE_DIRECTORY_REQ;

CREATE_DIRECTORY_RSP;

QUERY_INFORMATION_REQ;

QUERY_INFORMATION_RSP;

SETATTR_REQ;

SETATTR_RSP;

/* empty wct response to setattr */

/*******************************************************/
/* NT Transact structure definitions follow            */
/* Currently only ioctl, acl (get security descriptor) */
/* and notify are implemented                          */
/*******************************************************/
NTRANSACT_REQ;

NTRANSACT_RSP;

/* See MS-SMB 2.2.7.2.1.1 */
struct srv_copychunk {} __packed;

TRANSACT_IOCTL_REQ;

TRANSACT_COMPR_IOCTL_REQ;

/* compression state flags */
#define COMPRESSION_FORMAT_NONE
#define COMPRESSION_FORMAT_DEFAULT
#define COMPRESSION_FORMAT_LZNT1

TRANSACT_IOCTL_RSP;

#define CIFS_ACL_OWNER
#define CIFS_ACL_GROUP
#define CIFS_ACL_DACL
#define CIFS_ACL_SACL

QUERY_SEC_DESC_REQ;


SET_SEC_DESC_REQ;

TRANSACT_CHANGE_NOTIFY_REQ;

/* BB eventually change to use generic ntransact rsp struct
      and validation routine */
TRANSACT_CHANGE_NOTIFY_RSP;
/* Completion Filter flags for Notify */
#define FILE_NOTIFY_CHANGE_FILE_NAME
#define FILE_NOTIFY_CHANGE_DIR_NAME
#define FILE_NOTIFY_CHANGE_NAME
#define FILE_NOTIFY_CHANGE_ATTRIBUTES
#define FILE_NOTIFY_CHANGE_SIZE
#define FILE_NOTIFY_CHANGE_LAST_WRITE
#define FILE_NOTIFY_CHANGE_LAST_ACCESS
#define FILE_NOTIFY_CHANGE_CREATION
#define FILE_NOTIFY_CHANGE_EA
#define FILE_NOTIFY_CHANGE_SECURITY
#define FILE_NOTIFY_CHANGE_STREAM_NAME
#define FILE_NOTIFY_CHANGE_STREAM_SIZE
#define FILE_NOTIFY_CHANGE_STREAM_WRITE

#define FILE_ACTION_ADDED
#define FILE_ACTION_REMOVED
#define FILE_ACTION_MODIFIED
#define FILE_ACTION_RENAMED_OLD_NAME
#define FILE_ACTION_RENAMED_NEW_NAME
#define FILE_ACTION_ADDED_STREAM
#define FILE_ACTION_REMOVED_STREAM
#define FILE_ACTION_MODIFIED_STREAM

/* response contains array of the following structures */
struct file_notify_information {} __attribute__((packed));

/* For IO_REPARSE_TAG_SYMLINK */
struct reparse_symlink_data {} __attribute__((packed));

/* Flag above */
#define SYMLINK_FLAG_RELATIVE

/* For IO_REPARSE_TAG_NFS */
#define NFS_SPECFILE_LNK
#define NFS_SPECFILE_CHR
#define NFS_SPECFILE_BLK
#define NFS_SPECFILE_FIFO
#define NFS_SPECFILE_SOCK
struct reparse_posix_data {} __attribute__((packed));

struct cifs_quota_data {} __attribute__((packed));

/* quota sub commands */
#define QUOTA_LIST_CONTINUE
#define QUOTA_LIST_START
#define QUOTA_FOR_SID

struct trans2_req {} __attribute__((packed));

struct smb_t2_req {} __attribute__((packed));

struct trans2_resp {} __attribute__((packed));

struct smb_t2_rsp {} __attribute__((packed));

/* PathInfo/FileInfo infolevels */
#define SMB_INFO_STANDARD
#define SMB_SET_FILE_EA
#define SMB_QUERY_FILE_EA_SIZE
#define SMB_INFO_QUERY_EAS_FROM_LIST
#define SMB_INFO_QUERY_ALL_EAS
#define SMB_INFO_IS_NAME_VALID
#define SMB_QUERY_FILE_BASIC_INFO
#define SMB_QUERY_FILE_STANDARD_INFO
#define SMB_QUERY_FILE_EA_INFO
#define SMB_QUERY_FILE_NAME_INFO
#define SMB_QUERY_FILE_ALLOCATION_INFO
#define SMB_QUERY_FILE_END_OF_FILEINFO
#define SMB_QUERY_FILE_ALL_INFO
#define SMB_QUERY_ALT_NAME_INFO
#define SMB_QUERY_FILE_STREAM_INFO
#define SMB_QUERY_FILE_COMPRESSION_INFO
#define SMB_QUERY_FILE_UNIX_BASIC
#define SMB_QUERY_FILE_UNIX_LINK
#define SMB_QUERY_POSIX_ACL
#define SMB_QUERY_XATTR
#define SMB_QUERY_ATTR_FLAGS
#define SMB_QUERY_POSIX_PERMISSION
#define SMB_QUERY_POSIX_LOCK
/* #define SMB_POSIX_OPEN               0x209 */
/* #define SMB_POSIX_UNLINK             0x20a */
#define SMB_QUERY_FILE__UNIX_INFO2
#define SMB_QUERY_FILE_INTERNAL_INFO
#define SMB_QUERY_FILE_ACCESS_INFO
#define SMB_QUERY_FILE_NAME_INFO2
#define SMB_QUERY_FILE_POSITION_INFO
#define SMB_QUERY_FILE_MODE_INFO
#define SMB_QUERY_FILE_ALGN_INFO


#define SMB_SET_FILE_BASIC_INFO
#define SMB_SET_FILE_DISPOSITION_INFO
#define SMB_SET_FILE_ALLOCATION_INFO
#define SMB_SET_FILE_END_OF_FILE_INFO
#define SMB_SET_FILE_UNIX_BASIC
#define SMB_SET_FILE_UNIX_LINK
#define SMB_SET_FILE_UNIX_HLINK
#define SMB_SET_POSIX_ACL
#define SMB_SET_XATTR
#define SMB_SET_ATTR_FLAGS
#define SMB_SET_POSIX_LOCK
#define SMB_POSIX_OPEN
#define SMB_POSIX_UNLINK
#define SMB_SET_FILE_UNIX_INFO2
#define SMB_SET_FILE_BASIC_INFO2
#define SMB_SET_FILE_RENAME_INFORMATION
#define SMB_FILE_ALL_INFO2
#define SMB_SET_FILE_ALLOCATION_INFO2
#define SMB_SET_FILE_END_OF_FILE_INFO2
#define SMB_FILE_MOVE_CLUSTER_INFO
#define SMB_FILE_QUOTA_INFO
#define SMB_FILE_REPARSEPOINT_INFO
#define SMB_FILE_MAXIMUM_INFO

/* Find File infolevels */
#define SMB_FIND_FILE_INFO_STANDARD
#define SMB_FIND_FILE_QUERY_EA_SIZE
#define SMB_FIND_FILE_QUERY_EAS_FROM_LIST
#define SMB_FIND_FILE_DIRECTORY_INFO
#define SMB_FIND_FILE_FULL_DIRECTORY_INFO
#define SMB_FIND_FILE_NAMES_INFO
#define SMB_FIND_FILE_BOTH_DIRECTORY_INFO
#define SMB_FIND_FILE_ID_FULL_DIR_INFO
#define SMB_FIND_FILE_ID_BOTH_DIR_INFO
#define SMB_FIND_FILE_UNIX
/* #define SMB_FIND_FILE_POSIX_INFO          0x064 */

TRANSACTION2_QPI_REQ;

TRANSACTION2_QPI_RSP;

TRANSACTION2_SPI_REQ;

TRANSACTION2_SPI_RSP;

struct set_file_rename {} __attribute__((packed));

struct smb_com_transaction2_sfi_req {} __attribute__((packed));

struct smb_com_transaction2_sfi_rsp {} __attribute__((packed));

struct smb_t2_qfi_req {} __attribute__((packed));

struct smb_t2_qfi_rsp {} __attribute__((packed));

/*
 * Flags on T2 FINDFIRST and FINDNEXT
 */
#define CIFS_SEARCH_CLOSE_ALWAYS
#define CIFS_SEARCH_CLOSE_AT_END
#define CIFS_SEARCH_RETURN_RESUME
#define CIFS_SEARCH_CONTINUE_FROM_LAST
#define CIFS_SEARCH_BACKUP_SEARCH

/*
 * Size of the resume key on FINDFIRST and FINDNEXT calls
 */
#define CIFS_SMB_RESUME_KEY_SIZE

TRANSACTION2_FFIRST_REQ;

TRANSACTION2_FFIRST_RSP;

T2_FFIRST_RSP_PARMS;

TRANSACTION2_FNEXT_REQ;

TRANSACTION2_FNEXT_RSP;

T2_FNEXT_RSP_PARMS;

/* QFSInfo Levels */
#define SMB_INFO_ALLOCATION
#define SMB_INFO_VOLUME
#define SMB_QUERY_FS_VOLUME_INFO
#define SMB_QUERY_FS_SIZE_INFO
#define SMB_QUERY_FS_DEVICE_INFO
#define SMB_QUERY_FS_ATTRIBUTE_INFO
#define SMB_QUERY_CIFS_UNIX_INFO
#define SMB_QUERY_POSIX_FS_INFO
#define SMB_QUERY_POSIX_WHO_AM_I
#define SMB_REQUEST_TRANSPORT_ENCRYPTION
#define SMB_QUERY_FS_PROXY
#define SMB_QUERY_LABEL_INFO
#define SMB_QUERY_FS_QUOTA_INFO
#define SMB_QUERY_FS_FULL_SIZE_INFO
#define SMB_QUERY_OBJECTID_INFO

TRANSACTION2_QFSI_REQ;

TRANSACTION2_QFSI_RSP;

WHOAMI_RSP_DATA;

/* SETFSInfo Levels */
#define SMB_SET_CIFS_UNIX_INFO
/* level 0x203 is defined above in list of QFS info levels */
/* #define SMB_REQUEST_TRANSPORT_ENCRYPTION 0x203 */

/* Level 0x200 request structure follows */
TRANSACTION2_SETFSI_REQ;

/* level 0x203 request structure follows */
TRANSACTION2_SETFSI_ENC_REQ;

/* response for setfsinfo levels 0x200 and 0x203 */
TRANSACTION2_SETFSI_RSP;

TRANSACTION2_GET_DFS_REFER_REQ;

#define DFS_VERSION

/* DFS server target type */
#define DFS_TYPE_LINK
#define DFS_TYPE_ROOT

/* Referral Entry Flags */
#define DFS_NAME_LIST_REF
#define DFS_TARGET_SET_BOUNDARY

REFERRAL3;

struct get_dfs_referral_rsp {} __packed;

TRANSACTION2_GET_DFS_REFER_RSP;

/* DFS Flags */
#define DFSREF_REFERRAL_SERVER
#define DFSREF_STORAGE_SERVER
#define DFSREF_TARGET_FAILBACK

/*
 ************************************************************************
 * All structs for everything above the SMB PDUs themselves
 * (such as the T2 level specific data) go here
 ************************************************************************
 */

/*
 * Information on a server
 */

struct serverInfo {} __attribute__((packed));

/*
 * The following structure is the format of the data returned on a NetShareEnum
 * with level "90" (x5A)
 */

struct shareInfo {} __attribute__((packed));

struct aliasInfo {} __attribute__((packed));

struct aliasInfo92 {} __attribute__((packed));

FILE_SYSTEM_INFO;	/* size info, level 0x103 */

FILE_SYSTEM_ALLOC_INFO;

FILE_SYSTEM_UNIX_INFO; /* Unix extension level 0x200*/

/* Version numbers for CIFS UNIX major and minor. */
#define CIFS_UNIX_MAJOR_VERSION
#define CIFS_UNIX_MINOR_VERSION

/* Linux/Unix extensions capability flags */
#define CIFS_UNIX_FCNTL_CAP
#define CIFS_UNIX_POSIX_ACL_CAP
#define CIFS_UNIX_XATTR_CAP
#define CIFS_UNIX_EXTATTR_CAP
#define CIFS_UNIX_POSIX_PATHNAMES_CAP
#define CIFS_UNIX_POSIX_PATH_OPS_CAP
#define CIFS_UNIX_LARGE_READ_CAP
#define CIFS_UNIX_LARGE_WRITE_CAP
#define CIFS_UNIX_TRANSPORT_ENCRYPTION_CAP
#define CIFS_UNIX_TRANSPORT_ENCRYPTION_MANDATORY_CAP
#define CIFS_UNIX_PROXY_CAP
#ifdef CONFIG_CIFS_POSIX
/* presumably don't need the 0x20 POSIX_PATH_OPS_CAP since we never send
   LockingX instead of posix locking call on unix sess (and we do not expect
   LockingX to use different (ie Windows) semantics than posix locking on
   the same session (if WINE needs to do this later, we can add this cap
   back in later */
/* #define CIFS_UNIX_CAP_MASK              0x000000fb */
#define CIFS_UNIX_CAP_MASK
#else
#define CIFS_UNIX_CAP_MASK
#endif /* CONFIG_CIFS_POSIX */


#define CIFS_POSIX_EXTENSIONS

FILE_SYSTEM_POSIX_INFO;

/* DeviceType Flags */
#define FILE_DEVICE_CD_ROM
#define FILE_DEVICE_CD_ROM_FILE_SYSTEM
#define FILE_DEVICE_DFS
#define FILE_DEVICE_DISK
#define FILE_DEVICE_DISK_FILE_SYSTEM
#define FILE_DEVICE_FILE_SYSTEM
#define FILE_DEVICE_NAMED_PIPE
#define FILE_DEVICE_NETWORK
#define FILE_DEVICE_NETWORK_FILE_SYSTEM
#define FILE_DEVICE_NULL
#define FILE_DEVICE_PARALLEL_PORT
#define FILE_DEVICE_PRINTER
#define FILE_DEVICE_SERIAL_PORT
#define FILE_DEVICE_STREAMS
#define FILE_DEVICE_TAPE
#define FILE_DEVICE_TAPE_FILE_SYSTEM
#define FILE_DEVICE_VIRTUAL_DISK
#define FILE_DEVICE_NETWORK_REDIRECTOR

/* Device Characteristics */
#define FILE_REMOVABLE_MEDIA
#define FILE_READ_ONLY_DEVICE
#define FILE_FLOPPY_DISKETTE
#define FILE_WRITE_ONCE_MEDIA
#define FILE_REMOTE_DEVICE
#define FILE_DEVICE_IS_MOUNTED
#define FILE_VIRTUAL_VOLUME
#define FILE_DEVICE_SECURE_OPEN
#define FILE_CHARACTERISTIC_TS_DEVICE
#define FILE_CHARACTERISTIC_WEBDAV_DEVICE
#define FILE_PORTABLE_DEVICE
#define FILE_DEVICE_ALLOW_APPCONTAINER_TRAVERSAL

FILE_SYSTEM_DEVICE_INFO; /* device info level 0x104 */

/* minimum includes first three fields, and empty FS Name */
#define MIN_FS_ATTR_INFO_SIZE


/* List of FileSystemAttributes - see 2.5.1 of MS-FSCC */
#define FILE_SUPPORTS_SPARSE_VDL
#define FILE_SUPPORTS_BLOCK_REFCOUNTING
#define FILE_SUPPORT_INTEGRITY_STREAMS
#define FILE_SUPPORTS_USN_JOURNAL
#define FILE_SUPPORTS_OPEN_BY_FILE_ID
#define FILE_SUPPORTS_EXTENDED_ATTRIBUTES
#define FILE_SUPPORTS_HARD_LINKS
#define FILE_SUPPORTS_TRANSACTIONS
#define FILE_SEQUENTIAL_WRITE_ONCE
#define FILE_READ_ONLY_VOLUME
#define FILE_NAMED_STREAMS
#define FILE_SUPPORTS_ENCRYPTION
#define FILE_SUPPORTS_OBJECT_IDS
#define FILE_VOLUME_IS_COMPRESSED
#define FILE_SUPPORTS_REMOTE_STORAGE
#define FILE_SUPPORTS_REPARSE_POINTS
#define FILE_SUPPORTS_SPARSE_FILES
#define FILE_VOLUME_QUOTAS
#define FILE_FILE_COMPRESSION
#define FILE_PERSISTENT_ACLS
#define FILE_UNICODE_ON_DISK
#define FILE_CASE_PRESERVED_NAMES
#define FILE_CASE_SENSITIVE_SEARCH
FILE_SYSTEM_ATTRIBUTE_INFO;

/******************************************************************************/
/* QueryFileInfo/QueryPathinfo (also for SetPath/SetFile) data buffer formats */
/******************************************************************************/
FILE_ALL_INFO;	/* level 0x107 QPathInfo */

FILE_STANDARD_INFO;	/* level 0x102 QPathInfo */


/* defines for enumerating possible values of the Unix type field below */
#define UNIX_FILE
#define UNIX_DIR
#define UNIX_SYMLINK
#define UNIX_CHARDEV
#define UNIX_BLOCKDEV
#define UNIX_FIFO
#define UNIX_SOCKET
FILE_UNIX_BASIC_INFO;	/* level 0x200 QPathInfo */

FILE_UNIX_LINK_INFO;	/* level 0x201 QPathInfo */

/* The following three structures are needed only for
	setting time to NT4 and some older servers via
	the primitive DOS time format */
SMB_DATE;

SMB_TIME;

FILE_INFO_STANDARD;  /* level 1 SetPath/FileInfo */

FILE_BASIC_INFO;	/* size info, level 0x101 */

struct file_allocation_info {} __packed; /* size used on disk, for level 0x103 for set, 0x105 for query */

struct file_end_of_file_info {} __attribute__((packed)); /* size info, level 0x104 for set, 0x106 for query */

struct file_alt_name_info {} __attribute__((packed));      /* level 0x0108 */

struct file_stream_info {};      /* level 0x109 */

struct file_compression_info {} __attribute__((packed));      /* level 0x10b */

/* POSIX ACL set/query path info structures */
#define CIFS_ACL_VERSION
struct cifs_posix_ace {} __attribute__((packed));

struct cifs_posix_acl {} __attribute__((packed));  /* level 0x204 */

/* types of access control entries already defined in posix_acl.h */
/* #define CIFS_POSIX_ACL_USER_OBJ	 0x01
#define CIFS_POSIX_ACL_USER      0x02
#define CIFS_POSIX_ACL_GROUP_OBJ 0x04
#define CIFS_POSIX_ACL_GROUP     0x08
#define CIFS_POSIX_ACL_MASK      0x10
#define CIFS_POSIX_ACL_OTHER     0x20 */

/* types of perms */
/* #define CIFS_POSIX_ACL_EXECUTE   0x01
#define CIFS_POSIX_ACL_WRITE     0x02
#define CIFS_POSIX_ACL_READ	     0x04 */

/* end of POSIX ACL definitions */

/* POSIX Open Flags */
#define SMB_O_RDONLY
#define SMB_O_WRONLY
#define SMB_O_RDWR
#define SMB_O_CREAT
#define SMB_O_EXCL
#define SMB_O_TRUNC
#define SMB_O_APPEND
#define SMB_O_SYNC
#define SMB_O_DIRECTORY
#define SMB_O_NOFOLLOW
#define SMB_O_DIRECT

OPEN_PSX_REQ; /* level 0x209 SetPathInfo data */

OPEN_PSX_RSP; /* level 0x209 SetPathInfo data */

#define SMB_POSIX_UNLINK_FILE_TARGET
#define SMB_POSIX_UNLINK_DIRECTORY_TARGET

struct unlink_psx_rq {} __attribute__((packed));

struct file_internal_info {} __attribute__((packed));      /* level 0x3ee */

struct file_mode_info {} __attribute__((packed));      /* level 0x3f8 */

struct file_attrib_tag {} __attribute__((packed));      /* level 0x40b */


/********************************************************/
/*  FindFirst/FindNext transact2 data buffer formats    */
/********************************************************/

FILE_UNIX_INFO; /* level 0x202 */

FILE_DIRECTORY_INFO;   /* level 0x101 FF resp data */

FILE_FULL_DIRECTORY_INFO; /* level 0x102 rsp data */

SEARCH_ID_FULL_DIR_INFO; /* level 0x105 FF rsp data */

FILE_BOTH_DIRECTORY_INFO; /* level 0x104 FFrsp data */

FIND_FILE_STANDARD_INFO; /* level 0x1 FF resp data */


struct win_dev {} __attribute__((packed));

struct fea {} __attribute__((packed));
/* flags for _FEA.fEA */
#define FEA_NEEDEA

struct fealist {} __attribute__((packed));

/* used to hold an arbitrary blob of data */
struct data_blob {} __attribute__((packed));


#ifdef CONFIG_CIFS_POSIX
/*
	For better POSIX semantics from Linux client, (even better
	than the existing CIFS Unix Extensions) we need updated PDUs for:

	1) PosixCreateX - to set and return the mode, inode#, device info and
	perhaps add a CreateDevice - to create Pipes and other special .inodes
	Also note POSIX open flags
	2) Close - to return the last write time to do cache across close
		more safely
	3) FindFirst return unique inode number - what about resume key, two
	forms short (matches readdir) and full (enough info to cache inodes)
	4) Mkdir - set mode

	And under consideration:
	5) FindClose2 (return nanosecond timestamp ??)
	6) Use nanosecond timestamps throughout all time fields if
	   corresponding attribute flag is set
	7) sendfile - handle based copy

	what about fixing 64 bit alignment

	There are also various legacy SMB/CIFS requests used as is

	From existing Lanman and NTLM dialects:
	--------------------------------------
	NEGOTIATE
	SESSION_SETUP_ANDX (BB which?)
	TREE_CONNECT_ANDX (BB which wct?)
	TREE_DISCONNECT (BB add volume timestamp on response)
	LOGOFF_ANDX
	DELETE (note delete open file behavior)
	DELETE_DIRECTORY
	READ_AND_X
	WRITE_AND_X
	LOCKING_AND_X (note posix lock semantics)
	RENAME (note rename across dirs and open file rename posix behaviors)
	NT_RENAME (for hardlinks) Is this good enough for all features?
	FIND_CLOSE2
	TRANSACTION2 (18 cases)
		SMB_SET_FILE_END_OF_FILE_INFO2 SMB_SET_PATH_END_OF_FILE_INFO2
		(BB verify that never need to set allocation size)
		SMB_SET_FILE_BASIC_INFO2 (setting times - BB can it be done via
			 Unix ext?)

	COPY (note support for copy across directories) - FUTURE, OPTIONAL
	setting/getting OS/2 EAs - FUTURE (BB can this handle
	setting Linux xattrs perfectly)         - OPTIONAL
	dnotify                                 - FUTURE, OPTIONAL
	quota                                   - FUTURE, OPTIONAL

	Note that various requests implemented for NT interop such as
		NT_TRANSACT (IOCTL) QueryReparseInfo
	are unneeded to servers compliant with the CIFS POSIX extensions

	From CIFS Unix Extensions:
	-------------------------
	T2 SET_PATH_INFO (SMB_SET_FILE_UNIX_LINK) for symlinks
	T2 SET_PATH_INFO (SMB_SET_FILE_BASIC_INFO2)
	T2 QUERY_PATH_INFO (SMB_QUERY_FILE_UNIX_LINK)
	T2 QUERY_PATH_INFO (SMB_QUERY_FILE_UNIX_BASIC)	BB check for missing
							inode fields
				Actually a need QUERY_FILE_UNIX_INFO
				since has inode num
				BB what about a) blksize/blkbits/blocks
							  b) i_version
							  c) i_rdev
							  d) notify mask?
							  e) generation
							  f) size_seqcount
	T2 FIND_FIRST/FIND_NEXT FIND_FILE_UNIX
	TRANS2_GET_DFS_REFERRAL		      - OPTIONAL but recommended
	T2_QFS_INFO QueryDevice/AttributeInfo - OPTIONAL
 */

/* xsymlink is a symlink format (used by MacOS) that can be used
   to save symlink info in a regular file when
   mounted to operating systems that do not
   support the cifs Unix extensions or EAs (for xattr
   based symlinks).  For such a file to be recognized
   as containing symlink data:

   1) file size must be 1067,
   2) signature must begin file data,
   3) length field must be set to ASCII representation
	of a number which is less than or equal to 1024,
   4) md5 must match that of the path data */

struct xsymlink {} __attribute__((packed));

FILE_XATTR_INFO; /* extended attribute info level 0x205 */

/* flags for lsattr and chflags commands removed arein uapi/linux/fs.h */

FILE_CHATTR_INFO;  /* ext attributes (chattr, chflags) level 0x206 */
#endif				/* POSIX */
#endif				/* _CIFSPDU_H */