Network Component
Version 6.3
MDK-Professional Middleware for IP Networking
|
File Transfer Protocol (FTP) is a standard network protocol used to exchange and manipulate files over a TCP/IP-based network. FTP is built on a client-server architecture and utilizes separate control and data connections between the client and server applications. FTP is used with user-based password authentication or with anonymous user access.
FTP file manipulation means that you can: create and delete files on FTP server, rename files, create folders and subfolders, print the folder listings, etc.
FTP applications were originally interactive command-line tools with a standardized command syntax. Various graphical user interfaces have been developed for all types of operating systems in use today.
FTP can be run in active or in passive mode, which control how the data connection is opened. The mode of operation is defined by the command, received from the client.
An embedded FTP Server can also be used to upload HTTP Web pages or to download log files to a remote PC. In this case, the File System Component must be used, and the Embedded Web Server must be properly configured.
The Embedded FTP server has integrated several advanced features:
The Embedded FTP Server can store files in a generic File System. All interface functions are located in FTP_Server_FS.c, which will be automatically added to your project's Network folder. The file is preconfigured for the File System Component, so no modifications are required. If you want to use another type of file system or to use a different storage media such as a hard disk, you need to add a similar file to your project.
The following functions are implemented in this module:
For access filtering the function ftp_accept_client is used. It is part of the file FTP_Server_Access.c. You need to adapt the function to the application's needs.
Code Example FTP_Server_Access.c
The multi-user login allows you to create different profiles for different users or groups of users. The profiles define the access rights to different files on the FTP server. The users which are allowed to access the FTP server are stored in an user database.
If you want to use multi-user authentication, you check the Enable User Authentication in the Net_Config_FTP_Server.h configuration file. The default account defined in the Net_Config_FTP_Server.h file is a system administrator account, which has no restrictions. All other accounts are created in a separate FTP_Server_Multiuser.c module. To add the module to your project, simply right-click on the Source group, select Add Net Item to Group, then click on User Code Template and scroll in the template files list until you find the FTP Server Multi-user template. To enable a list of users, you need to adapt the following functions that are included in this module:
The following function is included in the Network Component library rl_net.h:
Code Example FTP_Server_Multiuser.c
In case you need to notify your application about events that are happening on the FTP server, the function ftp_server_notify is to be used. It is part of the file FTP_Server_Event.c. You need to adapt the function to the application's needs.
Code Example FTP_Server_Event.c
The Network Component's FTP Server supports only a subset of standard FTP Commands. The following FTP Commands are supported:
Code | Command | Description |
---|---|---|
USER | User Name | Starts login with name identifying the user. |
PASS | Password | Continues login with the user's password. |
QUIT | Logout | Closes the user connection. |
SYST | System | Identifies the operating system at the server. |
NOOP | No Operation | Sends an OK reply. |
XNOP | No Operation | Same as NOOP |
PWD | Print Working Directory | Returns the name of the current working directory. |
XPWD | Print Working Directory | Same as PWD |
CWD | Change Working Directory | Changes the current working directory of the user. |
XCWD | Change Working Directory | Same as CWD |
CDUP | Change Directory Up | Changes working directory to the parent of the current directory. |
XCUP | Change Directory Up | Same as CDUP |
MKD | Make Directory | Creates a sub directory in the current working directory. |
XMKD | Make Directory | Same as MKD |
RMD | Remove Directory | Removes the directory. |
XRMD | Remove Directory | Same as RMD |
TYPE | Representation Type | Supports ASCII and Image types. |
PORT | Data Port | Specifies the data port to be used in data connection. |
PASV | Passive | Requests the server to listen on a data port and wait for a connection. |
LIST | List | Sends a directory listing to the user. |
NLST | Name List | Sends a directory listing to the user. |
RETR | Retrieve | Sends a file content to the user. |
STOR | Store | Saves a captured user file on server. |
APPE | Append | Appends a captured user file to an existing file on server. |
DELE | Delete | Deletes a specified file from server. |
RNFR | Rename From | Specifies the name of existing file to rename (must be followed by RNTO). |
RNTO | Rename To | Renames an existing file to new name. |
HELP | Help | Returns a list of supported commands. |
SIZE | Size | Returns the size of a specified file. |
MDTM | Last-modified Time | Returns last-modified time of a specified file. |
The FTP server configuration file Net_Config_FTP_Server.h contains the following settings: