| 1 |
/* SPDX-License-Identifier: LGPL-2.1 */ |
| 2 |
/* |
| 3 |
* |
| 4 |
* Copyright (c) International Business Machines Corp., 2002, 2011 |
| 5 |
* Etersoft, 2012 |
| 6 |
* Author(s): Steve French ([email protected]) |
| 7 |
* Pavel Shilovsky ([email protected]) 2012 |
| 8 |
* |
| 9 |
*/ |
| 10 |
#ifndef _SMB2PROTO_H |
| 11 |
#define _SMB2PROTO_H |
| 12 |
|
| 13 |
#include <linux/nls.h> |
| 14 |
#include <linux/key-type.h> |
| 15 |
#include "cached_dir.h" |
| 16 |
|
| 17 |
struct statfs; |
| 18 |
struct smb_rqst; |
| 19 |
|
| 20 |
/* |
| 21 |
***************************************************************** |
| 22 |
* All Prototypes |
| 23 |
***************************************************************** |
| 24 |
*/ |
| 25 |
int map_smb2_to_linux_error(char *buf, bool log_err); |
| 26 |
int smb2_init_maperror(void); |
| 27 |
int smb2_check_message(char *buf, unsigned int pdu_len, unsigned int len, |
| 28 |
struct TCP_Server_Info *server); |
| 29 |
unsigned int smb2_calc_size(void *buf); |
| 30 |
char *smb2_get_data_area_len(int *off, int *len, struct smb2_hdr *shdr); |
| 31 |
__le16 *cifs_convert_path_to_utf16(const char *from, |
| 32 |
struct cifs_sb_info *cifs_sb); |
| 33 |
|
| 34 |
int smb2_verify_signature(struct smb_rqst *rqst, |
| 35 |
struct TCP_Server_Info *server); |
| 36 |
int smb2_check_receive(struct mid_q_entry *mid, struct TCP_Server_Info *server, |
| 37 |
bool log_error); |
| 38 |
struct mid_q_entry *smb2_setup_request(struct cifs_ses *ses, |
| 39 |
struct TCP_Server_Info *server, |
| 40 |
struct smb_rqst *rqst); |
| 41 |
struct mid_q_entry *smb2_setup_async_request(struct TCP_Server_Info *server, |
| 42 |
struct smb_rqst *rqst); |
| 43 |
struct cifs_tcon *smb2_find_smb_tcon(struct TCP_Server_Info *server, |
| 44 |
__u64 ses_id, __u32 tid); |
| 45 |
__le32 smb2_get_lease_state(struct cifsInodeInfo *cinode, unsigned int oplock); |
| 46 |
bool smb2_is_valid_oplock_break(char *buffer, struct TCP_Server_Info *server); |
| 47 |
int smb3_handle_read_data(struct TCP_Server_Info *server, |
| 48 |
struct mid_q_entry *mid); |
| 49 |
struct inode *smb2_create_reparse_inode(struct cifs_open_info_data *data, |
| 50 |
struct super_block *sb, |
| 51 |
const unsigned int xid, |
| 52 |
struct cifs_tcon *tcon, |
| 53 |
const char *full_path, bool directory, |
| 54 |
struct kvec *reparse_iov, |
| 55 |
struct kvec *xattr_iov); |
| 56 |
int smb2_query_reparse_point(const unsigned int xid, struct cifs_tcon *tcon, |
| 57 |
struct cifs_sb_info *cifs_sb, |
| 58 |
const char *full_path, u32 *tag, struct kvec *rsp, |
| 59 |
int *rsp_buftype); |
| 60 |
int smb2_query_path_info(const unsigned int xid, struct cifs_tcon *tcon, |
| 61 |
struct cifs_sb_info *cifs_sb, const char *full_path, |
| 62 |
struct cifs_open_info_data *data); |
| 63 |
int smb2_set_path_size(const unsigned int xid, struct cifs_tcon *tcon, |
| 64 |
const char *full_path, __u64 size, |
| 65 |
struct cifs_sb_info *cifs_sb, bool set_alloc, |
| 66 |
struct dentry *dentry); |
| 67 |
int smb2_set_file_info(struct inode *inode, const char *full_path, |
| 68 |
FILE_BASIC_INFO *buf, const unsigned int xid); |
| 69 |
int smb311_posix_mkdir(const unsigned int xid, struct inode *inode, |
| 70 |
umode_t mode, struct cifs_tcon *tcon, |
| 71 |
const char *full_path, struct cifs_sb_info *cifs_sb); |
| 72 |
int smb2_mkdir(const unsigned int xid, struct inode *parent_inode, |
| 73 |
umode_t mode, struct cifs_tcon *tcon, const char *name, |
| 74 |
struct cifs_sb_info *cifs_sb); |
| 75 |
void smb2_mkdir_setinfo(struct inode *inode, const char *name, |
| 76 |
struct cifs_sb_info *cifs_sb, struct cifs_tcon *tcon, |
| 77 |
const unsigned int xid); |
| 78 |
int smb2_rmdir(const unsigned int xid, struct cifs_tcon *tcon, |
| 79 |
const char *name, struct cifs_sb_info *cifs_sb); |
| 80 |
int smb2_unlink(const unsigned int xid, struct cifs_tcon *tcon, |
| 81 |
const char *name, struct cifs_sb_info *cifs_sb, |
| 82 |
struct dentry *dentry); |
| 83 |
int smb2_rename_path(const unsigned int xid, struct cifs_tcon *tcon, |
| 84 |
struct dentry *source_dentry, const char *from_name, |
| 85 |
const char *to_name, struct cifs_sb_info *cifs_sb); |
| 86 |
int smb2_create_hardlink(const unsigned int xid, struct cifs_tcon *tcon, |
| 87 |
struct dentry *source_dentry, const char *from_name, |
| 88 |
const char *to_name, struct cifs_sb_info *cifs_sb); |
| 89 |
int smb3_create_mf_symlink(unsigned int xid, struct cifs_tcon *tcon, |
| 90 |
struct cifs_sb_info *cifs_sb, |
| 91 |
const unsigned char *path, char *pbuf, |
| 92 |
unsigned int *pbytes_written); |
| 93 |
int smb3_query_mf_symlink(unsigned int xid, struct cifs_tcon *tcon, |
| 94 |
struct cifs_sb_info *cifs_sb, |
| 95 |
const unsigned char *path, char *pbuf, |
| 96 |
unsigned int *pbytes_read); |
| 97 |
int smb2_fix_symlink_target_type(char **target, bool directory, |
| 98 |
struct cifs_sb_info *cifs_sb); |
| 99 |
int smb2_parse_native_symlink(char **target, const char *buf, unsigned int len, |
| 100 |
bool relative, const char *full_path, |
| 101 |
struct cifs_sb_info *cifs_sb); |
| 102 |
int smb2_parse_symlink_response(struct cifs_sb_info *cifs_sb, |
| 103 |
const struct kvec *iov, const char *full_path, |
| 104 |
char **path); |
| 105 |
int smb2_open_file(const unsigned int xid, struct cifs_open_parms *oparms, |
| 106 |
__u32 *oplock, void *buf); |
| 107 |
int smb2_unlock_range(struct cifsFileInfo *cfile, struct file_lock *flock, |
| 108 |
const unsigned int xid); |
| 109 |
int smb2_push_mandatory_locks(struct cifsFileInfo *cfile); |
| 110 |
void smb2_reconnect_server(struct work_struct *work); |
| 111 |
int smb3_crypto_aead_allocate(struct TCP_Server_Info *server); |
| 112 |
unsigned long smb_rqst_len(struct TCP_Server_Info *server, |
| 113 |
struct smb_rqst *rqst); |
| 114 |
void smb2_set_next_command(struct cifs_tcon *tcon, struct smb_rqst *rqst); |
| 115 |
void smb2_set_related(struct smb_rqst *rqst); |
| 116 |
void smb2_set_replay(struct TCP_Server_Info *server, struct smb_rqst *rqst); |
| 117 |
bool smb2_should_replay(struct cifs_tcon *tcon, int *pretries, |
| 118 |
int *pcur_sleep); |
| 119 |
|
| 120 |
/* |
| 121 |
* SMB2 Worker functions - most of protocol specific implementation details |
| 122 |
* are contained within these calls. |
| 123 |
*/ |
| 124 |
int SMB2_negotiate(const unsigned int xid, struct cifs_ses *ses, |
| 125 |
struct TCP_Server_Info *server); |
| 126 |
int SMB2_sess_setup(const unsigned int xid, struct cifs_ses *ses, |
| 127 |
struct TCP_Server_Info *server, |
| 128 |
const struct nls_table *nls_cp); |
| 129 |
int SMB2_logoff(const unsigned int xid, struct cifs_ses *ses); |
| 130 |
int SMB2_tcon(const unsigned int xid, struct cifs_ses *ses, const char *tree, |
| 131 |
struct cifs_tcon *tcon, const struct nls_table *cp); |
| 132 |
int SMB2_tdis(const unsigned int xid, struct cifs_tcon *tcon); |
| 133 |
int SMB2_open(const unsigned int xid, struct cifs_open_parms *oparms, |
| 134 |
__le16 *path, __u8 *oplock, struct smb2_file_all_info *buf, |
| 135 |
struct create_posix_rsp *posix, struct kvec *err_iov, |
| 136 |
int *buftype); |
| 137 |
int SMB2_open_init(struct cifs_tcon *tcon, struct TCP_Server_Info *server, |
| 138 |
struct smb_rqst *rqst, __u8 *oplock, |
| 139 |
struct cifs_open_parms *oparms, __le16 *path); |
| 140 |
void SMB2_open_free(struct smb_rqst *rqst); |
| 141 |
int SMB2_ioctl(const unsigned int xid, struct cifs_tcon *tcon, |
| 142 |
u64 persistent_fid, u64 volatile_fid, u32 opcode, char *in_data, |
| 143 |
u32 indatalen, u32 max_out_data_len, char **out_data, |
| 144 |
u32 *plen /* returned data len */); |
| 145 |
int SMB2_ioctl_init(struct cifs_tcon *tcon, struct TCP_Server_Info *server, |
| 146 |
struct smb_rqst *rqst, u64 persistent_fid, |
| 147 |
u64 volatile_fid, u32 opcode, char *in_data, u32 indatalen, |
| 148 |
__u32 max_response_size); |
| 149 |
void SMB2_ioctl_free(struct smb_rqst *rqst); |
| 150 |
int SMB2_change_notify(const unsigned int xid, struct cifs_tcon *tcon, |
| 151 |
u64 persistent_fid, u64 volatile_fid, bool watch_tree, |
| 152 |
u32 completion_filter, u32 max_out_data_len, |
| 153 |
char **out_data, u32 *plen /* returned data len */); |
| 154 |
|
| 155 |
int __SMB2_close(const unsigned int xid, struct cifs_tcon *tcon, |
| 156 |
u64 persistent_fid, u64 volatile_fid, |
| 157 |
struct smb2_file_network_open_info *pbuf); |
| 158 |
int SMB2_close(const unsigned int xid, struct cifs_tcon *tcon, |
| 159 |
u64 persistent_fid, u64 volatile_fid); |
| 160 |
int SMB2_close_init(struct cifs_tcon *tcon, struct TCP_Server_Info *server, |
| 161 |
struct smb_rqst *rqst, u64 persistent_fid, |
| 162 |
u64 volatile_fid, bool query_attrs); |
| 163 |
void SMB2_close_free(struct smb_rqst *rqst); |
| 164 |
int SMB2_flush(const unsigned int xid, struct cifs_tcon *tcon, |
| 165 |
u64 persistent_fid, u64 volatile_fid); |
| 166 |
int SMB2_flush_init(const unsigned int xid, struct smb_rqst *rqst, |
| 167 |
struct cifs_tcon *tcon, struct TCP_Server_Info *server, |
| 168 |
u64 persistent_fid, u64 volatile_fid); |
| 169 |
void SMB2_flush_free(struct smb_rqst *rqst); |
| 170 |
int SMB2_query_info(const unsigned int xid, struct cifs_tcon *tcon, |
| 171 |
u64 persistent_fid, u64 volatile_fid, |
| 172 |
struct smb2_file_all_info *data); |
| 173 |
int SMB2_query_info_init(struct cifs_tcon *tcon, |
| 174 |
struct TCP_Server_Info *server, struct smb_rqst *rqst, |
| 175 |
u64 persistent_fid, u64 volatile_fid, u8 info_class, |
| 176 |
u8 info_type, u32 additional_info, size_t output_len, |
| 177 |
size_t input_len, void *input); |
| 178 |
void SMB2_query_info_free(struct smb_rqst *rqst); |
| 179 |
int SMB2_query_acl(const unsigned int xid, struct cifs_tcon *tcon, |
| 180 |
u64 persistent_fid, u64 volatile_fid, void **data, |
| 181 |
u32 *plen, u32 extra_info); |
| 182 |
int SMB2_get_srv_num(const unsigned int xid, struct cifs_tcon *tcon, |
| 183 |
u64 persistent_fid, u64 volatile_fid, __le64 *uniqueid); |
| 184 |
int smb2_async_readv(struct cifs_io_subrequest *rdata); |
| 185 |
int SMB2_read(const unsigned int xid, struct cifs_io_parms *io_parms, |
| 186 |
unsigned int *nbytes, char **buf, int *buf_type); |
| 187 |
void smb2_async_writev(struct cifs_io_subrequest *wdata); |
| 188 |
int SMB2_write(const unsigned int xid, struct cifs_io_parms *io_parms, |
| 189 |
unsigned int *nbytes, struct kvec *iov, int n_vec); |
| 190 |
int SMB2_echo(struct TCP_Server_Info *server); |
| 191 |
int SMB2_query_directory(const unsigned int xid, struct cifs_tcon *tcon, |
| 192 |
u64 persistent_fid, u64 volatile_fid, int index, |
| 193 |
struct cifs_search_info *srch_inf); |
| 194 |
int SMB2_query_directory_init(const unsigned int xid, struct cifs_tcon *tcon, |
| 195 |
struct TCP_Server_Info *server, |
| 196 |
struct smb_rqst *rqst, u64 persistent_fid, |
| 197 |
u64 volatile_fid, int index, int info_level); |
| 198 |
void SMB2_query_directory_free(struct smb_rqst *rqst); |
| 199 |
int SMB2_set_eof(const unsigned int xid, struct cifs_tcon *tcon, |
| 200 |
u64 persistent_fid, u64 volatile_fid, u32 pid, |
| 201 |
loff_t new_eof); |
| 202 |
int SMB2_set_info_init(struct cifs_tcon *tcon, struct TCP_Server_Info *server, |
| 203 |
struct smb_rqst *rqst, u64 persistent_fid, |
| 204 |
u64 volatile_fid, u32 pid, u8 info_class, u8 info_type, |
| 205 |
u32 additional_info, void **data, unsigned int *size); |
| 206 |
void SMB2_set_info_free(struct smb_rqst *rqst); |
| 207 |
int SMB2_set_acl(const unsigned int xid, struct cifs_tcon *tcon, |
| 208 |
u64 persistent_fid, u64 volatile_fid, struct smb_ntsd *pnntsd, |
| 209 |
int pacllen, int aclflag); |
| 210 |
int SMB2_set_ea(const unsigned int xid, struct cifs_tcon *tcon, |
| 211 |
u64 persistent_fid, u64 volatile_fid, |
| 212 |
struct smb2_file_full_ea_info *buf, int len); |
| 213 |
int SMB2_set_compression(const unsigned int xid, struct cifs_tcon *tcon, |
| 214 |
u64 persistent_fid, u64 volatile_fid); |
| 215 |
int SMB2_oplock_break(const unsigned int xid, struct cifs_tcon *tcon, |
| 216 |
const u64 persistent_fid, const u64 volatile_fid, |
| 217 |
__u8 oplock_level); |
| 218 |
int smb2_handle_cancelled_close(struct cifs_tcon *tcon, __u64 persistent_fid, |
| 219 |
__u64 volatile_fid); |
| 220 |
int smb2_handle_cancelled_mid(struct mid_q_entry *mid, |
| 221 |
struct TCP_Server_Info *server); |
| 222 |
void smb2_cancelled_close_fid(struct work_struct *work); |
| 223 |
int SMB311_posix_qfs_info(const unsigned int xid, struct cifs_tcon *tcon, |
| 224 |
u64 persistent_fid, u64 volatile_fid, |
| 225 |
struct kstatfs *fsdata); |
| 226 |
int SMB2_QFS_attr(const unsigned int xid, struct cifs_tcon *tcon, |
| 227 |
u64 persistent_fid, u64 volatile_fid, int level); |
| 228 |
int SMB2_lock(const unsigned int xid, struct cifs_tcon *tcon, |
| 229 |
const __u64 persist_fid, const __u64 volatile_fid, |
| 230 |
const __u32 pid, const __u64 length, const __u64 offset, |
| 231 |
const __u32 lock_flags, const bool wait); |
| 232 |
int smb2_lockv(const unsigned int xid, struct cifs_tcon *tcon, |
| 233 |
const __u64 persist_fid, const __u64 volatile_fid, |
| 234 |
const __u32 pid, const __u32 num_lock, |
| 235 |
struct smb2_lock_element *buf); |
| 236 |
int SMB2_lease_break(const unsigned int xid, struct cifs_tcon *tcon, |
| 237 |
__u8 *lease_key, const __le32 lease_state); |
| 238 |
int smb3_validate_negotiate(const unsigned int xid, struct cifs_tcon *tcon); |
| 239 |
|
| 240 |
enum securityEnum smb2_select_sectype(struct TCP_Server_Info *server, |
| 241 |
enum securityEnum requested); |
| 242 |
int smb2_parse_contexts(struct TCP_Server_Info *server, struct kvec *rsp_iov, |
| 243 |
__u16 *epoch, char *lease_key, __u8 *oplock, |
| 244 |
struct smb2_file_all_info *buf, |
| 245 |
struct create_posix_rsp *posix); |
| 246 |
|
| 247 |
int smb3_encryption_required(const struct cifs_tcon *tcon); |
| 248 |
int smb2_validate_iov(unsigned int offset, unsigned int buffer_length, |
| 249 |
struct kvec *iov, unsigned int min_buf_size); |
| 250 |
int smb2_validate_and_copy_iov(unsigned int offset, unsigned int buffer_length, |
| 251 |
struct kvec *iov, unsigned int minbufsize, |
| 252 |
char *data); |
| 253 |
void smb2_copy_fs_info_to_kstatfs(struct smb2_fs_full_size_info *pfs_inf, |
| 254 |
struct kstatfs *kst); |
| 255 |
int smb3_crypto_shash_allocate(struct TCP_Server_Info *server); |
| 256 |
void smb311_update_preauth_hash(struct cifs_ses *ses, |
| 257 |
struct TCP_Server_Info *server, |
| 258 |
struct kvec *iov, int nvec); |
| 259 |
int smb2_query_info_compound(const unsigned int xid, struct cifs_tcon *tcon, |
| 260 |
const char *path, u32 desired_access, u32 class, |
| 261 |
u32 type, u32 output_len, struct kvec *rsp, |
| 262 |
int *buftype, struct cifs_sb_info *cifs_sb); |
| 263 |
/* query path info from the server using SMB311 POSIX extensions*/ |
| 264 |
int posix_info_parse(const void *beg, const void *end, |
| 265 |
struct smb2_posix_info_parsed *out); |
| 266 |
int posix_info_sid_size(const void *beg, const void *end); |
| 267 |
int smb2_rename_pending_delete(const char *full_path, struct dentry *dentry, |
| 268 |
const unsigned int xid); |
| 269 |
|
| 270 |
#endif /* _SMB2PROTO_H */ |