FTPs_Init()
Initializes FTP server.
Files
ftp-s.h/ftp-s.c
Prototype
CPU_BOOLEAN FTPs_Init ( NET_IP_ADDR public_addr, NET_PORT_NBR public_port, const FTPs_SECURE_CFG *p_secure_cfg);
Arguments
public_addr
IP address used for passive mode.
public_port
TCP port used for passive mode.
p_secure_cfg
Pointer to a secure configuration structure if secured connection required or
Null if secured connection is not required.
Returned Values
DEF_OK
, FTP user successfully authenticated;
DEF_FAIL
, otherwise.
Required Configuration
- The network security manager MUST be available and enabled to accept a secure FTP connection (i.e: in “net_cfg.h”,
NET_SECURE_CFG_EN
should beDEF_ENABLED
ANDNET_CFG_TRANSPORT_LAYER_SEL
should be configured for TCP). See µC/TCPIP user manual for more information about the network security manager. - A network security module MUST be included in the project (i.e: Mocana’s NanoSSL) to use the network security manager functionalities.
Notes / Warnings
- Secure FTP connections are NOT supported if the client attempts to connect in active mode.
Example Usage
#define FTPs_PASSIVE_IP_ADDR "192.168.1.2" #define FTPs_PASSIVE_PORT 2000 extern const CPU_CHAR cert[]; extern const CPU_CHAR key[]; FTPs_SECURE_CFG ftps_secure_cfg; static void AppTaskStart (void *p_arg) { NET_IP_ADDR addr; CPU_BOOLEAN success; NET_ERR net_err; AppInit_TCPIP(); (1) App_FS_Init(); (2) addr = NetASCII_Str_to_IP((CPU_CHAR *) FTPs_PASSIVE_IP_ADDR, (NET_ERR *)&net_err); ftps_secure_cfg.CertPtr = (CPU_CHAR *)&cert[0]; (3) ftps_secure_cfg.CertLen = Str_Len(cert); (4) ftps_secure_cfg.Fmt = NET_SOCK_SECURE_CERT_KEY_FMT_PEM; (5) ftps_secure_cfg.KeyPtr = (CPU_CHAR *)&key[0]; (6) ftps_secure_cfg.KeyLen = Str_Len(key); (7) ftps_secure_cfg.CertChain = DEF_NO; (8) success = FTPs_Init(addr, FTPs_PASSIVE_PORT, &ftps_secure_cfg); (9) if (success == DEF_YES) { printf("FTP secure server successfully initialized.\n\r"); } else { printf("FTP secure server initialization failed.\n\r"); } while (DEF_YES) { OSTimeDlyHMSM(0, 0, 0, 100); } }