linux/fs/smb/server/smb2pdu.h

/* SPDX-License-Identifier: GPL-2.0-or-later */
/*
 *   Copyright (C) 2016 Namjae Jeon <[email protected]>
 *   Copyright (C) 2018 Samsung Electronics Co., Ltd.
 */

#ifndef _SMB2PDU_H
#define _SMB2PDU_H

#include "ntlmssp.h"
#include "smbacl.h"

/*Create Action Flags*/
#define FILE_SUPERSEDED
#define FILE_OPENED
#define FILE_CREATED
#define FILE_OVERWRITTEN

/* SMB2 Max Credits */
#define SMB2_MAX_CREDITS

/* BB FIXME - analyze following length BB */
#define MAX_SMB2_HDR_SIZE

#define SMB21_DEFAULT_IOSIZE
#define SMB3_DEFAULT_TRANS_SIZE
#define SMB3_MIN_IOSIZE
#define SMB3_MAX_IOSIZE
#define SMB3_MAX_MSGSIZE

/*
 *	Definitions for SMB2 Protocol Data Units (network frames)
 *
 *  See MS-SMB2.PDF specification for protocol details.
 *  The Naming convention is the lower case version of the SMB2
 *  command code name for the struct. Note that structures must be packed.
 *
 */

struct preauth_integrity_info {};

/* offset is sizeof smb2_negotiate_rsp but rounded up to 8 bytes. */
#ifdef CONFIG_SMB_SERVER_KERBEROS5
/* sizeof(struct smb2_negotiate_rsp) =
 * header(64) + response(64) + GSS_LENGTH(96) + GSS_PADDING(0)
 */
#define OFFSET_OF_NEG_CONTEXT
#else
/* sizeof(struct smb2_negotiate_rsp) =
 * header(64) + response(64) + GSS_LENGTH(74) + GSS_PADDING(6)
 */
#define OFFSET_OF_NEG_CONTEXT
#endif

#define SMB2_SESSION_EXPIRED
#define SMB2_SESSION_IN_PROGRESS
#define SMB2_SESSION_VALID

#define SMB2_SESSION_TIMEOUT

struct create_durable_req_v2 {} __packed;

#define DURABLE_HANDLE_MAX_TIMEOUT

struct create_durable_reconn_req {} __packed;

struct create_durable_reconn_v2_req {} __packed;

struct create_alloc_size_req {} __packed;

struct create_durable_rsp {} __packed;

/* See MS-SMB2 2.2.13.2.11 */
/* Flags */
#define SMB2_DHANDLE_FLAG_PERSISTENT
struct create_durable_v2_rsp {} __packed;

/* equivalent of the contents of SMB3.1.1 POSIX open context response */
struct create_posix_rsp {} __packed;

struct smb2_buffer_desc_v1 {} __packed;

#define SMB2_0_IOCTL_IS_FSCTL

struct smb_sockaddr_in {} __packed;

struct smb_sockaddr_in6 {} __packed;

#define INTERNETWORK
#define INTERNETWORKV6

struct sockaddr_storage_rsp {} __packed;

#define RSS_CAPABLE
#define RDMA_CAPABLE

struct network_interface_info_ioctl_rsp {} __packed;

struct file_object_buf_type1_ioctl_rsp {} __packed;

struct resume_key_ioctl_rsp {} __packed;

struct copychunk_ioctl_req {} __packed;

struct srv_copychunk {} __packed;

struct copychunk_ioctl_rsp {} __packed;

struct file_sparse {} __packed;

