aboutsummaryrefslogtreecommitdiff
path: root/fs/smb/client/smb2proto.h
blob: c7759e37d975f11f7d9693a06600f7cf25307ffa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
/* SPDX-License-Identifier: LGPL-2.1 */
/*
 *
 *   Copyright (c) International Business Machines  Corp., 2002, 2011
 *                 Etersoft, 2012
 *   Author(s): Steve French (sfrench@us.ibm.com)
 *              Pavel Shilovsky (pshilovsky@samba.org) 2012
 *
 */
#ifndef _SMB2PROTO_H
#define _SMB2PROTO_H

#include <linux/nls.h>
#include <linux/key-type.h>
#include "cached_dir.h"

struct statfs;
struct smb_rqst;

/*
 *****************************************************************
 * All Prototypes
 *****************************************************************
 */
int map_smb2_to_linux_error(char *buf, bool log_err);
int smb2_init_maperror(void);
int smb2_check_message(char *buf, unsigned int pdu_len, unsigned int len,
		       struct TCP_Server_Info *server);
unsigned int smb2_calc_size(void *buf);
char *smb2_get_data_area_len(int *off, int *len, struct smb2_hdr *shdr);
__le16 *cifs_convert_path_to_utf16(const char *from,
				   struct cifs_sb_info *cifs_sb);

int smb2_verify_signature(struct smb_rqst *rqst,
			  struct TCP_Server_Info *server);
int smb2_check_receive(struct mid_q_entry *mid, struct TCP_Server_Info *server,
		       bool log_error);
struct mid_q_entry *smb2_setup_request(struct cifs_ses *ses,
				       struct TCP_Server_Info *server,
				       struct smb_rqst *rqst);
struct mid_q_entry *smb2_setup_async_request(struct TCP_Server_Info *server,
					     struct smb_rqst *rqst);
struct cifs_tcon *smb2_find_smb_tcon(struct TCP_Server_Info *server,
				     __u64 ses_id, __u32  tid);
__le32 smb2_get_lease_state(struct cifsInodeInfo *cinode);
bool smb2_is_valid_oplock_break(char *buffer, struct TCP_Server_Info *server);
int smb3_handle_read_data(struct TCP_Server_Info *server,
			  struct mid_q_entry *mid);
struct inode *smb2_create_reparse_inode(struct cifs_open_info_data *data,
					struct super_block *sb,
					const unsigned int xid,
					struct cifs_tcon *tcon,
					const char *full_path, bool directory,
					struct kvec *reparse_iov,
					struct kvec *xattr_iov);
int smb2_query_reparse_point(const unsigned int xid, struct cifs_tcon *tcon,
			     struct cifs_sb_info *cifs_sb,
			     const char *full_path, u32 *tag, struct kvec *rsp,
			     int *rsp_buftype);
int smb2_query_path_info(const unsigned int xid, struct cifs_tcon *tcon,
			 struct cifs_sb_info *cifs_sb, const char *full_path,
			 struct cifs_open_info_data *data);
int smb2_set_path_size(const unsigned int xid, struct cifs_tcon *tcon,
		       const char *full_path, __u64 size,
		       struct cifs_sb_info *cifs_sb, bool set_alloc,
		       struct dentry *dentry);
int smb2_set_file_info(struct inode *inode, const char *full_path,
		       FILE_BASIC_INFO *buf, const unsigned int xid);
int smb311_posix_mkdir(const unsigned int xid, struct inode *inode,
		       umode_t mode, struct cifs_tcon *tcon,
		       const char *full_path, struct cifs_sb_info *cifs_sb);
int smb2_mkdir(const unsigned int xid, struct inode *parent_inode,
	       umode_t mode, struct cifs_tcon *tcon, const char *name,
	       struct cifs_sb_info *cifs_sb);
void smb2_mkdir_setinfo(struct inode *inode, const char *name,
			struct cifs_sb_info *cifs_sb, struct cifs_tcon *tcon,
			const unsigned int xid);
int smb2_rmdir(const unsigned int xid, struct cifs_tcon *tcon,
	       const char *name, struct cifs_sb_info *cifs_sb);
int smb2_unlink(const unsigned int xid, struct cifs_tcon *tcon,
		const char *name, struct cifs_sb_info *cifs_sb,
		struct dentry *dentry);
