1 /*
2  * ProFTPD - mod_sftp SFTP
3  * Copyright (c) 2008-2020 TJ Saunders
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
18  *
19  * As a special exemption, TJ Saunders and other respective copyright holders
20  * give permission to link this program with OpenSSL, and distribute the
21  * resulting executable, without including the source code for OpenSSL in the
22  * source distribution.
23  */
24 
25 #ifndef MOD_SFTP_FXP_H
26 #define MOD_SFTP_FXP_H
27 
28 #include "mod_sftp.h"
29 
30 #ifdef HAVE_SYS_STATVFS_H
31 # include <sys/statvfs.h>
32 #endif
33 
34 /* SFTP Packet Types */
35 #define SFTP_SSH2_FXP_INIT		1
36 #define SFTP_SSH2_FXP_VERSION		2
37 #define SFTP_SSH2_FXP_OPEN		3
38 #define SFTP_SSH2_FXP_CLOSE		4
39 #define SFTP_SSH2_FXP_READ		5
40 #define SFTP_SSH2_FXP_WRITE		6
41 #define SFTP_SSH2_FXP_LSTAT		7
42 #define SFTP_SSH2_FXP_FSTAT		8
43 #define SFTP_SSH2_FXP_SETSTAT		9
44 #define SFTP_SSH2_FXP_FSETSTAT		10
45 #define SFTP_SSH2_FXP_OPENDIR		11
46 #define SFTP_SSH2_FXP_READDIR		12
47 #define SFTP_SSH2_FXP_REMOVE		13
48 #define SFTP_SSH2_FXP_MKDIR		14
49 #define SFTP_SSH2_FXP_RMDIR		15
50 #define SFTP_SSH2_FXP_REALPATH		16
51 #define SFTP_SSH2_FXP_STAT		17
52 #define SFTP_SSH2_FXP_RENAME		18
53 #define SFTP_SSH2_FXP_READLINK		19
54 #define SFTP_SSH2_FXP_SYMLINK		20
55 #define SFTP_SSH2_FXP_LINK		21
56 #define SFTP_SSH2_FXP_LOCK		22
57 #define SFTP_SSH2_FXP_UNLOCK		23
58 #define SFTP_SSH2_FXP_STATUS		101
59 #define SFTP_SSH2_FXP_HANDLE		102
60 #define SFTP_SSH2_FXP_DATA		103
61 #define SFTP_SSH2_FXP_NAME		104
62 #define SFTP_SSH2_FXP_ATTRS		105
63 #define SFTP_SSH2_FXP_EXTENDED		200
64 #define SFTP_SSH2_FXP_EXTENDED_REPLY	201
65 
66 /* SFTP Extensions */
67 #define SFTP_FXP_EXT_CHECK_FILE		0x0001
68 #define SFTP_FXP_EXT_COPY_FILE		0x0002
69 #define SFTP_FXP_EXT_VERSION_SELECT	0x0004
70 #define SFTP_FXP_EXT_POSIX_RENAME	0x0008
71 #define SFTP_FXP_EXT_STATVFS		0x0010
72 #define SFTP_FXP_EXT_VENDOR_ID		0x0020
73 #define SFTP_FXP_EXT_SPACE_AVAIL	0x0040
74 #define SFTP_FXP_EXT_FSYNC		0x0080
75 #define SFTP_FXP_EXT_HARDLINK		0x0100
76 #define SFTP_FXP_EXT_XATTR		0x0200
77 
78 #define SFTP_FXP_EXT_DEFAULT \
79   (SFTP_FXP_EXT_CHECK_FILE|SFTP_FXP_EXT_COPY_FILE|SFTP_FXP_EXT_VERSION_SELECT|SFTP_FXP_EXT_POSIX_RENAME|SFTP_FXP_EXT_SPACE_AVAIL|SFTP_FXP_EXT_STATVFS|SFTP_FXP_EXT_FSYNC|SFTP_FXP_EXT_HARDLINK)
80 
81 int sftp_fxp_handle_packet(pool *, void *, uint32_t, unsigned char *, uint32_t);
82 
83 int sftp_fxp_open_session(uint32_t);
84 int sftp_fxp_close_session(uint32_t);
85 
86 int sftp_fxp_set_displaylogin(const char *);
87 int sftp_fxp_set_extensions(unsigned long);
88 
89 int sftp_fxp_set_protocol_version(unsigned int, unsigned int);
90 
91 /* Set the SFTP protocol version at which UTF8 decoding/encoding will be done
92  * on the paths/strings sent to/from the SFTP client.  The default SFTP
93  * protocol version at which this happens, by IETF Draft, is 4.  Some sites
94  * (e.g. Japanese sites) may need the encoding facilities for other SFTP
95  * protocol versions, however.
96  */
97 int sftp_fxp_set_utf8_protocol_version(unsigned int);
98 
99 void sftp_fxp_use_gmt(int);
100 
101 #endif /* MOD_SFTP_FXP_H */
102