/* FILE Info response size */
#define FILE_DIRECTORY_INFORMATION_SIZE
#define FILE_FULL_DIRECTORY_INFORMATION_SIZE
#define FILE_BOTH_DIRECTORY_INFORMATION_SIZE
#define FILE_BASIC_INFORMATION_SIZE
#define FILE_STANDARD_INFORMATION_SIZE
#define FILE_INTERNAL_INFORMATION_SIZE
#define FILE_EA_INFORMATION_SIZE
#define FILE_ACCESS_INFORMATION_SIZE
#define FILE_NAME_INFORMATION_SIZE
#define FILE_RENAME_INFORMATION_SIZE
#define FILE_LINK_INFORMATION_SIZE
#define FILE_NAMES_INFORMATION_SIZE
#define FILE_DISPOSITION_INFORMATION_SIZE
#define FILE_POSITION_INFORMATION_SIZE
#define FILE_FULL_EA_INFORMATION_SIZE
#define FILE_MODE_INFORMATION_SIZE
#define FILE_ALIGNMENT_INFORMATION_SIZE
#define FILE_ALL_INFORMATION_SIZE
#define FILE_ALLOCATION_INFORMATION_SIZE
#define FILE_END_OF_FILE_INFORMATION_SIZE
#define FILE_ALTERNATE_NAME_INFORMATION_SIZE
#define FILE_STREAM_INFORMATION_SIZE
#define FILE_PIPE_INFORMATION_SIZE
#define FILE_PIPE_LOCAL_INFORMATION_SIZE
#define FILE_PIPE_REMOTE_INFORMATION_SIZE
#define FILE_MAILSLOT_QUERY_INFORMATION_SIZE
#define FILE_MAILSLOT_SET_INFORMATION_SIZE
#define FILE_COMPRESSION_INFORMATION_SIZE
#define FILE_OBJECT_ID_INFORMATION_SIZE
/* Number 30 not defined in documents */
#define FILE_MOVE_CLUSTER_INFORMATION_SIZE
#define FILE_QUOTA_INFORMATION_SIZE
#define FILE_REPARSE_POINT_INFORMATION_SIZE
#define FILE_NETWORK_OPEN_INFORMATION_SIZE
#define FILE_ATTRIBUTE_TAG_INFORMATION_SIZE

/* FS Info response  size */
#define FS_DEVICE_INFORMATION_SIZE
#define FS_ATTRIBUTE_INFORMATION_SIZE
#define FS_VOLUME_INFORMATION_SIZE
#define FS_SIZE_INFORMATION_SIZE
#define FS_FULL_SIZE_INFORMATION_SIZE
#define FS_SECTOR_SIZE_INFORMATION_SIZE
#define FS_OBJECT_ID_INFORMATION_SIZE
#define FS_CONTROL_INFORMATION_SIZE
#define FS_POSIX_INFORMATION_SIZE

/* FS_ATTRIBUTE_File_System_Name */
#define FS_TYPE_SUPPORT_SIZE
struct fs_type_info {} __packed;

/*
 *	PDU query infolevel structure definitions
 *	BB consider moving to a different header
 */

struct smb2_file_access_info {} __packed;

struct smb2_file_alignment_info {} __packed;

struct smb2_file_basic_info {} __packed;

struct smb2_file_alt_name_info {} __packed;

struct smb2_file_stream_info {} __packed;

struct smb2_file_ntwrk_info {} __packed;

struct smb2_file_standard_info {} __packed; /* level 18 Query */

struct smb2_file_ea_info {} __packed;

struct smb2_file_alloc_info {} __packed;

struct smb2_file_disposition_info {} __packed;

struct smb2_file_pos_info {} __packed;

#define FILE_MODE_INFO_MASK

struct smb2_file_mode_info {} __packed;

#define COMPRESSION_FORMAT_NONE
#define COMPRESSION_FORMAT_LZNT1

struct smb2_file_comp_info {} __packed;

struct smb2_file_attr_tag_info {} __packed;

#define SL_RESTART_SCAN
#define SL_RETURN_SINGLE_ENTRY
#define SL_INDEX_SPECIFIED

struct smb2_ea_info_req {} __packed; /* level 15 Query */

struct smb2_ea_info {} __packed; /* level 15 Query */

struct create_ea_buf_req {} __packed;

struct create_sd_buf_req {} __packed;

struct smb2_posix_info {} __packed;

