ftp_server.h File Reference

FTP server (File Transfer Protocol) More...

#include "core/net.h"
#include "core/socket.h"
#include "fs_port.h"

Go to the source code of this file.

Data Structures

struct  FtpClientConnection
 FTP client connection. More...
 
struct  FtpServerSettings
 FTP server settings. More...
 
struct  FtpServerContext
 FTP server context. More...
 

Macros

#define FTP_SERVER_SUPPORT   ENABLED
 
#define FTP_SERVER_STACK_SIZE   650
 
#define FTP_SERVER_PRIORITY   OS_TASK_PRIORITY_NORMAL
 
#define FTP_SERVER_MAX_CONNECTIONS   4
 
#define FTP_SERVER_TIMEOUT   60000
 
#define FTP_SERVER_SOCKET_POLLING_TIMEOUT   2000
 
#define FTP_SERVER_BACKLOG   4
 
#define FTP_SERVER_MAX_LINE_LEN   255
 
#define FTP_SERVER_BUFFER_SIZE   1536
 
#define FTP_SERVER_MAX_ROOT_DIR_LEN   63
 
#define FTP_SERVER_MAX_HOME_DIR_LEN   63
 
#define FTP_SERVER_MAX_USERNAME_LEN   63
 
#define FTP_SERVER_MAX_PATH_LEN   255
 
#define FTP_SERVER_CTRL_SOCKET_BUFFER_SIZE   1430
 
#define FTP_SERVER_DATA_SOCKET_BUFFER_SIZE   2860
 
#define FTP_SERVER_PASSIVE_PORT_MIN   48128
 
#define FTP_SERVER_PASSIVE_PORT_MAX   49151
 
#define FTP_PORT   21
 
#define FTP_DATA_PORT   20
 
#define FTPS_PORT   990
 
#define FTPS_DATA_PORT   989
 

Typedefs

typedef uint_t(* FtpCheckUserCallback) (FtpClientConnection *connection, const char_t *user)
 User verification callback function. More...
 
typedef uint_t(* FtpCheckPasswordCallback) (FtpClientConnection *connection, const char_t *user, const char_t *password)
 Password verification callback function. More...
 
typedef uint_t(* FtpGetFilePermCallback) (FtpClientConnection *connection, const char_t *user, const char_t *path)
 Callback used to retrieve file permissions. More...
 
typedef error_t(* FtpUnknownCommandCallback) (FtpClientConnection *connection, const char_t *command, const char_t *param)
 Unknown command callback function. More...
 

Enumerations

enum  FtpControlConnState {
  FTP_CONTROL_STATE_CLOSED = 0, FTP_CONTROL_STATE_IDLE = 1, FTP_CONTROL_STATE_DISCARD = 2, FTP_CONTROL_STATE_USER = 3,
  FTP_CONTROL_STATE_LIST = 4, FTP_CONTROL_STATE_RETR = 5, FTP_CONTROL_STATE_STOR = 6, FTP_CONTROL_STATE_APPE = 7,
  FTP_CONTROL_STATE_RNFR = 8, FTP_CONTROL_STATE_WAIT_ACK = 9, FTP_CONTROL_STATE_SHUTDOWN_TX = 10, FTP_CONTROL_STATE_SHUTDOWN_RX = 11
}
 Control connection state. More...
 
enum  FtpDataConnState {
  FTP_DATA_STATE_CLOSED = 0, FTP_DATA_STATE_LISTEN = 1, FTP_DATA_STATE_IDLE = 2, FTP_DATA_STATE_SEND = 3,
  FTP_DATA_STATE_RECEIVE = 4, FTP_DATA_STATE_WAIT_ACK = 5, FTP_DATA_STATE_SHUTDOWN_TX = 6, FTP_DATA_STATE_SHUTDOWN_RX = 7
}
 Data connection state. More...
 
enum  FtpAccessStatus { FTP_ACCESS_DENIED = 0, FTP_ACCESS_ALLOWED = 1, FTP_PASSWORD_REQUIRED = 2 }
 FTP server access status. More...
 
enum  FtpFilePerm { FTP_FILE_PERM_LIST = 0x01, FTP_FILE_PERM_READ = 0x02, FTP_FILE_PERM_WRITE = 0x04 }
 File permissions. More...
 

