FTPc_Open()
Establishes a connection to a FTP server.
Files
ftp-c.h/ftp-c.c
Prototype
CPU_BOOLEAN FTPc_Open ( NET_IP_ADDR server_ip, CPU_INT16U server_port, CPU_CHAR *p_user, CPU_CHAR *p_pass, const FTPc_SECURE_CFG p_secure_cfg, NET_ERR *p_err); |
Arguments
server_ip Server IP address.
server_port Server TCP port number.
p_user Username of the FTP server.
p_pass Password for specified FTP user.
p_secure_cfg Desired value for client secure mode:
p_err Pointer to variable that will receive the return error code from this function.
Returned Values
DEF_OK, FTP connection successfully established;
DEF_FAIL, otherwise.
Required Configuration
The network security manager MUST be available and enabled to open a secure FTP connection (i.e: in “net_cfg.h”, NET_SECURE_CFG_EN should be DEF_ENABLED AND NET_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
None.
Example Usage
#define FTP_SERVER_IP_ADDR "192.168.1.101" #define FTP_SERVER_PORT 21
#define FTPc_USER "anonymous" #define FTPc_PW "test@micrium.com"
NET_IP_ADDR server_addr; CPU_INT16U server_port; CPU_BOOLEAN result; NET_ERR err;
server_addr = NetASCII_Str_to_IP(FTP_SERVER_IP_ADDR, &err); server_port = FTP_SERVER_PORT;
result = FTPc_Open(server_addr, server_port, FTPc_USER, FTPc_PW, DEF_NULL &err); if (result != DEF_OK) { printf("FTPc_Open() failed.\n\r"); } |
#define FTP_SERVER_IP_ADDR "192.168.1.101" #define FTP_SERVER_PORT_SECURE 990 #define FTP_COMMON_NAME "micrium.com"
#define FTPc_USER "anonymous" #define FTPc_PW "test@micrium.com"
NET_IP_ADDR server_addr; CPU_INT16U server_port; CPU_BOOLEAN result; FTPc_SECURE_CFG ftpc_secure_cfg; NET_ERR err;
server_addr = NetASCII_Str_to_IP((CPU_CHAR *) FTP_SERVER_IP_ADDR, (NET_ERR *)&err); server_port = FTP_SERVER_PORT_SECURE;
Str_Copy(ftpc_secure_cfg.CommonName, FTP_COMMON_NAME); ftpc_secure_cfg.TrustCallback = (NET_SOCK_SECURE_TRUST_FNCT)NetSecure_TrustInvalidSig;
result = FTPc_Open((NET_IP_ADDR ) server_addr, (NET_PORT_NBR ) server_port, (CPU_CHAR *) FTPc_USER, (CPU_CHAR *) FTPc_PW, (const FTPc_SECURE_CFG *)&ftpc_secure_cfg, (NET_ERR *)&err); if (result != DEF_OK) { printf("Secure FTPc_Open() failed.\n\r"); } |