Go to the documentation of this file.
31 #ifndef _SFTP_SERVER_H
32 #define _SFTP_SERVER_H
40 #ifndef SFTP_SERVER_SUPPORT
41 #define SFTP_SERVER_SUPPORT DISABLED
42 #elif (SFTP_SERVER_SUPPORT != ENABLED && SFTP_SERVER_SUPPORT != DISABLED)
43 #error SFTP_SERVER_SUPPORT parameter is not valid
47 #ifndef SFTP_SERVER_STACK_SIZE
48 #define SFTP_SERVER_STACK_SIZE 650
49 #elif (SFTP_SERVER_STACK_SIZE < 1)
50 #error SFTP_SERVER_STACK_SIZE parameter is not valid
54 #ifndef SFTP_SERVER_PRIORITY
55 #define SFTP_SERVER_PRIORITY OS_TASK_PRIORITY_NORMAL
59 #ifndef SFTP_SERVER_MAX_SESSIONS
60 #define SFTP_SERVER_MAX_SESSIONS 10
61 #elif (SFTP_SERVER_MAX_SESSIONS < 1)
62 #error SFTP_SERVER_MAX_SESSIONS parameter is not valid
66 #ifndef SFTP_SERVER_TICK_INTERVAL
67 #define SFTP_SERVER_TICK_INTERVAL 1000
68 #elif (SFTP_SERVER_TICK_INTERVAL < 100)
69 #error SFTP_SERVER_TICK_INTERVAL parameter is not valid
73 #ifndef SFTP_SERVER_MIN_VERSION
74 #define SFTP_SERVER_MIN_VERSION 1
75 #elif (SFTP_SERVER_MIN_VERSION < 1)
76 #error SFTP_SERVER_MIN_VERSION parameter is not valid
80 #ifndef SFTP_SERVER_MAX_VERSION
81 #define SFTP_SERVER_MAX_VERSION 3
82 #elif (SFTP_SERVER_MAX_VERSION > 3 || SFTP_SERVER_MAX_VERSION < SFTP_CLIENT_MIN_VERSION)
83 #error SFTP_SERVER_MAX_VERSION parameter is not valid
87 #ifndef SFTP_SERVER_BUFFER_SIZE
88 #define SFTP_SERVER_BUFFER_SIZE 1024
89 #elif (SFTP_SERVER_BUFFER_SIZE < 128)
90 #error SFTP_SERVER_BUFFER_SIZE parameter is not valid
94 #ifndef SFTP_SERVER_MAX_ROOT_DIR_LEN
95 #define SFTP_SERVER_MAX_ROOT_DIR_LEN 63
96 #elif (SFTP_SERVER_MAX_ROOT_DIR_LEN < 7)
97 #error SFTP_SERVER_MAX_ROOT_DIR_LEN parameter is not valid
101 #ifndef SFTP_SERVER_MAX_HOME_DIR_LEN
102 #define SFTP_SERVER_MAX_HOME_DIR_LEN 63
103 #elif (SFTP_SERVER_MAX_HOME_DIR_LEN < 7)
104 #error SFTP_SERVER_MAX_HOME_DIR_LEN parameter is not valid
108 #ifndef SFTP_SERVER_MAX_PATH_LEN
109 #define SFTP_SERVER_MAX_PATH_LEN 255
110 #elif (SFTP_SERVER_MAX_PATH_LEN < 7)
111 #error SFTP_SERVER_MAX_PATH_LEN parameter is not valid
116 #define SftpServerContext struct _SftpServerContext
120 #define SftpServerSession struct _SftpServerSession
uint_t numSessions
Maximum number of SFTP sessions.
char_t path[SFTP_SERVER_MAX_PATH_LEN+1]
Path name.
size_t dataLen
Length of the data payload.
#define SFTP_SERVER_BUFFER_SIZE
uint_t numSessions
Maximum number of SFTP sessions.
error_t sftpServerSetRootDir(SftpServerSession *session, const char_t *rootDir)
Set user's root directory.
SFtpFilePerm
File permissions.
OsTaskParameters task
Task parameters.
SftpServerSession * sessions
SFTP sessions.
SftpServerCheckUserCallback checkUserCallback
User verification callback function.
FsFile * file
File pointer.
@ SFTP_SERVER_SESSION_STATE_RECEIVING_DATA
SftpAccessStatus(* SftpServerCheckUserCallback)(SftpServerSession *session, const char_t *user)
User verification callback function.
FsDir * dir
Directory pointer.
SftpServerSession * session
Pointer to the SFTP session.
SshServerContext * sshServerContext
SSH server context.
error_t sftpServerStop(SftpServerContext *context)
Stop SFTP server.
char_t rootDir[SFTP_SERVER_MAX_ROOT_DIR_LEN+1]
Root directory.
OsEvent event
Event object used to poll the channels.
size_t bufferLen
Actual length of the buffer, in bytes.
FsFile * file
File pointer.
size_t bufferPos
Current position in the buffer.
OsTaskParameters taskParams
Task parameters.
SftpFileType type
File type.
#define SFTP_SERVER_MAX_PATH_LEN
const char_t * rootDir
Root directory.
uint8_t buffer[SFTP_SERVER_BUFFER_SIZE]
Memory buffer for input/output operations.
uint64_t offset
Offset within the file.
SftpFileObject * fileObjects
File objects.
OsTaskId taskId
Task identifier.
#define SFTP_SERVER_MAX_ROOT_DIR_LEN
SftpServerSession * sessions
SFTP sessions.
SftpAccessStatus
Access status.
SftpVersion version
SFTP protocol version.
bool_t running
Operational state of the FTP server.
uint32_t requestId
Request identifier.
void sftpServerTask(void *param)
SFTP server task.
@ SFTP_SERVER_SESSION_STATE_SENDING_DATA
File or directory object.
uint32_t handle
File or directory handle.
error_t sftpServerStart(SftpServerContext *context)
Start SFTP server.
File system abstraction layer.
char_t rootDir[SFTP_SERVER_MAX_ROOT_DIR_LEN+1]
Root directory.
SftpServerSessionState state
Session state.
void sftpServerDeinit(SftpServerContext *context)
Release SFTP server context.
error_t requestStatus
Status of the request.
@ SFTP_SERVER_SESSION_STATE_CLOSED
SftpServerContext * context
SFTP server context.
uint_t numFileObjects
Maximum number of file objects.
#define SFTP_SERVER_MAX_SESSIONS
uint_t(* SftpServerGetFilePermCallback)(SftpServerSession *session, const char_t *user, const char_t *path)
Callback used to retrieve file permissions.
Structure describing channel events.
SftpServerSessionState
SFTP session state.
uint64_t size
Size of the file.
SftpServerCheckUserCallback checkUserCallback
User verification callback function.
SftpFileObject * fileObjects
File objects.
SshChannel * channel
Underlying SSH channel.
error_t sftpServerSetHomeDir(SftpServerSession *session, const char_t *homeDir)
Set user's home directory.
SshServerContext * sshServerContext
SSH server context.
void sftpServerGetDefaultSettings(SftpServerSettings *settings)
Initialize settings with default values.
@ SFTP_SERVER_SESSION_STATE_RECEIVING
Definitions common to SFTP client and server.
SftpVersion
SFTP protocol version.
SftpServerGetFilePermCallback getFilePermCallback
Callback used to retrieve file permissions.
thread_t * OsTaskId
Task identifier.
SftpServerGetFilePermCallback getFilePermCallback
Callback used to retrieve file permissions.
#define SftpServerSession
#define SftpServerContext
uint32_t handle
Opaque value that identifies the file.
error_t sftpServerInit(SftpServerContext *context, const SftpServerSettings *settings)
Initialize SFTP server context.
SshChannelEventDesc eventDesc[SFTP_SERVER_MAX_SESSIONS]
The events the application is interested in.
uint_t numFileObjects
Maximum number of file objects.
@ SFTP_SERVER_SESSION_STATE_SENDING
#define SFTP_SERVER_MAX_HOME_DIR_LEN
void FsFile
File descriptor.
char_t homeDir[SFTP_SERVER_MAX_HOME_DIR_LEN+1]
Home directory.