scp_server.h File Reference

SCP server. More...

#include "ssh/ssh_server.h"
#include "scp/scp_common.h"
#include "fs_port.h"

Go to the source code of this file.

Data Structures

struct  ScpServerSettings
 SCP server settings. More...
 
struct  _ScpServerSession
 SCP session. More...
 
struct  _ScpServerContext
 SCP server context. More...
 

Macros

#define SCP_SERVER_SUPPORT   DISABLED
 
#define SCP_SERVER_STACK_SIZE   650
 
#define SCP_SERVER_PRIORITY   OS_TASK_PRIORITY_NORMAL
 
#define SCP_SERVER_MAX_SESSIONS   10
 
#define SCP_SERVER_TICK_INTERVAL   1000
 
#define SCP_SERVER_BUFFER_SIZE   512
 
#define SCP_SERVER_MAX_ROOT_DIR_LEN   63
 
#define SCP_SERVER_MAX_HOME_DIR_LEN   63
 
#define SCP_SERVER_MAX_PATH_LEN   255
 
#define SCP_SERVER_MAX_RECURSION_LEVEL   4
 
#define ScpServerContext   struct _ScpServerContext
 
#define ScpServerSession   struct _ScpServerSession
 

Typedefs

typedef ScpAccessStatus(* ScpServerCheckUserCallback) (ScpServerSession *session, const char_t *user)
 User verification callback function. More...
 
typedef uint_t(* ScpServerGetFilePermCallback) (ScpServerSession *session, const char_t *user, const char_t *path)
 Callback used to retrieve file permissions. More...
 

Enumerations

enum  ScpAccessStatus { SCP_ACCESS_DENIED = 0 , SCP_ACCESS_ALLOWED = 1 }
 Access status. More...
 
enum  ScpFilePerm { SCP_FILE_PERM_LIST = 0x01 , SCP_FILE_PERM_READ = 0x02 , SCP_FILE_PERM_WRITE = 0x04 }
 File permissions. More...
 
enum  ScpServerSessionState {
  SCP_SERVER_SESSION_STATE_CLOSED = 0 , SCP_SERVER_SESSION_STATE_WRITE_INIT = 1 , SCP_SERVER_SESSION_STATE_WRITE_COMMAND = 2 , SCP_SERVER_SESSION_STATE_WRITE_ACK = 3 ,
  SCP_SERVER_SESSION_STATE_WRITE_DATA = 4 , SCP_SERVER_SESSION_STATE_WRITE_STATUS = 5 , SCP_SERVER_SESSION_STATE_WRITE_FIN = 6 , SCP_SERVER_SESSION_STATE_READ_INIT = 7 ,
  SCP_SERVER_SESSION_STATE_READ_COMMAND = 8 , SCP_SERVER_SESSION_STATE_READ_ACK = 9 , SCP_SERVER_SESSION_STATE_READ_DATA = 10 , SCP_SERVER_SESSION_STATE_READ_STATUS = 11 ,
  SCP_SERVER_SESSION_STATE_READ_FIN = 12 , SCP_SERVER_SESSION_STATE_ERROR = 13 , SCP_SERVER_SESSION_STATE_CLOSING = 14
}
 SCP session state. More...
 

Functions

void scpServerGetDefaultSettings (ScpServerSettings *settings)
 Initialize settings with default values. More...
 
error_t scpServerInit (ScpServerContext *context, const ScpServerSettings *settings)
 Initialize SCP server context. More...
 
error_t scpServerStart (ScpServerContext *context)
 Start SCP server. More...
 
error_t scpServerStop (ScpServerContext *context)
 Stop SCP server. More...
 
error_t scpServerSetRootDir (ScpServerSession *session, const char_t *rootDir)
 Set user's root directory. More...
 
error_t scpServerSetHomeDir (ScpServerSession *session, const char_t *homeDir)
 Set user's home directory. More...
 
void scpServerTask (void *param)
 SCP server task. More...
 
void scpServerDeinit (ScpServerContext *context)
 Release SCP server context. More...
 

Detailed Description

SCP server.

License

SPDX-License-Identifier: GPL-2.0-or-later

Copyright (C) 2019-2024 Oryx Embedded SARL. All rights reserved.

This file is part of CycloneSSH Open.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

Author
Oryx Embedded SARL (www.oryx-embedded.com)
Version
2.4.0

Definition in file scp_server.h.

Macro Definition Documentation

◆ SCP_SERVER_BUFFER_SIZE

#define SCP_SERVER_BUFFER_SIZE   512

Definition at line 74 of file scp_server.h.

◆ SCP_SERVER_MAX_HOME_DIR_LEN

#define SCP_SERVER_MAX_HOME_DIR_LEN   63

Definition at line 88 of file scp_server.h.

◆ SCP_SERVER_MAX_PATH_LEN

#define SCP_SERVER_MAX_PATH_LEN   255

Definition at line 95 of file scp_server.h.

◆ SCP_SERVER_MAX_RECURSION_LEVEL

#define SCP_SERVER_MAX_RECURSION_LEVEL   4

Definition at line 102 of file scp_server.h.

◆ SCP_SERVER_MAX_ROOT_DIR_LEN

#define SCP_SERVER_MAX_ROOT_DIR_LEN   63

