FTP server (File Transfer Protocol) More...
#include "core/net.h"#include "core/socket.h"#include "fs_port.h"#include "core/crypto.h"#include "tls.h"#include "tls_ticket.h"Go to the source code of this file.
Data Structures | |
| struct | FtpServerSettings |
| FTP server settings. More... | |
| struct | FtpServerChannel |
| Control or data channel. More... | |
| struct | _FtpClientConnection |
| FTP client connection. More... | |
| struct | _FtpServerContext |
| FTP server context. More... | |
Typedefs | |
| typedef error_t(* | FtpServerConnectCallback) (FtpClientConnection *connection, const IpAddr *clientIpAddr, uint16_t clientPort) |
| Connection callback function. More... | |
| typedef void(* | FtpServerDisconnectCallback) (FtpClientConnection *connection, const IpAddr *clientIpAddr, uint16_t clientPort) |
| Disconnection callback function. More... | |
| typedef error_t(* | FtpServerTlsInitCallback) (FtpClientConnection *connection, TlsContext *tlsContext) |
| TLS initialization callback function. More... | |
| typedef uint_t(* | FtpServerCheckUserCallback) (FtpClientConnection *connection, const char_t *user) |
| User verification callback function. More... | |
| typedef uint_t(* | FtpServerCheckPasswordCallback) (FtpClientConnection *connection, const char_t *user, const char_t *password) |
| Password verification callback function. More... | |
| typedef uint_t(* | FtpServerGetFilePermCallback) (FtpClientConnection *connection, const char_t *user, const char_t *path) |
| Callback used to retrieve file permissions. More... | |
| typedef error_t(* | FtpServerUnknownCommandCallback) (FtpClientConnection *connection, const char_t *command, const char_t *param) |
| Unknown command callback function. 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 | ftpServerStop (FtpServerContext *context) |
| Stop FTP server. More... | |
| error_t | ftpServerSetRootDir (FtpClientConnection *connection, const char_t *rootDir) |
| Set user's root directory. More... | |
| error_t | ftpServerSetHomeDir (FtpClientConnection *connection, const char_t *homeDir) |
| Set user's home directory. More... | |
| void | ftpServerTask (FtpServerContext *context) |
| FTP server task. More... | |
| void | ftpServerDeinit (FtpServerContext *context) |
| Release FTP server context. More... | |
Detailed Description
FTP server (File Transfer Protocol)
License
SPDX-License-Identifier: GPL-2.0-or-later
Copyright (C) 2010-2025 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.
- Version
- 2.5.4
Definition in file ftp_server.h.
Macro Definition Documentation
◆ FTP_DATA_PORT
| #define FTP_DATA_PORT 20 |
Definition at line 192 of file ftp_server.h.
◆ FTP_PORT
| #define FTP_PORT 21 |
Definition at line 190 of file ftp_server.h.
◆ FTP_SERVER_BACKLOG
| #define FTP_SERVER_BACKLOG 4 |
Definition at line 88 of file ftp_server.h.
◆ FTP_SERVER_BUFFER_SIZE
| #define FTP_SERVER_BUFFER_SIZE 1024 |
Definition at line 102 of file ftp_server.h.
◆ FTP_SERVER_MAX_CONNECTIONS
| #define FTP_SERVER_MAX_CONNECTIONS 10 |
Definition at line 67 of file ftp_server.h.
◆ FTP_SERVER_MAX_LINE_LEN
| #define FTP_SERVER_MAX_LINE_LEN 255 |
Definition at line 95 of file ftp_server.h.
◆ FTP_SERVER_MAX_PATH_LEN
| #define FTP_SERVER_MAX_PATH_LEN 255 |
Definition at line 123 of file ftp_server.h.
◆ FTP_SERVER_MAX_ROOT_DIR_LEN
| #define FTP_SERVER_MAX_ROOT_DIR_LEN 63 |
Definition at line 109 of file ftp_server.h.
◆ FTP_SERVER_MAX_TCP_BUFFER_SIZE
| #define FTP_SERVER_MAX_TCP_BUFFER_SIZE 2860 |
Definition at line 137 of file ftp_server.h.
◆ FTP_SERVER_MAX_TLS_RX_BUFFER_SIZE
| #define FTP_SERVER_MAX_TLS_RX_BUFFER_SIZE 16384 |
Definition at line 158 of file ftp_server.h.
◆ FTP_SERVER_MAX_USERNAME_LEN
| #define FTP_SERVER_MAX_USERNAME_LEN 63 |
Definition at line 116 of file ftp_server.h.
◆ FTP_SERVER_MIN_TCP_BUFFER_SIZE
| #define FTP_SERVER_MIN_TCP_BUFFER_SIZE 1430 |
Definition at line 130 of file ftp_server.h.
◆ FTP_SERVER_MIN_TLS_RX_BUFFER_SIZE
| #define FTP_SERVER_MIN_TLS_RX_BUFFER_SIZE 2048 |
Definition at line 151 of file ftp_server.h.
◆ FTP_SERVER_PASSIVE_PORT_MAX
| #define FTP_SERVER_PASSIVE_PORT_MAX 49151 |
Definition at line 172 of file ftp_server.h.
◆ FTP_SERVER_PASSIVE_PORT_MIN
| #define FTP_SERVER_PASSIVE_PORT_MIN 48128 |
Definition at line 165 of file ftp_server.h.
◆ FTP_SERVER_PRIORITY
| #define FTP_SERVER_PRIORITY OS_TASK_PRIORITY_NORMAL |
Definition at line 62 of file ftp_server.h.
◆ FTP_SERVER_PRIVATE_CONTEXT
| #define FTP_SERVER_PRIVATE_CONTEXT |
Definition at line 179 of file ftp_server.h.
◆ FTP_SERVER_STACK_SIZE
| #define FTP_SERVER_STACK_SIZE 650 |
Definition at line 55 of file ftp_server.h.
◆ FTP_SERVER_SUPPORT
| #define FTP_SERVER_SUPPORT ENABLED |
Definition at line 41 of file ftp_server.h.
◆ FTP_SERVER_TICK_INTERVAL
| #define FTP_SERVER_TICK_INTERVAL 1000 |
Definition at line 81 of file ftp_server.h.
◆ FTP_SERVER_TIMEOUT
| #define FTP_SERVER_TIMEOUT 60000 |
Definition at line 74 of file ftp_server.h.
◆ FTP_SERVER_TLS_SUPPORT
| #define FTP_SERVER_TLS_SUPPORT DISABLED |
Definition at line 48 of file ftp_server.h.
◆ FTP_SERVER_TLS_TX_BUFFER_SIZE
| #define FTP_SERVER_TLS_TX_BUFFER_SIZE 4096 |
Definition at line 144 of file ftp_server.h.
◆ FtpClientConnection
| #define FtpClientConnection struct _FtpClientConnection |
Definition at line 205 of file ftp_server.h.
◆ FTPS_DATA_PORT
| #define FTPS_DATA_PORT 989 |
Definition at line 197 of file ftp_server.h.
◆ FTPS_PORT
| #define FTPS_PORT 990 |
Definition at line 195 of file ftp_server.h.
◆ FtpServerContext
| #define FtpServerContext struct _FtpServerContext |
Definition at line 201 of file ftp_server.h.
Typedef Documentation
◆ FtpServerCheckPasswordCallback
| typedef uint_t(* FtpServerCheckPasswordCallback) (FtpClientConnection *connection, const char_t *user, const char_t *password) |
Password verification callback function.
Definition at line 319 of file ftp_server.h.
◆ FtpServerCheckUserCallback
| typedef uint_t(* FtpServerCheckUserCallback) (FtpClientConnection *connection, const char_t *user) |
User verification callback function.
Definition at line 311 of file ftp_server.h.
◆ FtpServerConnectCallback
| typedef error_t(* FtpServerConnectCallback) (FtpClientConnection *connection, const IpAddr *clientIpAddr, uint16_t clientPort) |
Connection callback function.
Definition at line 282 of file ftp_server.h.
◆ FtpServerDisconnectCallback
| typedef void(* FtpServerDisconnectCallback) (FtpClientConnection *connection, const IpAddr *clientIpAddr, uint16_t clientPort) |
Disconnection callback function.
Definition at line 290 of file ftp_server.h.
◆ FtpServerGetFilePermCallback
| typedef uint_t(* FtpServerGetFilePermCallback) (FtpClientConnection *connection, const char_t *user, const char_t *path) |
Callback used to retrieve file permissions.
Definition at line 327 of file ftp_server.h.
◆ FtpServerTlsInitCallback
| typedef error_t(* FtpServerTlsInitCallback) (FtpClientConnection *connection, TlsContext *tlsContext) |
TLS initialization callback function.
Definition at line 301 of file ftp_server.h.
◆ FtpServerUnknownCommandCallback
| typedef error_t(* FtpServerUnknownCommandCallback) (FtpClientConnection *connection, const char_t *command, const char_t *param) |
Unknown command callback function.
Definition at line 335 of file ftp_server.h.
Enumeration Type Documentation
◆ FtpAccessStatus
| enum FtpAccessStatus |
FTP server access status.
| Enumerator | |
|---|---|
| FTP_ACCESS_DENIED | |
| FTP_ACCESS_ALLOWED | |
| FTP_PASSWORD_REQUIRED | |
Definition at line 258 of file ftp_server.h.
◆ FtpFilePerm
| enum FtpFilePerm |
File permissions.
| Enumerator | |
|---|---|
| FTP_FILE_PERM_LIST | |
| FTP_FILE_PERM_READ | |
| FTP_FILE_PERM_WRITE | |
Definition at line 270 of file ftp_server.h.
◆ FtpServerChannelState
Channel state.
Definition at line 217 of file ftp_server.h.
◆ FtpServerMode
| enum FtpServerMode |
Security modes.
| Enumerator | |
|---|---|
| FTP_SERVER_MODE_PLAINTEXT | |
| FTP_SERVER_MODE_IMPLICIT_TLS | |
| FTP_SERVER_MODE_EXPLICIT_TLS | |
Definition at line 246 of file ftp_server.h.
Function Documentation
◆ ftpServerDeinit()
| void ftpServerDeinit | ( | FtpServerContext * | context | ) |
Release FTP server context.
- Parameters
-
[in] context Pointer to the FTP server context
Definition at line 600 of file ftp_server.c.
◆ ftpServerGetDefaultSettings()
| void ftpServerGetDefaultSettings | ( | FtpServerSettings * | settings | ) |
Initialize settings with default values.
- Parameters
-
[out] settings Structure that contains FTP server settings
Definition at line 61 of file ftp_server.c.
◆ ftpServerInit()
| error_t ftpServerInit | ( | FtpServerContext * | context, |
| const FtpServerSettings * | settings | ||
| ) |
FTP server initialization.
- Parameters
-
[in] context Pointer to the FTP server context [in] settings FTP server specific settings
- Returns
- Error code
Definition at line 121 of file ftp_server.c.
◆ ftpServerSetHomeDir()
| error_t ftpServerSetHomeDir | ( | FtpClientConnection * | connection, |
| const char_t * | homeDir | ||
| ) |
Set user's home directory.
- Parameters
-
[in] connection Pointer to the client connection [in] homeDir NULL-terminated string specifying the home directory
- Returns
- Error code
Definition at line 426 of file ftp_server.c.
◆ ftpServerSetRootDir()
| error_t ftpServerSetRootDir | ( | FtpClientConnection * | connection, |
| const char_t * | rootDir | ||
| ) |
Set user's root directory.
- Parameters
-
[in] connection Pointer to the client connection [in] rootDir NULL-terminated string specifying the root directory
- Returns
- Error code
Definition at line 390 of file ftp_server.c.
◆ ftpServerStart()
| error_t ftpServerStart | ( | FtpServerContext * | context | ) |
Start FTP server.
- Parameters
-
[in] context Pointer to the FTP server context
- Returns
- Error code
Definition at line 232 of file ftp_server.c.
◆ ftpServerStop()
| error_t ftpServerStop | ( | FtpServerContext * | context | ) |
Stop FTP server.
- Parameters
-
[in] context Pointer to the FTP server context
- Returns
- Error code
Definition at line 339 of file ftp_server.c.
◆ ftpServerTask()
| void ftpServerTask | ( | FtpServerContext * | context | ) |
FTP server task.
- Parameters
-
[in] context Pointer to the FTP server context
Definition at line 456 of file ftp_server.c.