Functions

void ftpServerGetDefaultSettings (FtpServerSettings *settings)
 Initialize settings with default values. More...
 
error_t ftpServerInit (FtpServerContext *context, const FtpServerSettings *settings)
 FTP server initialization. More...
 
error_t ftpServerStart (FtpServerContext *context)
 Start FTP server. More...
 
error_t ftpServerSetHomeDir (FtpClientConnection *connection, const char_t *homeDir)
 Set home directory. More...
 
void ftpServerTask (FtpServerContext *context)
 FTP server task. More...
 

Detailed Description

FTP server (File Transfer Protocol)

License

Copyright (C) 2010-2018 Oryx Embedded SARL. All rights reserved.

This file is part of CycloneTCP 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
1.9.0

Definition in file ftp_server.h.

Macro Definition Documentation

◆ FTP_DATA_PORT

#define FTP_DATA_PORT   20

Definition at line 157 of file ftp_server.h.

◆ FTP_PORT

#define FTP_PORT   21

Definition at line 155 of file ftp_server.h.

◆ FTP_SERVER_BACKLOG

#define FTP_SERVER_BACKLOG   4

Definition at line 79 of file ftp_server.h.

◆ FTP_SERVER_BUFFER_SIZE

#define FTP_SERVER_BUFFER_SIZE   1536

Definition at line 93 of file ftp_server.h.

◆ FTP_SERVER_CTRL_SOCKET_BUFFER_SIZE

#define FTP_SERVER_CTRL_SOCKET_BUFFER_SIZE   1430

Definition at line 128 of file ftp_server.h.

◆ FTP_SERVER_DATA_SOCKET_BUFFER_SIZE

#define FTP_SERVER_DATA_SOCKET_BUFFER_SIZE   2860

Definition at line 135 of file ftp_server.h.

◆ FTP_SERVER_MAX_CONNECTIONS

#define FTP_SERVER_MAX_CONNECTIONS   4

Definition at line 58 of file ftp_server.h.

◆ FTP_SERVER_MAX_HOME_DIR_LEN

#define FTP_SERVER_MAX_HOME_DIR_LEN   63

Definition at line 107 of file ftp_server.h.

◆ FTP_SERVER_MAX_LINE_LEN

#define FTP_SERVER_MAX_LINE_LEN   255

Definition at line 86 of file ftp_server.h.

◆ FTP_SERVER_MAX_PATH_LEN

#define FTP_SERVER_MAX_PATH_LEN   255

Definition at line 121 of file ftp_server.h.

◆ FTP_SERVER_MAX_ROOT_DIR_LEN

#define FTP_SERVER_MAX_ROOT_DIR_LEN   63

Definition at line 100 of file ftp_server.h.

◆ FTP_SERVER_MAX_USERNAME_LEN

#define FTP_SERVER_MAX_USERNAME_LEN   63

Definition at line 114 of file ftp_server.h.

◆ FTP_SERVER_PASSIVE_PORT_MAX

#define FTP_SERVER_PASSIVE_PORT_MAX   49151

Definition at line 149 of file ftp_server.h.

◆ FTP_SERVER_PASSIVE_PORT_MIN

#define FTP_SERVER_PASSIVE_PORT_MIN   48128

Definition at line 142 of file ftp_server.h.

◆ FTP_SERVER_PRIORITY

#define FTP_SERVER_PRIORITY   OS_TASK_PRIORITY_NORMAL

Definition at line 53 of file ftp_server.h.

◆ FTP_SERVER_SOCKET_POLLING_TIMEOUT

#define FTP_SERVER_SOCKET_POLLING_TIMEOUT   2000

Definition at line 72 of file ftp_server.h.

◆ FTP_SERVER_STACK_SIZE

#define FTP_SERVER_STACK_SIZE   650

Definition at line 46 of file ftp_server.h.

◆ FTP_SERVER_SUPPORT

#define FTP_SERVER_SUPPORT   ENABLED

Definition at line 39 of file ftp_server.h.

◆ FTP_SERVER_TIMEOUT

#define FTP_SERVER_TIMEOUT   60000

Definition at line 65 of file ftp_server.h.

◆ FTPS_DATA_PORT