Definition at line 81 of file scp_server.h.

◆ SCP_SERVER_MAX_SESSIONS

#define SCP_SERVER_MAX_SESSIONS   10

Definition at line 60 of file scp_server.h.

◆ SCP_SERVER_PRIORITY

#define SCP_SERVER_PRIORITY   OS_TASK_PRIORITY_NORMAL

Definition at line 55 of file scp_server.h.

◆ SCP_SERVER_STACK_SIZE

#define SCP_SERVER_STACK_SIZE   650

Definition at line 48 of file scp_server.h.

◆ SCP_SERVER_SUPPORT

#define SCP_SERVER_SUPPORT   DISABLED

Definition at line 41 of file scp_server.h.

◆ SCP_SERVER_TICK_INTERVAL

#define SCP_SERVER_TICK_INTERVAL   1000

Definition at line 67 of file scp_server.h.

◆ ScpServerContext

#define ScpServerContext   struct _ScpServerContext

Definition at line 109 of file scp_server.h.

◆ ScpServerSession

#define ScpServerSession   struct _ScpServerSession

Definition at line 113 of file scp_server.h.

Typedef Documentation

◆ ScpServerCheckUserCallback

typedef ScpAccessStatus(* ScpServerCheckUserCallback) (ScpServerSession *session, const char_t *user)

User verification callback function.

Definition at line 172 of file scp_server.h.

◆ ScpServerGetFilePermCallback

typedef uint_t(* ScpServerGetFilePermCallback) (ScpServerSession *session, const char_t *user, const char_t *path)

Callback used to retrieve file permissions.

Definition at line 180 of file scp_server.h.

Enumeration Type Documentation

◆ ScpAccessStatus

Access status.

Enumerator
SCP_ACCESS_DENIED 
SCP_ACCESS_ALLOWED 

Definition at line 125 of file scp_server.h.

◆ ScpFilePerm

File permissions.

Enumerator
SCP_FILE_PERM_LIST 
SCP_FILE_PERM_READ 
SCP_FILE_PERM_WRITE 

Definition at line 136 of file scp_server.h.

◆ ScpServerSessionState

SCP session state.

Enumerator
SCP_SERVER_SESSION_STATE_CLOSED 
SCP_SERVER_SESSION_STATE_WRITE_INIT 
SCP_SERVER_SESSION_STATE_WRITE_COMMAND 
SCP_SERVER_SESSION_STATE_WRITE_ACK 
SCP_SERVER_SESSION_STATE_WRITE_DATA 
SCP_SERVER_SESSION_STATE_WRITE_STATUS 
SCP_SERVER_SESSION_STATE_WRITE_FIN 
SCP_SERVER_SESSION_STATE_READ_INIT 
SCP_SERVER_SESSION_STATE_READ_COMMAND 
SCP_SERVER_SESSION_STATE_READ_ACK 
SCP_SERVER_SESSION_STATE_READ_DATA 
SCP_SERVER_SESSION_STATE_READ_STATUS 
SCP_SERVER_SESSION_STATE_READ_FIN 
SCP_SERVER_SESSION_STATE_ERROR 
SCP_SERVER_SESSION_STATE_CLOSING 

Definition at line 148 of file scp_server.h.

Function Documentation

◆ scpServerDeinit()

void scpServerDeinit ( ScpServerContext context)

Release SCP server context.

Parameters
[in]contextPointer to the SCP server context

Definition at line 436 of file scp_server.c.

◆ scpServerGetDefaultSettings()

void scpServerGetDefaultSettings ( ScpServerSettings settings)

Initialize settings with default values.

Parameters
[out]settingsStructure that contains SCP server settings

Definition at line 50 of file scp_server.c.

◆ scpServerInit()

error_t scpServerInit ( ScpServerContext context,
const ScpServerSettings settings 
)

Initialize SCP server context.

Parameters
[in]contextPointer to the SCP server context
[in]settingsSCP server specific settings
Returns
Error code

Definition at line 81 of file scp_server.c.

◆ scpServerSetHomeDir()

error_t scpServerSetHomeDir ( ScpServerSession session,
const char_t homeDir 
)

Set user's home directory.

Parameters
[in]sessionHandle referencing an SCP session
[in]homeDirNULL-terminated string specifying the home directory
Returns
Error code

Definition at line 310 of file scp_server.c.

◆ scpServerSetRootDir()

error_t scpServerSetRootDir ( ScpServerSession session,
const char_t rootDir 
)

Set user's root directory.

Parameters
[in]sessionHandle referencing an SCP session
[in]rootDirNULL-terminated string specifying the root directory
Returns
Error code

Definition at line 276 of file scp_server.c.

◆ scpServerStart()

error_t scpServerStart ( ScpServerContext context)

Start SCP server.

Parameters
[in]contextPointer to the SCP server context
Returns
Error code

Definition at line 164 of file scp_server.c.

◆ scpServerStop()

error_t scpServerStop ( ScpServerContext context)

Stop SCP server.

Parameters
[in]contextPointer to the SCP server context
Returns
Error code

Definition at line 223 of file scp_server.c.

◆ scpServerTask()

void scpServerTask ( void *  param)

SCP server task.

Parameters
[in]paramPointer to the SCP server context

Definition at line 339 of file scp_server.c.