Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Anchor10502781050278 FTPc_Open() Anchor10502791050279Establishes a connection to a FTP server. Anchor10490151049015

Files

...

...

ftp-c.h/ftp-c.c

...

Prototype

CPU_INT16U server_port, CPU_CHAR *p_user, CPU_CHAR *p_pass, const FTPc_SECURE_CFG p_secure_cfg, NET_ERR
 (       FTPc_CONN        *p_conn,
                                  const  FTPc_CFG         *p_cfg,
                                  const  FTPc_SECURE_CFG  *p_secure_cfg,                                    
								         CPU_CHAR         *p_host_server, 
                                         CPU_INT16U        port_nbr, 
                                         CPU_CHAR         *p_user, 
                                         CPU_CHAR         *p_pass,
                                         FTPc_ERR         *p_err);
tr
HTML Table
classCode_Listing
Table Row (tr)
Table Cell (td)
rowspan5
Anchor
10490191049019
Code Block
          CPU_BOOLEAN  FTPc_Open
( NET_IP_ADDR server_ip,
Anchor
10490201049020
Anchor
10490211049021
Anchor
10501881050188
Anchor
10501891050189
Anchor
10494881049488

Arguments

...

p_conn

Pointer to FTPc Connection object.

p_cfg

Pointer to FTPc Configuration object.

p_secuce_cfg

Pointer to FTPc Secure Configuration object.
DEF_NULL, if secured connection is not required

p_host_server

Pointer to hostname or IP address string of the server.

port_nbr 

Server TCP port number.

...

p_user 

Username of the FTP server.

...

...

p_pass 

Password for specified FTP user.

...

classWebWorks_Indent_1

...

classWebWorks_Indent_1

...

classWebWorks_Indent_1

...

classWebWorks_Indent_1

...

p_err 

Pointer to variable that will receive the return error code from this function.

...

TFTPc_ERR_NONE
FTPc_ERR_CONN_FAIL
FTPc_ERR_TX_CMD
FTPc_ERR_RX_CMD_RESP_FAIL
FTPc_ERR_LOGGEDIN       

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_TCP_CFG_

...

  • EN should be

...

  • DEF_ENABLED). 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 #define

          #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) {
                      21
           
          #define  FTPc_USER                    "anonymous"
          #define  FTPc_PW               "test@micrium.com"
           
          FTPc_CONN    conn; 
          CPU_INT16U   server_port;
          CPU_BOOLEAN  result;
          FTPc_ERR     err;
           
          server_port = FTP_SERVER_PORT;
           
          result = FTPc_Open(&conn, DEF_NULL, DEF_NULL, FTP_SERVER_IP_ADDR, server_port, FTPc_USER, FTPc_PW, &err);
          if (result != DEF_OK) {
              printf("FTPc_Open() failed.\n\r");
} #define

          }
HTML Table
classCode_Listing
Table Row (tr)
Table Cell (td)
rowspan8
Anchor
10496701049670
Code Block
          #define  FTP_SERVER_IP_ADDR       "192.168.1.101"
Anchor
10496711049671
Anchor
10496721049672
Anchor
10496731049673
Anchor
10496741049674
Anchor
10496751049675
Anchor
10496761049676
Anchor
10496771049677
Anchor
10496781049678
Anchor
10496791049679
Anchor
10496801049680
Anchor
10496811049681
Anchor
10496821049682
Anchor
10496831049683
Anchor
10496841049684
Anchor
10496851049685
Anchor
10496861049686
Anchor
10496871049687
Anchor
10496881049688
Table Row (tr)
Table Row (tr)
Table Row (tr)
Table Row (tr)
Table Row (tr)
Table Row (tr)
Table Row (tr)
HTML Table
classCode_Listing
Table Row (tr)
Table Cell (td)
rowspan8
Anchor
10497121049712


#define

          #define  FTP_SERVER_PORT_SECURE
990 #define
               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;  

           
          #define  FTPc_USER                    "anonymous"
          #define  FTPc_PW               "test@micrium.com"
           
          FTPc_CONN        conn;
          CPU_INT16U       server_port;
          CPU_BOOLEAN      result;
          FTPc_SECURE_CFG  ftpc_secure_cfg;
          FTPc_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()

           
          result = FTPc_Open(&conn,
                              DEF_NULL,
                             &ftpc_secure_cfg,
                              FTP_SERVER_IP_ADDR
                              server_port,                            
                              FTPc_USER,                             
                              FTPc_PW,                                                     
                             &err);
          if (result != DEF_OK) { 
              printf("Secure FTPc_Open() failed.\n\r");
} tr
  
          } 
Code Block

          #define  FTP_SERVER_IP_ADDR       "192.168.1.101"
Anchor
10497131049713
Anchor
10509301050930
Anchor
10497141049714
Anchor
10497151049715
Anchor
10497161049716
Anchor
10503591050359
Anchor
10497191049719
Anchor
10497201049720
Anchor
10497211049721
Anchor
10507481050748
Anchor
10497221049722
Anchor
10497231049723
Anchor
10508611050861
Anchor
10508691050869
Anchor
10508621050862
Anchor
10508631050863
Anchor
10509271050927
Anchor
10507171050717
Anchor
10507181050718
Anchor
10507191050719
Anchor
10508111050811
Anchor
10508121050812
Anchor
10507231050723
Anchor
10507241050724
Anchor
10507251050725
Anchor
10507261050726
Anchor
10507271050727
Anchor
10507281050728
Anchor
10497301049730
Table Row (tr)
Table Row (tr)
Table Row (tr)
Table Row (tr)
Table Row (tr)
Table Row (tr)