/* functions */
void init_smb2_1_server(struct ksmbd_conn *conn);
void init_smb3_0_server(struct ksmbd_conn *conn);
void init_smb3_02_server(struct ksmbd_conn *conn);
int init_smb3_11_server(struct ksmbd_conn *conn);

void init_smb2_max_read_size(unsigned int sz);
void init_smb2_max_write_size(unsigned int sz);
void init_smb2_max_trans_size(unsigned int sz);
void init_smb2_max_credits(unsigned int sz);

bool is_smb2_neg_cmd(struct ksmbd_work *work);
bool is_smb2_rsp(struct ksmbd_work *work);

u16 get_smb2_cmd_val(struct ksmbd_work *work);
void set_smb2_rsp_status(struct ksmbd_work *work, __le32 err);
int init_smb2_rsp_hdr(struct ksmbd_work *work);
int smb2_allocate_rsp_buf(struct ksmbd_work *work);
bool is_chained_smb2_message(struct ksmbd_work *work);
int init_smb2_neg_rsp(struct ksmbd_work *work);
void smb2_set_err_rsp(struct ksmbd_work *work);
int smb2_check_user_session(struct ksmbd_work *work);
int smb2_get_ksmbd_tcon(struct ksmbd_work *work);
bool smb2_is_sign_req(struct ksmbd_work *work, unsigned int command);
int smb2_check_sign_req(struct ksmbd_work *work);
void smb2_set_sign_rsp(struct ksmbd_work *work);
int smb3_check_sign_req(struct ksmbd_work *work);
void smb3_set_sign_rsp(struct ksmbd_work *work);
int find_matching_smb2_dialect(int start_index, __le16 *cli_dialects,
			       __le16 dialects_count);
struct file_lock *smb_flock_init(struct file *f);
int setup_async_work(struct ksmbd_work *work, void (*fn)(void **),
		     void **arg);
void release_async_work(struct ksmbd_work *work);
void smb2_send_interim_resp(struct ksmbd_work *work, __le32 status);
struct channel *lookup_chann_list(struct ksmbd_session *sess,
				  struct ksmbd_conn *conn);
void smb3_preauth_hash_rsp(struct ksmbd_work *work);
bool smb3_is_transform_hdr(void *buf);
int smb3_decrypt_req(struct ksmbd_work *work);
int smb3_encrypt_resp(struct ksmbd_work *work);
bool smb3_11_final_sess_setup_resp(struct ksmbd_work *work);
int smb2_set_rsp_credits(struct ksmbd_work *work);
bool smb3_encryption_negotiated(struct ksmbd_conn *conn);

/* smb2 misc functions */
int ksmbd_smb2_check_message(struct ksmbd_work *work);

/* smb2 command handlers */
int smb2_handle_negotiate(struct ksmbd_work *work);
int smb2_negotiate_request(struct ksmbd_work *work);
int smb2_sess_setup(struct ksmbd_work *work);
int smb2_tree_connect(struct ksmbd_work *work);
int smb2_tree_disconnect(struct ksmbd_work *work);
int smb2_session_logoff(struct ksmbd_work *work);
int smb2_open(struct ksmbd_work *work);
int smb2_query_info(struct ksmbd_work *work);
int smb2_query_dir(struct ksmbd_work *work);
int smb2_close(struct ksmbd_work *work);
int smb2_echo(struct ksmbd_work *work);
int smb2_set_info(struct ksmbd_work *work);
int smb2_read(struct ksmbd_work *work);
int smb2_write(struct ksmbd_work *work);
int smb2_flush(struct ksmbd_work *work);
int smb2_cancel(struct ksmbd_work *work);
int smb2_lock(struct ksmbd_work *work);
int smb2_ioctl(struct ksmbd_work *work);
int smb2_oplock_break(struct ksmbd_work *work);
int smb2_notify(struct ksmbd_work *ksmbd_work);

/*
 * Get the body of the smb2 message excluding the 4 byte rfc1002 headers
 * from request/response buffer.
 */
static inline void *smb2_get_msg(void *buf)
{}

#endif	/* _SMB2PDU_H */