Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: LGPL-2.1 */
0002 /*
0003  *
0004  *   Copyright (c) International Business Machines  Corp., 2002, 2011
0005  *                 Etersoft, 2012
0006  *   Author(s): Steve French (sfrench@us.ibm.com)
0007  *              Pavel Shilovsky (pshilovsky@samba.org) 2012
0008  *
0009  */
0010 #ifndef _SMB2PROTO_H
0011 #define _SMB2PROTO_H
0012 #include <linux/nls.h>
0013 #include <linux/key-type.h>
0014 
0015 struct statfs;
0016 struct smb_rqst;
0017 
0018 /*
0019  *****************************************************************
0020  * All Prototypes
0021  *****************************************************************
0022  */
0023 extern int map_smb2_to_linux_error(char *buf, bool log_err);
0024 extern int smb2_check_message(char *buf, unsigned int length,
0025                   struct TCP_Server_Info *server);
0026 extern unsigned int smb2_calc_size(void *buf);
0027 extern char *smb2_get_data_area_len(int *off, int *len,
0028                     struct smb2_hdr *shdr);
0029 extern __le16 *cifs_convert_path_to_utf16(const char *from,
0030                       struct cifs_sb_info *cifs_sb);
0031 
0032 extern int smb2_verify_signature(struct smb_rqst *, struct TCP_Server_Info *);
0033 extern int smb2_check_receive(struct mid_q_entry *mid,
0034                   struct TCP_Server_Info *server, bool log_error);
0035 extern struct mid_q_entry *smb2_setup_request(struct cifs_ses *ses,
0036                           struct TCP_Server_Info *,
0037                           struct smb_rqst *rqst);
0038 extern struct mid_q_entry *smb2_setup_async_request(
0039             struct TCP_Server_Info *server, struct smb_rqst *rqst);
0040 extern struct cifs_ses *smb2_find_smb_ses(struct TCP_Server_Info *server,
0041                        __u64 ses_id);
0042 extern struct cifs_tcon *smb2_find_smb_tcon(struct TCP_Server_Info *server,
0043                         __u64 ses_id, __u32  tid);
0044 extern int smb2_calc_signature(struct smb_rqst *rqst,
0045                 struct TCP_Server_Info *server,
0046                 bool allocate_crypto);
0047 extern int smb3_calc_signature(struct smb_rqst *rqst,
0048                 struct TCP_Server_Info *server,
0049                 bool allocate_crypto);
0050 extern void smb2_echo_request(struct work_struct *work);
0051 extern __le32 smb2_get_lease_state(struct cifsInodeInfo *cinode);
0052 extern bool smb2_is_valid_oplock_break(char *buffer,
0053                        struct TCP_Server_Info *srv);
0054 extern int smb3_handle_read_data(struct TCP_Server_Info *server,
0055                  struct mid_q_entry *mid);
0056 
0057 extern void move_smb2_info_to_cifs(FILE_ALL_INFO *dst,
0058                    struct smb2_file_all_info *src);
0059 extern int smb2_query_reparse_tag(const unsigned int xid, struct cifs_tcon *tcon,
0060                 struct cifs_sb_info *cifs_sb, const char *path,
0061                 __u32 *reparse_tag);
0062 extern int smb2_query_path_info(const unsigned int xid, struct cifs_tcon *tcon,
0063                 struct cifs_sb_info *cifs_sb,
0064                 const char *full_path, FILE_ALL_INFO *data,
0065                 bool *adjust_tz, bool *symlink);
0066 extern int smb2_set_path_size(const unsigned int xid, struct cifs_tcon *tcon,
0067                   const char *full_path, __u64 size,
0068                   struct cifs_sb_info *cifs_sb, bool set_alloc);
0069 extern int smb2_set_file_info(struct inode *inode, const char *full_path,
0070                   FILE_BASIC_INFO *buf, const unsigned int xid);
0071 extern int smb311_posix_mkdir(const unsigned int xid, struct inode *inode,
0072                    umode_t mode, struct cifs_tcon *tcon,
0073                    const char *full_path,
0074                    struct cifs_sb_info *cifs_sb);
0075 extern int smb2_mkdir(const unsigned int xid, struct inode *inode,
0076               umode_t mode, struct cifs_tcon *tcon,
0077               const char *name, struct cifs_sb_info *cifs_sb);
0078 extern void smb2_mkdir_setinfo(struct inode *inode, const char *full_path,
0079                    struct cifs_sb_info *cifs_sb,
0080                    struct cifs_tcon *tcon, const unsigned int xid);
0081 extern int smb2_rmdir(const unsigned int xid, struct cifs_tcon *tcon,
0082               const char *name, struct cifs_sb_info *cifs_sb);
0083 extern int smb2_unlink(const unsigned int xid, struct cifs_tcon *tcon,
0084                const char *name, struct cifs_sb_info *cifs_sb);
0085 extern int smb2_rename_path(const unsigned int xid, struct cifs_tcon *tcon,
0086                 const char *from_name, const char *to_name,
0087                 struct cifs_sb_info *cifs_sb);
0088 extern int smb2_create_hardlink(const unsigned int xid, struct cifs_tcon *tcon,
0089                 const char *from_name, const char *to_name,
0090                 struct cifs_sb_info *cifs_sb);
0091 extern int smb3_create_mf_symlink(unsigned int xid, struct cifs_tcon *tcon,
0092             struct cifs_sb_info *cifs_sb, const unsigned char *path,
0093             char *pbuf, unsigned int *pbytes_written);
0094 extern int smb3_query_mf_symlink(unsigned int xid, struct cifs_tcon *tcon,
0095               struct cifs_sb_info *cifs_sb,
0096               const unsigned char *path, char *pbuf,
0097               unsigned int *pbytes_read);
0098 extern int smb2_open_file(const unsigned int xid,
0099               struct cifs_open_parms *oparms,
0100               __u32 *oplock, FILE_ALL_INFO *buf);
0101 extern int smb2_unlock_range(struct cifsFileInfo *cfile,
0102                  struct file_lock *flock, const unsigned int xid);
0103 extern int smb2_push_mandatory_locks(struct cifsFileInfo *cfile);
0104 extern void smb2_reconnect_server(struct work_struct *work);
0105 extern int smb3_crypto_aead_allocate(struct TCP_Server_Info *server);
0106 extern unsigned long smb_rqst_len(struct TCP_Server_Info *server,
0107                   struct smb_rqst *rqst);
0108 extern void smb2_set_next_command(struct cifs_tcon *tcon,
0109                   struct smb_rqst *rqst);
0110 extern void smb2_set_related(struct smb_rqst *rqst);
0111 
0112 /*
0113  * SMB2 Worker functions - most of protocol specific implementation details
0114  * are contained within these calls.
0115  */
0116 extern int SMB2_negotiate(const unsigned int xid,
0117               struct cifs_ses *ses,
0118               struct TCP_Server_Info *server);
0119 extern int SMB2_sess_setup(const unsigned int xid, struct cifs_ses *ses,
0120                struct TCP_Server_Info *server,
0121                const struct nls_table *nls_cp);
0122 extern int SMB2_logoff(const unsigned int xid, struct cifs_ses *ses);
0123 extern int SMB2_tcon(const unsigned int xid, struct cifs_ses *ses,
0124              const char *tree, struct cifs_tcon *tcon,
0125              const struct nls_table *);
0126 extern int SMB2_tdis(const unsigned int xid, struct cifs_tcon *tcon);
0127 extern int SMB2_open(const unsigned int xid, struct cifs_open_parms *oparms,
0128              __le16 *path, __u8 *oplock,
0129              struct smb2_file_all_info *buf,
0130              struct create_posix_rsp *posix,
0131              struct kvec *err_iov, int *resp_buftype);
0132 extern int SMB2_open_init(struct cifs_tcon *tcon,
0133               struct TCP_Server_Info *server,
0134               struct smb_rqst *rqst,
0135               __u8 *oplock, struct cifs_open_parms *oparms,
0136               __le16 *path);
0137 extern void SMB2_open_free(struct smb_rqst *rqst);
0138 extern int SMB2_ioctl(const unsigned int xid, struct cifs_tcon *tcon,
0139              u64 persistent_fid, u64 volatile_fid, u32 opcode,
0140              char *in_data, u32 indatalen, u32 maxoutlen,
0141              char **out_data, u32 *plen /* returned data len */);
0142 extern int SMB2_ioctl_init(struct cifs_tcon *tcon,
0143                struct TCP_Server_Info *server,
0144                struct smb_rqst *rqst,
0145                u64 persistent_fid, u64 volatile_fid, u32 opcode,
0146                char *in_data, u32 indatalen,
0147                __u32 max_response_size);
0148 extern void SMB2_ioctl_free(struct smb_rqst *rqst);
0149 extern int SMB2_change_notify(const unsigned int xid, struct cifs_tcon *tcon,
0150             u64 persistent_fid, u64 volatile_fid, bool watch_tree,
0151             u32 completion_filter);
0152 
0153 extern int __SMB2_close(const unsigned int xid, struct cifs_tcon *tcon,
0154             u64 persistent_fid, u64 volatile_fid,
0155             struct smb2_file_network_open_info *pbuf);
0156 extern int SMB2_close(const unsigned int xid, struct cifs_tcon *tcon,
0157               u64 persistent_file_id, u64 volatile_file_id);
0158 extern int SMB2_close_init(struct cifs_tcon *tcon,
0159                struct TCP_Server_Info *server,
0160                struct smb_rqst *rqst,
0161                u64 persistent_fid, u64 volatile_fid,
0162                bool query_attrs);
0163 extern void SMB2_close_free(struct smb_rqst *rqst);
0164 extern int SMB2_flush(const unsigned int xid, struct cifs_tcon *tcon,
0165               u64 persistent_file_id, u64 volatile_file_id);
0166 extern int SMB2_flush_init(const unsigned int xid, struct smb_rqst *rqst,
0167                struct cifs_tcon *tcon,
0168                struct TCP_Server_Info *server,
0169                u64 persistent_file_id, u64 volatile_file_id);
0170 extern void SMB2_flush_free(struct smb_rqst *rqst);
0171 extern int SMB311_posix_query_info(const unsigned int xid, struct cifs_tcon *tcon,
0172         u64 persistent_fid, u64 volatile_fid, struct smb311_posix_qinfo *data, u32 *plen);
0173 extern int SMB2_query_info(const unsigned int xid, struct cifs_tcon *tcon,
0174                u64 persistent_file_id, u64 volatile_file_id,
0175                struct smb2_file_all_info *data);
0176 extern int SMB2_query_info_init(struct cifs_tcon *tcon,
0177                 struct TCP_Server_Info *server,
0178                 struct smb_rqst *rqst,
0179                 u64 persistent_fid, u64 volatile_fid,
0180                 u8 info_class, u8 info_type,
0181                 u32 additional_info, size_t output_len,
0182                 size_t input_len, void *input);
0183 extern void SMB2_query_info_free(struct smb_rqst *rqst);
0184 extern int SMB2_query_acl(const unsigned int xid, struct cifs_tcon *tcon,
0185               u64 persistent_file_id, u64 volatile_file_id,
0186               void **data, unsigned int *plen, u32 info);
0187 extern int SMB2_get_srv_num(const unsigned int xid, struct cifs_tcon *tcon,
0188                 u64 persistent_fid, u64 volatile_fid,
0189                 __le64 *uniqueid);
0190 extern int smb2_async_readv(struct cifs_readdata *rdata);
0191 extern int SMB2_read(const unsigned int xid, struct cifs_io_parms *io_parms,
0192              unsigned int *nbytes, char **buf, int *buf_type);
0193 extern int smb2_async_writev(struct cifs_writedata *wdata,
0194                  void (*release)(struct kref *kref));
0195 extern int SMB2_write(const unsigned int xid, struct cifs_io_parms *io_parms,
0196               unsigned int *nbytes, struct kvec *iov, int n_vec);
0197 extern int SMB2_echo(struct TCP_Server_Info *server);
0198 extern int SMB2_query_directory(const unsigned int xid, struct cifs_tcon *tcon,
0199                 u64 persistent_fid, u64 volatile_fid, int index,
0200                 struct cifs_search_info *srch_inf);
0201 extern int SMB2_query_directory_init(unsigned int xid, struct cifs_tcon *tcon,
0202                      struct TCP_Server_Info *server,
0203                      struct smb_rqst *rqst,
0204                      u64 persistent_fid, u64 volatile_fid,
0205                      int index, int info_level);
0206 extern void SMB2_query_directory_free(struct smb_rqst *rqst);
0207 extern int SMB2_set_eof(const unsigned int xid, struct cifs_tcon *tcon,
0208             u64 persistent_fid, u64 volatile_fid, u32 pid,
0209             __le64 *eof);
0210 extern int SMB2_set_info_init(struct cifs_tcon *tcon,
0211                   struct TCP_Server_Info *server,
0212                   struct smb_rqst *rqst,
0213                   u64 persistent_fid, u64 volatile_fid, u32 pid,
0214                   u8 info_class, u8 info_type, u32 additional_info,
0215                   void **data, unsigned int *size);
0216 extern void SMB2_set_info_free(struct smb_rqst *rqst);
0217 extern int SMB2_set_acl(const unsigned int xid, struct cifs_tcon *tcon,
0218             u64 persistent_fid, u64 volatile_fid,
0219             struct cifs_ntsd *pnntsd, int pacllen, int aclflag);
0220 extern int SMB2_set_ea(const unsigned int xid, struct cifs_tcon *tcon,
0221                u64 persistent_fid, u64 volatile_fid,
0222                struct smb2_file_full_ea_info *buf, int len);
0223 extern int SMB2_set_compression(const unsigned int xid, struct cifs_tcon *tcon,
0224                 u64 persistent_fid, u64 volatile_fid);
0225 extern int SMB2_oplock_break(const unsigned int xid, struct cifs_tcon *tcon,
0226                  const u64 persistent_fid, const u64 volatile_fid,
0227                  const __u8 oplock_level);
0228 extern int smb2_handle_cancelled_close(struct cifs_tcon *tcon,
0229                        __u64 persistent_fid,
0230                        __u64 volatile_fid);
0231 extern int smb2_handle_cancelled_mid(struct mid_q_entry *mid, struct TCP_Server_Info *server);
0232 void smb2_cancelled_close_fid(struct work_struct *work);
0233 extern int SMB2_QFS_info(const unsigned int xid, struct cifs_tcon *tcon,
0234              u64 persistent_file_id, u64 volatile_file_id,
0235              struct kstatfs *FSData);
0236 extern int SMB311_posix_qfs_info(const unsigned int xid, struct cifs_tcon *tcon,
0237              u64 persistent_file_id, u64 volatile_file_id,
0238              struct kstatfs *FSData);
0239 extern int SMB2_QFS_attr(const unsigned int xid, struct cifs_tcon *tcon,
0240              u64 persistent_file_id, u64 volatile_file_id, int lvl);
0241 extern int SMB2_lock(const unsigned int xid, struct cifs_tcon *tcon,
0242              const __u64 persist_fid, const __u64 volatile_fid,
0243              const __u32 pid, const __u64 length, const __u64 offset,
0244              const __u32 lockFlags, const bool wait);
0245 extern int smb2_lockv(const unsigned int xid, struct cifs_tcon *tcon,
0246               const __u64 persist_fid, const __u64 volatile_fid,
0247               const __u32 pid, const __u32 num_lock,
0248               struct smb2_lock_element *buf);
0249 extern int SMB2_lease_break(const unsigned int xid, struct cifs_tcon *tcon,
0250                 __u8 *lease_key, const __le32 lease_state);
0251 extern int smb3_validate_negotiate(const unsigned int, struct cifs_tcon *);
0252 
0253 extern enum securityEnum smb2_select_sectype(struct TCP_Server_Info *,
0254                     enum securityEnum);
0255 extern void smb2_parse_contexts(struct TCP_Server_Info *server,
0256                 struct smb2_create_rsp *rsp,
0257                 unsigned int *epoch, char *lease_key,
0258                 __u8 *oplock, struct smb2_file_all_info *buf,
0259                 struct create_posix_rsp *posix);
0260 extern int smb3_encryption_required(const struct cifs_tcon *tcon);
0261 extern int smb2_validate_iov(unsigned int offset, unsigned int buffer_length,
0262                  struct kvec *iov, unsigned int min_buf_size);
0263 extern int smb2_validate_and_copy_iov(unsigned int offset,
0264                       unsigned int buffer_length,
0265                       struct kvec *iov,
0266                       unsigned int minbufsize, char *data);
0267 extern void smb2_copy_fs_info_to_kstatfs(
0268      struct smb2_fs_full_size_info *pfs_inf,
0269      struct kstatfs *kst);
0270 extern int smb311_crypto_shash_allocate(struct TCP_Server_Info *server);
0271 extern int smb311_update_preauth_hash(struct cifs_ses *ses,
0272                       struct TCP_Server_Info *server,
0273                       struct kvec *iov, int nvec);
0274 extern int smb2_query_info_compound(const unsigned int xid,
0275                     struct cifs_tcon *tcon,
0276                     const char *path, u32 desired_access,
0277                     u32 class, u32 type, u32 output_len,
0278                     struct kvec *rsp, int *buftype,
0279                     struct cifs_sb_info *cifs_sb);
0280 /* query path info from the server using SMB311 POSIX extensions*/
0281 extern int smb311_posix_query_path_info(const unsigned int xid, struct cifs_tcon *tcon,
0282             struct cifs_sb_info *sb, const char *path, struct smb311_posix_qinfo *qinf,
0283             bool *adjust_tx, bool *symlink);
0284 int posix_info_parse(const void *beg, const void *end,
0285              struct smb2_posix_info_parsed *out);
0286 int posix_info_sid_size(const void *beg, const void *end);
0287 #endif          /* _SMB2PROTO_H */