Go to the documentation of this file.
40 #ifndef SCP_SERVER_SUPPORT
41 #define SCP_SERVER_SUPPORT DISABLED
42 #elif (SCP_SERVER_SUPPORT != ENABLED && SCP_SERVER_SUPPORT != DISABLED)
43 #error SCP_SERVER_SUPPORT parameter is not valid
47 #ifndef SCP_SERVER_STACK_SIZE
48 #define SCP_SERVER_STACK_SIZE 650
49 #elif (SCP_SERVER_STACK_SIZE < 1)
50 #error SCP_SERVER_STACK_SIZE parameter is not valid
54 #ifndef SCP_SERVER_PRIORITY
55 #define SCP_SERVER_PRIORITY OS_TASK_PRIORITY_NORMAL
59 #ifndef SCP_SERVER_MAX_SESSIONS
60 #define SCP_SERVER_MAX_SESSIONS 10
61 #elif (SCP_SERVER_MAX_SESSIONS < 1)
62 #error SCP_SERVER_MAX_SESSIONS parameter is not valid
66 #ifndef SCP_SERVER_TICK_INTERVAL
67 #define SCP_SERVER_TICK_INTERVAL 1000
68 #elif (SCP_SERVER_TICK_INTERVAL < 100)
69 #error SCP_SERVER_TICK_INTERVAL parameter is not valid
73 #ifndef SCP_SERVER_BUFFER_SIZE
74 #define SCP_SERVER_BUFFER_SIZE 512
75 #elif (SCP_SERVER_BUFFER_SIZE < 128)
76 #error SCP_SERVER_BUFFER_SIZE parameter is not valid
80 #ifndef SCP_SERVER_MAX_ROOT_DIR_LEN
81 #define SCP_SERVER_MAX_ROOT_DIR_LEN 63
82 #elif (SCP_SERVER_MAX_ROOT_DIR_LEN < 7)
83 #error SCP_SERVER_MAX_ROOT_DIR_LEN parameter is not valid
87 #ifndef SCP_SERVER_MAX_HOME_DIR_LEN
88 #define SCP_SERVER_MAX_HOME_DIR_LEN 63
89 #elif (SCP_SERVER_MAX_HOME_DIR_LEN < 7)
90 #error SCP_SERVER_MAX_HOME_DIR_LEN parameter is not valid
94 #ifndef SCP_SERVER_MAX_PATH_LEN
95 #define SCP_SERVER_MAX_PATH_LEN 255
96 #elif (SCP_SERVER_MAX_PATH_LEN < 7)
97 #error SCP_SERVER_MAX_PATH_LEN parameter is not valid
101 #ifndef SCP_SERVER_MAX_RECURSION_LEVEL
102 #define SCP_SERVER_MAX_RECURSION_LEVEL 4
103 #elif (SCP_SERVER_MAX_RECURSION_LEVEL < 1)
104 #error SCP_SERVER_MAX_RECURSION_LEVEL parameter is not valid
109 #define ScpServerContext struct _ScpServerContext
113 #define ScpServerSession struct _ScpServerSession
ScpServerSession * sessions
SCP sessions.
char_t path[SCP_SERVER_MAX_PATH_LEN+1]
Path name.
@ SCP_SERVER_SESSION_STATE_WRITE_STATUS
SshServerContext * sshServerContext
SSH server context.
uint_t(* ScpServerGetFilePermCallback)(ScpServerSession *session, const char_t *user, const char_t *path)
Callback used to retrieve file permissions.
SshChannelEventDesc eventDesc[SCP_SERVER_MAX_SESSIONS]
The events the application is interested in.
char_t buffer[SCP_SERVER_BUFFER_SIZE]
Memory buffer for input/output operations.
#define SCP_SERVER_BUFFER_SIZE
@ SCP_SERVER_SESSION_STATE_WRITE_COMMAND
#define SCP_SERVER_MAX_RECURSION_LEVEL
ScpAccessStatus(* ScpServerCheckUserCallback)(ScpServerSession *session, const char_t *user)
User verification callback function.
uint32_t fileMode
File access rights.
ScpServerSessionState state
Session state.
ScpFilePerm
File permissions.
OsTaskId taskId
Task identifier.
@ SCP_SERVER_SESSION_STATE_WRITE_INIT
uint_t numSessions
Maximum number of SCP sessions.
#define SCP_SERVER_MAX_SESSIONS
uint64_t fileSize
Size of the file, in bytes.
bool_t recursive
Recursive copy.
#define SCP_SERVER_MAX_PATH_LEN
ScpAccessStatus
Access status.
bool_t running
Operational state of the FTP server.
SshServerContext * sshServerContext
SSH server context.
@ SCP_SERVER_SESSION_STATE_CLOSING
@ SCP_SERVER_SESSION_STATE_WRITE_ACK
void scpServerDeinit(ScpServerContext *context)
Release SCP server context.
FsFile * file
File pointer.
@ SCP_SERVER_SESSION_STATE_READ_STATUS
uint_t dirLevel
Current level of recursion.
ScpServerContext * context
SCP server context.
@ SCP_SERVER_SESSION_STATE_ERROR
error_t statusCode
Status code.
void scpServerTask(void *param)
SCP server task.
char_t rootDir[SCP_SERVER_MAX_ROOT_DIR_LEN+1]
Root directory.
#define SCP_SERVER_MAX_ROOT_DIR_LEN
error_t scpServerSetHomeDir(ScpServerSession *session, const char_t *homeDir)
Set user's home directory.
uint64_t fileOffset
Offset within the file.
SshChannel * channel
Underlying SSH channel.
OsTaskParameters task
Task parameters.
File system abstraction layer.
Definitions common to SCP client and server.
@ SCP_SERVER_SESSION_STATE_WRITE_FIN
@ SCP_SERVER_SESSION_STATE_READ_COMMAND
ScpServerGetFilePermCallback getFilePermCallback
Callback used to retrieve file permissions.
size_t bufferLen
Actual length of the buffer, in bytes.
error_t scpServerInit(ScpServerContext *context, const ScpServerSettings *settings)
Initialize SCP server context.
@ SCP_SERVER_SESSION_STATE_CLOSED
#define SCP_SERVER_MAX_HOME_DIR_LEN
const char_t * rootDir
Root directory.
void scpServerGetDefaultSettings(ScpServerSettings *settings)
Initialize settings with default values.
Structure describing channel events.
@ SCP_SERVER_SESSION_STATE_READ_INIT
bool_t targetIsDir
The target is a directory.
ScpServerSessionState
SCP session state.
char_t path[SCP_SERVER_MAX_PATH_LEN+1]
Path name.
char_t rootDir[SCP_SERVER_MAX_ROOT_DIR_LEN+1]
Root directory.
OsEvent event
Event object used to poll the channels.
size_t bufferPos
Current position in the buffer.
uint_t numSessions
Maximum number of SCP sessions.
@ SCP_SERVER_SESSION_STATE_WRITE_DATA
thread_t * OsTaskId
Task identifier.
OsTaskParameters taskParams
Task parameters.
ScpServerSession * sessions
SCP sessions.
ScpServerCheckUserCallback checkUserCallback
User verification callback function.
char_t homeDir[SCP_SERVER_MAX_HOME_DIR_LEN+1]
Home directory.
@ SCP_SERVER_SESSION_STATE_READ_ACK
FsDir * dir[SCP_SERVER_MAX_RECURSION_LEVEL]
Directory pointers.
ScpServerCheckUserCallback checkUserCallback
User verification callback function.
error_t scpServerStop(ScpServerContext *context)
Stop SCP server.
@ SCP_SERVER_SESSION_STATE_READ_FIN
error_t scpServerSetRootDir(ScpServerSession *session, const char_t *rootDir)
Set user's root directory.
@ SCP_SERVER_SESSION_STATE_READ_DATA
error_t scpServerStart(ScpServerContext *context)
Start SCP server.
void FsFile
File descriptor.
ScpServerGetFilePermCallback getFilePermCallback
Callback used to retrieve file permissions.