FTP Server

Modules

 Functions
 
 Definitions
 
 Data Structures
 

Detailed Description

For FTP server support you have to include ftplib.h in your application and link ftp.lib - FTP Server Support to your project. The FTP server makes use of the EFS Embedded File System. A usermanagement can be used to restrict file access to users: A user logged in as administrator for example may have read/write access to the Module Configuration File, a guest user will only be allowed to read this file.

The FTP server expects a list of users terminated with 0. Each user is described by a user_type:

user_type user_1 = {username, password, dirlist, 0}

Members

username : name of user, max. 30 characters, no spaces allowed
password: the user's password, or '*' as a wildcard (no password required) max. 30 characters, no spaces allowed
dirlist: a list of directories accessible for this user, this list contains pointers to the direntry_type directories defined. The list must be terminated with a 0.

Example: configure two users: an administrator and an anonymous user. The administrator is allowed to read and write the module configuration and application boot file, the anonymous user is allowed to read the Module Configuration File only.

user_type users[] =
{
{"admin", "xxxx", &cfg_dir, &app_dir, EFS_TERMINATION},
{"anonymous", "*" , &cfg_readonly, EFS_TERMINATION},
EFS_TERMINATION
};

This user list must be passed to FTP server initialization function ftp_server_init()

//****************************************************************************
// initialize ftp server; parameter is the specified user list
//****************************************************************************
ftp_serv = ftp_server_init ( users, // specified user list
NULL, // mmc support
FTP_NO_LIMIT); // max parallel connections
// 0 == no limit (heap limit only)
if ( ftp_serv == FALSE )
{
prg_exit ("ftp_server_init() failed"); // possibly insufficient heap
}

The main FTP server processing is performed by function ftp_server(). Call this function regularly with net_isq() in your main loop:

for (;;)
{
//**************************************************************************
// call net_isq() and ftp_server()
//**************************************************************************
net_isq ();
ftp_ret = ftp_server ();
if ((uint32_t)ftp_ret > FTP_NO_ERROR)
{
//************************************************************************
// print result
//************************************************************************
FTP_PrintResult (ftp_ret);
}
//**************************************************************************
// check client connections
//**************************************************************************
}