int smb2_rename_path(const unsigned int xid, struct cifs_tcon *tcon,
		     struct dentry *source_dentry, const char *from_name,
		     const char *to_name, struct cifs_sb_info *cifs_sb);
int smb2_create_hardlink(const unsigned int xid, struct cifs_tcon *tcon,
			 struct dentry *source_dentry, const char *from_name,
			 const char *to_name, struct cifs_sb_info *cifs_sb);
int smb3_create_mf_symlink(unsigned int xid, struct cifs_tcon *tcon,
			   struct cifs_sb_info *cifs_sb,
			   const unsigned char *path, char *pbuf,
			   unsigned int *pbytes_written);
int smb3_query_mf_symlink(unsigned int xid, struct cifs_tcon *tcon,
			  struct cifs_sb_info *cifs_sb,
			  const unsigned char *path, char *pbuf,
			  unsigned int *pbytes_read);
int smb2_fix_symlink_target_type(char **target, bool directory,
				 struct cifs_sb_info *cifs_sb);
int smb2_parse_native_symlink(char **target, const char *buf, unsigned int len,
			      bool relative, const char *full_path,
			      struct cifs_sb_info *cifs_sb);
int smb2_parse_symlink_response(struct cifs_sb_info *cifs_sb,
				const struct kvec *iov, const char *full_path,
				char **path);
int smb2_open_file(const unsigned int xid, struct cifs_open_parms *oparms,
		   __u32 *oplock, void *buf);
int smb2_unlock_range(struct cifsFileInfo *cfile, struct file_lock *flock,
		      const unsigned int xid);
int smb2_push_mandatory_locks(struct cifsFileInfo *cfile);
void smb2_reconnect_server(struct work_struct *work);
int smb3_crypto_aead_allocate(struct TCP_Server_Info *server);
unsigned long smb_rqst_len(struct TCP_Server_Info *server,
			   struct smb_rqst *rqst);
void smb2_set_next_command(struct cifs_tcon *tcon, struct smb_rqst *rqst);
void smb2_set_related(struct smb_rqst *rqst);
void smb2_set_replay(struct TCP_Server_Info *server, struct smb_rqst *rqst);
bool smb2_should_replay(struct cifs_tcon *tcon, int *pretries,
			int *pcur_sleep);

/*
 * SMB2 Worker functions - most of protocol specific implementation details
 * are contained within these calls.
 */
int SMB2_negotiate(const unsigned int xid, struct cifs_ses *ses,
		   struct TCP_Server_Info *server);
int SMB2_sess_setup(const unsigned int xid, struct cifs_ses *ses,
		    struct TCP_Server_Info *server,
		    const struct nls_table *nls_cp);
int SMB2_logoff(const unsigned int xid, struct cifs_ses *ses);
int SMB2_tcon(const unsigned int xid, struct cifs_ses *ses, const char *tree,
	      struct cifs_tcon *tcon, const struct nls_table *cp);
int SMB2_tdis(const unsigned int xid, struct cifs_tcon *tcon);
int SMB2_open(const unsigned int xid, struct cifs_open_parms *oparms,
	      __le16 *path, __u8 *oplock, struct smb2_file_all_info *buf,
	      struct create_posix_rsp *posix, struct kvec *err_iov,
	      int *buftype);
int SMB2_open_init(struct cifs_tcon *tcon, struct TCP_Server_Info *server,
		   struct smb_rqst *rqst, __u8 *oplock,
		   struct cifs_open_parms *oparms, __le16 *path);
void SMB2_open_free(struct smb_rqst *rqst);
int SMB2_ioctl(const unsigned int xid, struct cifs_tcon *tcon,
	       u64 persistent_fid, u64 volatile_fid, u32 opcode, char *in_data,
	       u32 indatalen, u32 max_out_data_len, char **out_data,
	       u32 *plen /* returned data len */);
int SMB2_ioctl_init(struct cifs_tcon *tcon, struct TCP_Server_Info *server,
		    struct smb_rqst *rqst, u64 persistent_fid,
		    u64 volatile_fid, u32 opcode, char *in_data, u32 indatalen,
		    __u32 max_response_size);
void SMB2_ioctl_free(struct smb_rqst *rqst);
int SMB2_change_notify(const unsigned int xid, struct cifs_tcon *tcon,
		       u64 persistent_fid, u64 volatile_fid, bool watch_tree,
		       u32 comple