#define FTPS_DATA_PORT   989

Definition at line 162 of file ftp_server.h.

◆ FTPS_PORT

#define FTPS_PORT   990

Definition at line 160 of file ftp_server.h.

Typedef Documentation

◆ FtpCheckPasswordCallback

typedef uint_t(* FtpCheckPasswordCallback) (FtpClientConnection *connection, const char_t *user, const char_t *password)

Password verification callback function.

Definition at line 277 of file ftp_server.h.

◆ FtpCheckUserCallback

typedef uint_t(* FtpCheckUserCallback) (FtpClientConnection *connection, const char_t *user)

User verification callback function.

Definition at line 269 of file ftp_server.h.

◆ FtpGetFilePermCallback

typedef uint_t(* FtpGetFilePermCallback) (FtpClientConnection *connection, const char_t *user, const char_t *path)

Callback used to retrieve file permissions.

Definition at line 285 of file ftp_server.h.

◆ FtpUnknownCommandCallback

typedef error_t(* FtpUnknownCommandCallback) (FtpClientConnection *connection, const char_t *command, const char_t *param)

Unknown command callback function.

Definition at line 293 of file ftp_server.h.

Enumeration Type Documentation

◆ FtpAccessStatus

FTP server access status.

Enumerator
FTP_ACCESS_DENIED 
FTP_ACCESS_ALLOWED 
FTP_PASSWORD_REQUIRED 

Definition at line 212 of file ftp_server.h.

◆ FtpControlConnState

Control connection state.

Enumerator
FTP_CONTROL_STATE_CLOSED 
FTP_CONTROL_STATE_IDLE 
FTP_CONTROL_STATE_DISCARD 
FTP_CONTROL_STATE_USER 
FTP_CONTROL_STATE_LIST 
FTP_CONTROL_STATE_RETR 
FTP_CONTROL_STATE_STOR 
FTP_CONTROL_STATE_APPE 
FTP_CONTROL_STATE_RNFR 
FTP_CONTROL_STATE_WAIT_ACK 
FTP_CONTROL_STATE_SHUTDOWN_TX 
FTP_CONTROL_STATE_SHUTDOWN_RX 

Definition at line 174 of file ftp_server.h.

◆ FtpDataConnState

Data connection state.

Enumerator
FTP_DATA_STATE_CLOSED 
FTP_DATA_STATE_LISTEN 
FTP_DATA_STATE_IDLE 
FTP_DATA_STATE_SEND 
FTP_DATA_STATE_RECEIVE 
FTP_DATA_STATE_WAIT_ACK 
FTP_DATA_STATE_SHUTDOWN_TX 
FTP_DATA_STATE_SHUTDOWN_RX 

Definition at line 195 of file ftp_server.h.

◆ FtpFilePerm

File permissions.

Enumerator
FTP_FILE_PERM_LIST 
FTP_FILE_PERM_READ 
FTP_FILE_PERM_WRITE 

Definition at line 224 of file ftp_server.h.

Function Documentation

◆ ftpServerGetDefaultSettings()

void ftpServerGetDefaultSettings ( FtpServerSettings settings)

Initialize settings with default values.

Parameters
[out]settingsStructure that contains FTP server settings

Definition at line 60 of file ftp_server.c.

◆ ftpServerInit()

error_t ftpServerInit ( FtpServerContext context,
const FtpServerSettings settings 
)

FTP server initialization.

Parameters
[in]contextPointer to the FTP server context
[in]settingsFTP server specific settings
Returns
Error code

Definition at line 94 of file ftp_server.c.

◆ ftpServerSetHomeDir()

error_t ftpServerSetHomeDir ( FtpClientConnection connection,
const char_t homeDir 
)

Set home directory.

Parameters
[in]connectionPointer to the client connection
[in]homeDirNULL-terminated string specifying the home directory
Returns
Error code

Definition at line 232 of file ftp_server.c.

◆ ftpServerStart()

error_t ftpServerStart ( FtpServerContext context)

Start FTP server.

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

Definition at line 201 of file ftp_server.c.

◆ ftpServerTask()

void ftpServerTask ( FtpServerContext context)

FTP server task.

Parameters
[in]contextPointer to the FTP server context

Definition at line 257 of file ftp_server.c.