ftp_server.h
Go to the documentation of this file.
1 /**
2  * @file ftp_server.h
3  * @brief FTP server (File Transfer Protocol)
4  *
5  * @section License
6  *
7  * SPDX-License-Identifier: GPL-2.0-or-later
8  *
9  * Copyright (C) 2010-2024 Oryx Embedded SARL. All rights reserved.
10  *
11  * This file is part of CycloneTCP Open.
12  *
13  * This program is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU General Public License
15  * as published by the Free Software Foundation; either version 2
16  * of the License, or (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program; if not, write to the Free Software Foundation,
25  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26  *
27  * @author Oryx Embedded SARL (www.oryx-embedded.com)
28  * @version 2.4.4
29  **/
30 
31 #ifndef _FTP_SERVER_H
32 #define _FTP_SERVER_H
33 
34 //Dependencies
35 #include "core/net.h"
36 #include "core/socket.h"
37 #include "fs_port.h"
38 
39 //FTP server support
40 #ifndef FTP_SERVER_SUPPORT
41  #define FTP_SERVER_SUPPORT ENABLED
42 #elif (FTP_SERVER_SUPPORT != ENABLED && FTP_SERVER_SUPPORT != DISABLED)
43  #error FTP_SERVER_SUPPORT parameter is not valid
44 #endif
45 
46 //FTP over TLS
47 #ifndef FTP_SERVER_TLS_SUPPORT
48  #define FTP_SERVER_TLS_SUPPORT DISABLED
49 #elif (FTP_SERVER_TLS_SUPPORT != ENABLED && FTP_SERVER_TLS_SUPPORT != DISABLED)
50  #error FTP_SERVER_TLS_SUPPORT parameter is not valid
51 #endif
52 
53 //Stack size required to run the FTP server
54 #ifndef FTP_SERVER_STACK_SIZE
55  #define FTP_SERVER_STACK_SIZE 650
56 #elif (FTP_SERVER_STACK_SIZE < 1)
57  #error FTP_SERVER_STACK_SIZE parameter is not valid
58 #endif
59 
60 //Priority at which the FTP server should run
61 #ifndef FTP_SERVER_PRIORITY
62  #define FTP_SERVER_PRIORITY OS_TASK_PRIORITY_NORMAL
63 #endif
64 
65 //Maximum number of simultaneous connections
66 #ifndef FTP_SERVER_MAX_CONNECTIONS
67  #define FTP_SERVER_MAX_CONNECTIONS 10
68 #elif (FTP_SERVER_MAX_CONNECTIONS < 1)
69  #error FTP_SERVER_MAX_CONNECTIONS parameter is not valid
70 #endif
71 
72 //Maximum time the server will wait before closing the connection
73 #ifndef FTP_SERVER_TIMEOUT
74  #define FTP_SERVER_TIMEOUT 60000
75 #elif (FTP_SERVER_TIMEOUT < 1000)
76  #error FTP_SERVER_TIMEOUT parameter is not valid
77 #endif
78 
79 //FTP server tick interval
80 #ifndef FTP_SERVER_TICK_INTERVAL
81  #define FTP_SERVER_TICK_INTERVAL 1000
82 #elif (FTP_SERVER_TICK_INTERVAL < 100)
83  #error FTP_SERVER_TICK_INTERVAL parameter is not valid
84 #endif
85 
86 //Maximum length of the pending connection queue
87 #ifndef FTP_SERVER_BACKLOG
88  #define FTP_SERVER_BACKLOG 4
89 #elif (FTP_SERVER_BACKLOG < 1)
90  #error FTP_SERVER_BACKLOG parameter is not valid
91 #endif
92 
93 //Maximum line length
94 #ifndef FTP_SERVER_MAX_LINE_LEN
95  #define FTP_SERVER_MAX_LINE_LEN 255
96 #elif (FTP_SERVER_MAX_LINE_LEN < 64)
97  #error FTP_SERVER_MAX_LINE_LEN parameter is not valid
98 #endif
99 
100 //Size of buffer used for input/output operations
101 #ifndef FTP_SERVER_BUFFER_SIZE
102  #define FTP_SERVER_BUFFER_SIZE 1024
103 #elif (FTP_SERVER_BUFFER_SIZE < 128)
104  #error FTP_SERVER_BUFFER_SIZE parameter is not valid
105 #endif
106 
107 //Maximum size of root directory
108 #ifndef FTP_SERVER_MAX_ROOT_DIR_LEN
109  #define FTP_SERVER_MAX_ROOT_DIR_LEN 63
110 #elif (FTP_SERVER_MAX_ROOT_DIR_LEN < 7)
111  #error FTP_SERVER_MAX_ROOT_DIR_LEN parameter is not valid
112 #endif
113 
114 //Maximum size of home directory
115 #ifndef FTP_SERVER_MAX_HOME_DIR_LEN
116  #define FTP_SERVER_MAX_HOME_DIR_LEN 63
117 #elif (FTP_SERVER_MAX_HOME_DIR_LEN < 7)
118  #error FTP_SERVER_MAX_HOME_DIR_LEN parameter is not valid
119 #endif
120 
121 //Maximum user name length
122 #ifndef FTP_SERVER_MAX_USERNAME_LEN
123  #define FTP_SERVER_MAX_USERNAME_LEN 63
124 #elif (FTP_SERVER_MAX_USERNAME_LEN < 7)
125  #error FTP_SERVER_MAX_USERNAME_LEN parameter is not valid
126 #endif
127 
128 //Maximum path length
129 #ifndef FTP_SERVER_MAX_PATH_LEN
130  #define FTP_SERVER_MAX_PATH_LEN 255
131 #elif (FTP_SERVER_MAX_PATH_LEN < 7)
132  #error FTP_SERVER_MAX_PATH_LEN parameter is not valid
133 #endif
134 
135 //Minimum buffer size for TCP sockets
136 #ifndef FTP_SERVER_MIN_TCP_BUFFER_SIZE
137  #define FTP_SERVER_MIN_TCP_BUFFER_SIZE 1430
138 #elif (FTP_SERVER_MIN_TCP_BUFFER_SIZE < 512)
139  #error FTP_SERVER_MIN_TCP_BUFFER_SIZE parameter is not valid
140 #endif
141 
142 //Maximum buffer size for TCP sockets
143 #ifndef FTP_SERVER_MAX_TCP_BUFFER_SIZE
144  #define FTP_SERVER_MAX_TCP_BUFFER_SIZE 2860
145 #elif (FTP_SERVER_MAX_TCP_BUFFER_SIZE < 512)
146  #error FTP_SERVER_MAX_TCP_BUFFER_SIZE parameter is not valid
147 #endif
148 
149 //TX buffer size for TLS connections
150 #ifndef FTP_SERVER_TLS_TX_BUFFER_SIZE
151  #define FTP_SERVER_TLS_TX_BUFFER_SIZE 4096
152 #elif (FTP_SERVER_TLS_TX_BUFFER_SIZE < 512)
153  #error FTP_SERVER_TLS_TX_BUFFER_SIZE parameter is not valid
154 #endif
155 
156 //Minimum RX buffer size for TLS connections
157 #ifndef FTP_SERVER_MIN_TLS_RX_BUFFER_SIZE
158  #define FTP_SERVER_MIN_TLS_RX_BUFFER_SIZE 2048
159 #elif (FTP_SERVER_MIN_TLS_RX_BUFFER_SIZE < 512)
160  #error FTP_SERVER_MIN_TLS_RX_BUFFER_SIZE parameter is not valid
161 #endif
162 
163 //Maximum RX buffer size for TLS connections
164 #ifndef FTP_SERVER_MAX_TLS_RX_BUFFER_SIZE
165  #define FTP_SERVER_MAX_TLS_RX_BUFFER_SIZE 16384
166 #elif (FTP_SERVER_MAX_TLS_RX_BUFFER_SIZE < 512)
167  #error FTP_SERVER_MAX_TLS_RX_BUFFER_SIZE parameter is not valid
168 #endif
169 
170 //Passive port range (lower limit)
171 #ifndef FTP_SERVER_PASSIVE_PORT_MIN
172  #define FTP_SERVER_PASSIVE_PORT_MIN 48128
173 #elif (FTP_SERVER_PASSIVE_PORT_MIN < 1024)
174  #error FTP_SERVER_PASSIVE_PORT_MIN parameter is not valid
175 #endif
176 
177 //Passive port range (upper limit)
178 #ifndef FTP_SERVER_PASSIVE_PORT_MAX
179  #define FTP_SERVER_PASSIVE_PORT_MAX 49151
180 #elif (FTP_SERVER_PASSIVE_PORT_MAX <= FTP_SERVER_PASSIVE_PORT_MIN || FTP_SERVER_PASSIVE_PORT_MAX > 65535)
181  #error FTP_SERVER_PASSIVE_PORT_MAX parameter is not valid
182 #endif
183 
184 //Application specific context
185 #ifndef FTP_SERVER_PRIVATE_CONTEXT
186  #define FTP_SERVER_PRIVATE_CONTEXT
187 #endif
188 
189 //TLS supported?
190 #if (FTP_SERVER_TLS_SUPPORT == ENABLED)
191  #include "core/crypto.h"
192  #include "tls.h"
193  #include "tls_ticket.h"
194 #endif
195 
196 //FTP port number
197 #define FTP_PORT 21
198 //FTP data port number
199 #define FTP_DATA_PORT 20
200 
201 //FTPS port number (implicit mode)
202 #define FTPS_PORT 990
203 //FTPS data port number (implicit mode)
204 #define FTPS_DATA_PORT 989
205 
206 //Forward declaration of FtpServerContext structure
207 struct _FtpServerContext;
208 #define FtpServerContext struct _FtpServerContext
209 
210 //Forward declaration of FtpClientConnection structure
211 struct _FtpClientConnection;
212 #define FtpClientConnection struct _FtpClientConnection
213 
214 //C++ guard
215 #ifdef __cplusplus
216 extern "C" {
217 #endif
218 
219 
220 /**
221  * @brief Channel state
222  **/
223 
224 typedef enum
225 {
247 
248 
249 /**
250  * @brief Security modes
251  **/
252 
253 typedef enum
254 {
259 
260 
261 /**
262  * @brief FTP server access status
263  **/
264 
265 typedef enum
266 {
271 
272 
273 /**
274  * @brief File permissions
275  **/
276 
277 typedef enum
278 {
281  FTP_FILE_PERM_WRITE = 0x04
283 
284 
285 /**
286  * @brief Connection callback function
287  **/
288 
290  const IpAddr *clientIpAddr, uint16_t clientPort);
291 
292 
293 /**
294  * @brief Disconnection callback function
295  **/
296 
298  const IpAddr *clientIpAddr, uint16_t clientPort);
299 
300 
301 //TLS supported?
302 #if (FTP_SERVER_TLS_SUPPORT == ENABLED)
303 
304 /**
305  * @brief TLS initialization callback function
306  **/
307 
309  TlsContext *tlsContext);
310 
311 #endif
312 
313 
314 /**
315  * @brief User verification callback function
316  **/
317 
319  const char_t *user);
320 
321 
322 /**
323  * @brief Password verification callback function
324  **/
325 
327  const char_t *user, const char_t *password);
328 
329 
330 /**
331  * @brief Callback used to retrieve file permissions
332  **/
333 
335  const char_t *user, const char_t *path);
336 
337 
338 /**
339  * @brief Unknown command callback function
340  **/
341 
343  const char_t *command, const char_t *param);
344 
345 
346 /**
347  * @brief FTP server settings
348  **/
349 
350 typedef struct
351 {
352  OsTaskParameters task; ///<Task parameters
353  NetInterface *interface; ///<Underlying network interface
354  uint16_t port; ///<FTP command port number
355  uint16_t dataPort; ///<FTP data port number
356  uint16_t passivePortMin; ///<Passive port range (lower value)
357  uint16_t passivePortMax; ///<Passive port range (upper value)
358  Ipv4Addr publicIpv4Addr; ///<Public IPv4 address to be used in PASV replies
359  uint_t mode; ///<Security modes
360  uint_t maxConnections; ///<Maximum number of client connections
361  FtpClientConnection *connections; ///<Client connections
362  char_t rootDir[FTP_SERVER_MAX_ROOT_DIR_LEN + 1]; ///<Root directory
363  FtpServerConnectCallback connectCallback; ///<Connection callback function
364  FtpServerDisconnectCallback disconnectCallback; ///<Disconnection callback function
365 #if (FTP_SERVER_TLS_SUPPORT == ENABLED)
366  FtpServerTlsInitCallback tlsInitCallback; ///<TLS initialization callback function
367 #endif
368  FtpServerCheckUserCallback checkUserCallback; ///<User verification callback function
369  FtpServerCheckPasswordCallback checkPasswordCallback; ///<Password verification callback function
370  FtpServerGetFilePermCallback getFilePermCallback; ///<Callback used to retrieve file permissions
371  FtpServerUnknownCommandCallback unknownCommandCallback; ///<Unknown command callback function
373 
374 
375 /**
376  * @brief Control or data channel
377  **/
378 
379 typedef struct
380 {
381  FtpServerChannelState state; ///<Channel state
382  Socket *socket; ///<Underlying TCP socket
383 #if (FTP_SERVER_TLS_SUPPORT == ENABLED)
384  TlsContext *tlsContext; ///<TLS context
385 #endif
387 
388 
389 /**
390  * @brief FTP client connection
391  **/
392 
394 {
395  FtpServerContext *context; ///<FTP server context
396  NetInterface *interface; ///<Underlying network interface
397  bool_t userLoggedIn; ///<This flag tells whether the user is logged in
398  systime_t timestamp; ///<Time stamp to manage timeout
399  FtpServerChannel controlChannel; ///<Control channel
400  FtpServerChannel dataChannel; ///<Data channel
401  FsFile *file; ///<File pointer
402  FsDir *dir; ///<Directory pointer
403  bool_t passiveMode; ///<Passive data transfer
404  IpAddr remoteIpAddr; ///<Remote IP address
405  uint16_t remotePort; ///<Remote port number
407  char_t homeDir[FTP_SERVER_MAX_HOME_DIR_LEN + 1]; ///<Home directory
408  char_t currentDir[FTP_SERVER_MAX_PATH_LEN + 1]; ///<Current directory
410  char_t command[FTP_SERVER_MAX_LINE_LEN + 1]; ///<Incoming command
411  size_t commandLen; ///<Number of bytes available in the command buffer
412  char_t response[FTP_SERVER_MAX_LINE_LEN + 1]; ///<Response buffer
413  size_t responseLen; ///<Number of bytes available in the response buffer
414  size_t responsePos; ///<Current position in the response buffer
415  char_t buffer[FTP_SERVER_BUFFER_SIZE]; ///<Memory buffer for input/output operations
416  size_t bufferLength; ///<Length of the buffer, in bytes
417  size_t bufferPos; ///<Current position in the buffer
418 };
419 
420 
421 /**
422  * @brief FTP server context
423  **/
424 
426 {
427  FtpServerSettings settings; ///<User settings
428  bool_t running; ///<Operational state of the FTP server
429  bool_t stop; ///<Stop request
430  OsEvent event; ///<Event object used to poll the sockets
431  OsTaskParameters taskParams; ///<Task parameters
432  OsTaskId taskId; ///<Task identifier
433  Socket *socket; ///<Listening socket
434  uint16_t passivePort; ///<Current passive port number
435  FtpClientConnection *connections; ///<Client connections
436  SocketEventDesc eventDesc[2 * FTP_SERVER_MAX_CONNECTIONS + 1]; ///<The events the application is interested in
437 #if (FTP_SERVER_TLS_SUPPORT == ENABLED && TLS_TICKET_SUPPORT == ENABLED)
438  TlsTicketContext tlsTicketContext; ///<TLS ticket encryption context
439 #endif
440  FTP_SERVER_PRIVATE_CONTEXT ///<Application specific context
441 };
442 
443 
444 //FTP server related functions
446 
448  const FtpServerSettings *settings);
449 
452 
454  const char_t *homeDir);
455 
456 void ftpServerTask(FtpServerContext *context);
457 
458 void ftpServerDeinit(FtpServerContext *context);
459 
460 //C++ guard
461 #ifdef __cplusplus
462 }
463 #endif
464 
465 #endif
size_t responsePos
Current position in the response buffer.
Definition: ftp_server.h:414
#define FtpServerContext
Definition: ftp_server.h:208
@ FTP_CHANNEL_STATE_RECEIVE
Definition: ftp_server.h:231
OsTaskParameters taskParams
Task parameters.
Definition: ftp_server.h:431
Control or data channel.
Definition: ftp_server.h:380
uint_t(* FtpServerGetFilePermCallback)(FtpClientConnection *connection, const char_t *user, const char_t *path)
Callback used to retrieve file permissions.
Definition: ftp_server.h:334
error_t(* FtpServerUnknownCommandCallback)(FtpClientConnection *connection, const char_t *command, const char_t *param)
Unknown command callback function.
Definition: ftp_server.h:342
int bool_t
Definition: compiler_port.h:53
Socket * socket
Listening socket.
Definition: ftp_server.h:433
uint16_t passivePortMin
Passive port range (lower value)
Definition: ftp_server.h:356
OsTaskId taskId
Task identifier.
Definition: ftp_server.h:432
FtpServerConnectCallback connectCallback
Connection callback function.
Definition: ftp_server.h:363
IP network address.
Definition: ip.h:90
FtpClientConnection * connections
Client connections.
Definition: ftp_server.h:435
FtpServerChannelState
Channel state.
Definition: ftp_server.h:225
@ FTP_CHANNEL_STATE_IDLE
Definition: ftp_server.h:229
@ FTP_ACCESS_ALLOWED
Definition: ftp_server.h:268
@ FTP_CHANNEL_STATE_RNFR
Definition: ftp_server.h:241
Event object.
#define FTP_SERVER_MAX_PATH_LEN
Definition: ftp_server.h:130
error_t ftpServerInit(FtpServerContext *context, const FtpServerSettings *settings)
FTP server initialization.
Definition: ftp_server.c:120
#define FTP_SERVER_MAX_USERNAME_LEN
Definition: ftp_server.h:123
FtpServerChannel controlChannel
Control channel.
Definition: ftp_server.h:399
void(* FtpServerDisconnectCallback)(FtpClientConnection *connection, const IpAddr *clientIpAddr, uint16_t clientPort)
Disconnection callback function.
Definition: ftp_server.h:297
@ FTP_SERVER_MODE_EXPLICIT_TLS
Definition: ftp_server.h:257
FTP server context.
Definition: ftp_server.h:426
NetInterface * interface
Underlying network interface.
Definition: ftp_server.h:353
@ FTP_CHANNEL_STATE_SHUTDOWN_TLS
Definition: ftp_server.h:242
FtpServerContext * context
FTP server context.
Definition: ftp_server.h:395
void ftpServerTask(FtpServerContext *context)
FTP server task.
Definition: ftp_server.c:397
NetInterface * interface
Underlying network interface.
Definition: ftp_server.h:396
uint16_t dataPort
FTP data port number.
Definition: ftp_server.h:355
FtpAccessStatus
FTP server access status.
Definition: ftp_server.h:266
uint16_t remotePort
Remote port number.
Definition: ftp_server.h:405
Directory descriptor.
Definition: fs_port_posix.h:60
char_t buffer[FTP_SERVER_BUFFER_SIZE]
Memory buffer for input/output operations.
Definition: ftp_server.h:415
#define FTP_SERVER_MAX_ROOT_DIR_LEN
Definition: ftp_server.h:109
uint32_t Ipv4Addr
IPv4 network address.
Definition: ipv4.h:297
uint_t mode
Security modes.
Definition: ftp_server.h:359
Structure describing socket events.
Definition: socket.h:426
@ FTP_PASSWORD_REQUIRED
Definition: ftp_server.h:269
uint16_t passivePortMax
Passive port range (upper value)
Definition: ftp_server.h:357
void ftpServerGetDefaultSettings(FtpServerSettings *settings)
Initialize settings with default values.
Definition: ftp_server.c:60
uint_t(* FtpServerCheckPasswordCallback)(FtpClientConnection *connection, const char_t *user, const char_t *password)
Password verification callback function.
Definition: ftp_server.h:326
FTP server settings.
Definition: ftp_server.h:351
@ FTP_CHANNEL_STATE_CLOSED
Definition: ftp_server.h:226
@ FTP_CHANNEL_STATE_AUTH_TLS_1
Definition: ftp_server.h:233
FtpServerMode
Security modes.
Definition: ftp_server.h:254
FtpServerChannelState state
Channel state.
Definition: ftp_server.h:381
OsTaskParameters task
Task parameters.
Definition: ftp_server.h:352
@ FTP_CHANNEL_STATE_RETR
Definition: ftp_server.h:238
Session ticket encryption context.
Definition: tls_ticket.h:91
IpAddr remoteIpAddr
Remote IP address.
Definition: ftp_server.h:404
char_t user[FTP_SERVER_MAX_USERNAME_LEN+1]
User name.
Definition: ftp_server.h:406
@ FTP_CHANNEL_STATE_WAIT_ACK
Definition: ftp_server.h:243
FtpServerCheckPasswordCallback checkPasswordCallback
Password verification callback function.
Definition: ftp_server.h:369
@ FTP_CHANNEL_STATE_NLST
Definition: ftp_server.h:237
FtpServerSettings settings
User settings.
Definition: ftp_server.h:427
FtpServerGetFilePermCallback getFilePermCallback
Callback used to retrieve file permissions.
Definition: ftp_server.h:370
#define TlsContext
Definition: tls.h:36
@ FTP_ACCESS_DENIED
Definition: ftp_server.h:267
error_t
Error codes.
Definition: error.h:43
error_t ftpServerStart(FtpServerContext *context)
Start FTP server.
Definition: ftp_server.c:210
@ FTP_CHANNEL_STATE_LISTEN
Definition: ftp_server.h:228
Ipv4Addr publicIpv4Addr
Public IPv4 address to be used in PASV replies.
Definition: ftp_server.h:358
@ FTP_CHANNEL_STATE_AUTH_TLS_2
Definition: ftp_server.h:234
char_t command[FTP_SERVER_MAX_LINE_LEN+1]
Incoming command.
Definition: ftp_server.h:410
@ FTP_CHANNEL_STATE_SHUTDOWN_TX
Definition: ftp_server.h:244
bool_t userLoggedIn
This flag tells whether the user is logged in.
Definition: ftp_server.h:397
#define NetInterface
Definition: net.h:36
TlsContext * tlsContext
TLS context.
Definition: ftp_server.h:384
bool_t passiveMode
Passive data transfer.
Definition: ftp_server.h:403
char_t currentDir[FTP_SERVER_MAX_PATH_LEN+1]
Current directory.
Definition: ftp_server.h:408
bool_t stop
Stop request.
Definition: ftp_server.h:429
General definitions for cryptographic algorithms.
@ FTP_CHANNEL_STATE_SHUTDOWN_RX
Definition: ftp_server.h:245
@ FTP_CHANNEL_STATE_USER
Definition: ftp_server.h:235
Task parameters.
uint16_t port
FTP command port number.
Definition: ftp_server.h:354
#define FTP_SERVER_MAX_HOME_DIR_LEN
Definition: ftp_server.h:116
@ FTP_CHANNEL_STATE_APPE
Definition: ftp_server.h:240
TlsTicketContext tlsTicketContext
TLS ticket encryption context.
Definition: ftp_server.h:438
OsEvent event
Event object used to poll the sockets.
Definition: ftp_server.h:430
#define FTP_SERVER_PRIVATE_CONTEXT
Definition: ftp_server.h:186
FsFile * file
File pointer.
Definition: ftp_server.h:401
#define FTP_SERVER_BUFFER_SIZE
Definition: ftp_server.h:102
File system abstraction layer.
error_t ftpServerSetHomeDir(FtpClientConnection *connection, const char_t *homeDir)
Set home directory.
Definition: ftp_server.c:370
TLS session tickets.
@ FTP_CHANNEL_STATE_DISCARD
Definition: ftp_server.h:232
@ FTP_FILE_PERM_LIST
Definition: ftp_server.h:279
FtpServerTlsInitCallback tlsInitCallback
TLS initialization callback function.
Definition: ftp_server.h:366
uint32_t systime_t
System time.
char char_t
Definition: compiler_port.h:48
SocketEventDesc eventDesc[2 *FTP_SERVER_MAX_CONNECTIONS+1]
The events the application is interested in.
Definition: ftp_server.h:436
size_t commandLen
Number of bytes available in the command buffer.
Definition: ftp_server.h:411
FsDir * dir
Directory pointer.
Definition: ftp_server.h:402
char_t path[FTP_SERVER_MAX_PATH_LEN+1]
Pathname.
Definition: ftp_server.h:409
FtpFilePerm
File permissions.
Definition: ftp_server.h:278
FTP client connection.
Definition: ftp_server.h:394
@ FTP_CHANNEL_STATE_LIST
Definition: ftp_server.h:236
size_t responseLen
Number of bytes available in the response buffer.
Definition: ftp_server.h:413
error_t(* FtpServerTlsInitCallback)(FtpClientConnection *connection, TlsContext *tlsContext)
TLS initialization callback function.
Definition: ftp_server.h:308
FtpServerChannel dataChannel
Data channel.
Definition: ftp_server.h:400
error_t ftpServerStop(FtpServerContext *context)
Stop FTP server.
Definition: ftp_server.c:319
#define Socket
Definition: socket.h:36
@ FTP_CHANNEL_STATE_SEND
Definition: ftp_server.h:230
FtpClientConnection * connections
Client connections.
Definition: ftp_server.h:361
char_t homeDir[FTP_SERVER_MAX_HOME_DIR_LEN+1]
Home directory.
Definition: ftp_server.h:407
bool_t running
Operational state of the FTP server.
Definition: ftp_server.h:428
TLS (Transport Layer Security)
Socket API.
Socket * socket
Underlying TCP socket.
Definition: ftp_server.h:382
#define FTP_SERVER_MAX_LINE_LEN
Definition: ftp_server.h:95
FtpServerDisconnectCallback disconnectCallback
Disconnection callback function.
Definition: ftp_server.h:364
@ FTP_SERVER_MODE_PLAINTEXT
Definition: ftp_server.h:255
#define FtpClientConnection
Definition: ftp_server.h:212
uint16_t passivePort
Current passive port number.
Definition: ftp_server.h:434
FtpServerCheckUserCallback checkUserCallback
User verification callback function.
Definition: ftp_server.h:368
FtpServerUnknownCommandCallback unknownCommandCallback
Unknown command callback function.
Definition: ftp_server.h:371
@ FTP_CHANNEL_STATE_STOR
Definition: ftp_server.h:239
@ FTP_FILE_PERM_READ
Definition: ftp_server.h:280
#define FTP_SERVER_MAX_CONNECTIONS
Definition: ftp_server.h:67
size_t bufferPos
Current position in the buffer.
Definition: ftp_server.h:417
thread_t * OsTaskId
Task identifier.
uint_t maxConnections
Maximum number of client connections.
Definition: ftp_server.h:360
char_t response[FTP_SERVER_MAX_LINE_LEN+1]
Response buffer.
Definition: ftp_server.h:412
size_t bufferLength
Length of the buffer, in bytes.
Definition: ftp_server.h:416
unsigned int uint_t
Definition: compiler_port.h:50
TCP/IP stack core.
uint_t(* FtpServerCheckUserCallback)(FtpClientConnection *connection, const char_t *user)
User verification callback function.
Definition: ftp_server.h:318
systime_t timestamp
Time stamp to manage timeout.
Definition: ftp_server.h:398
void ftpServerDeinit(FtpServerContext *context)
Release FTP server context.
Definition: ftp_server.c:541
error_t(* FtpServerConnectCallback)(FtpClientConnection *connection, const IpAddr *clientIpAddr, uint16_t clientPort)
Connection callback function.
Definition: ftp_server.h:289
@ FTP_CHANNEL_STATE_CONNECT_TLS
Definition: ftp_server.h:227
@ FTP_FILE_PERM_WRITE
Definition: ftp_server.h:281
@ FTP_SERVER_MODE_IMPLICIT_TLS
Definition: ftp_server.h:256
void FsFile
File descriptor.
Definition: fs_port_fatfs.h:60