/* * Hillstone Software. HS FTP C Source Library */ #ifndef _HS_TFTP_IF_H #define _HS_TFTP_IF_H typedef enum { HS_FTP_RC_OK, HS_FTPCLI_RC_INV_PAR, HS_FTPCLI_RC_NO_CTX, HS_FTPCLI_RC_NOTINIT, HS_FTPCLI_RC_ALRINIT, HS_FTPCLI_RC_TCPCONNFAIL, HS_FTPCLI_RC_SOCKINIT_FAIL, HS_FTPCLI_RC_INVALID_CMD, HS_FTPCLI_RC_NOTALLOC, HS_FTPCLI_NUM_ERR, } hs_tftp_rc_t; typedef enum { HS_FTPCLI_USR_EV_LOGGEDIN, // connected and logged in HS_FTPCLI_USR_EV_CLOSED, // FTP control connection closed HS_FTPCLI_USR_EV_CONNFAIL, // Failed to connect to FTP server HS_FTPCLI_USR_EV_SRVERR, // FTP session closed due to server error reply HS_FTPCLI_USR_EV_UNEXP, // Unexpected server response, session closed HS_FTPCLI_USR_EV_UNKNOWN, // Unrecognized server response HS_FTPCLI_USR_EV_NOCTX, // FTP session closed, no free contexts HS_FTPCLI_USR_EV_TIMEDOUT, // FTP session closed due to timeout HS_FTPCLI_USR_EV_NOMEM, // FTP session closed, no free memory HS_FTPCLI_USR_EV_LIST, // current directory listing HS_FTPCLI_USR_EV_CWD_FAILED,// HsFtpCliChDir function (CWD) request failed HS_FTPCLI_USR_EV_CWD_DONE, // HsFtpCliChDir function (CWD) complete HS_FTPCLI_USR_EV_RXDONE, // File receive transfer complete HS_FTPCLI_USR_EV_TXDONE, // File send transfer complete HS_FTPCLI_USR_EV_RXINCOMPL, // File receive failed, incomplete. HS_FTPCLI_USR_EV_RXSEG, // receive segment of file HS_FTPCLI_USR_EV_TXSEG, // transmit segment of file HS_FTPCLI_USR_EV_TYP_FAILED, // setting transfer type failed HS_FTPCLI_USR_EV_STOR_FAILED, // File send transfer failed HS_FTPCLI_USR_EV_ABORTED, // file transfer aborted, can be for send or receive transfer HS_FTPCLI_USR_EV_ABOR_FAILED, // ABORT command failed HS_FTPCLI_USR_EV_MKD_FAILED,// HsFtpCliCreateDir function (MKD) request failed HS_FTPCLI_USR_EV_MKD_DONE, // HsFtpCliCreateDir function (MKD) complete HS_FTPCLI_USR_EV_RMD_FAILED,// HsFtpCliRemoveDir function (RMD) request failed HS_FTPCLI_USR_EV_RMD_DONE, // HsFtpCliRemoveDir function (RMD) complete HS_FTPCLI_USR_EV_DELE_FAILED,// HsFtpCliDeleteFile function (DELE) request failed HS_FTPCLI_USR_EV_DELE_DONE, // HsFtpCliDeleteFile function (DELE) complete HS_FTPCLI_USR_EV_NOOP_DONE, // Received response to NOOP command HS_FTPCLI_USR_EV_PWD_DONE, // Received response to PWD command HS_FTPCLI_USR_EV_PWD_FAILED, // PWD failed HS_FTPCLI_USR_EV_RENAME_DONE, // Rename complete HS_FTPCLI_USR_EV_RENAME_FAILED, // rename failed } hs_ftp_usr_ev_t; typedef enum { HS_FTPC_ST_WAIT_WELCOME, HS_FTPC_ST_CHDIR_RSP, HS_FTPC_ST_LIST_WAIT_RSP, HS_FTPC_ST_WAIT_PASV_RSP, HS_FTPC_ST_WAIT_USER_RSP, HS_FTPC_ST_WAIT_PASS_RSP, HS_FTPC_ST_WAIT_LSTDATA_CONN, HS_FTPC_ST_WAIT_TYPE_RSP, HS_FTPC_ST_WAIT_RETRDATA_CONN, HS_FTPC_ST_WAIT_STORDATA_CONN, HS_FTPC_ST_STOR_WAIT_RSP, HS_FTPC_ST_RETR_WAIT_RSP, HS_FTPC_ST_STOR_SENDING, HS_FTPC_ST_WAIT_ABOR_RSP, HS_FTPC_ST_MKDIR_RSP, HS_FTPC_ST_RMDIR_RSP, HS_FTPC_ST_DELE_RSP, HS_FTPC_ST_WAIT_NOOP_RSP, HS_FTPC_ST_WAIT_PWD_RSP, HS_FTPC_ST_WAIT_RNFR_RSP, HS_FTPC_ST_WAIT_RNTO_RSP, HS_FTPC_ST_LIST_WAIT_DATA_CLOSED, HS_FTPC_ST_LOGGED_IN, } hs_ftp_information_codes_t; /* FTP module callback prototype */ typedef int ftp_callback_t(void *user_ref, int ev, long arg1, long arg2, long arg3); /* connect structure */ typedef struct hs_ftp_conn_t { /* either name or IP address may be specified, if not specified supply NULL pointer */ /* if srv_name is NULL, try to connect using srv_ip - which is a string in the form x.x.x.x */ /* if srv_name is not null, HS FTP will try to resolve name to IP address */ unsigned char *srv_name; // FTP server name unsigned char *srv_ip; // FTP server ip address unsigned short srv_port; // FTP server port unsigned char *usrname; // user name for authentication unsigned char *password; // password for authentication ftp_callback_t *callback; // callback function used by HS FTP to communicate to user application void *user_ref; // user reference association with this session } hs_ftp_conn_t; /* configuration */ typedef struct { long t1_timeout; // T1 timeout value } hs_ftp_config_t; /* stats structure */ typedef struct { __int64 total_bytes_Tx; // total number of bytes transmitted __int64 total_bytes_Rx; // total number of bytes received } hsftp_stats_t; /* * Hs FTP initialisation function */ extern int HsFtpInit(void); /* * Hs FTP clean-up function */ extern int HsFtpCleanUp(void); /* * Connect to FTP server */ extern int HsFtpCliConnect(hs_ftp_conn_t *conn, long *session_handle); /* * Disconnect from FTP Server */ extern int HsFtpCliDisconnect(long session_handle); /* * Send file to FTP server */ extern int HsFtpCliSendFile(long session_handle, unsigned char *filename); /* * Get file from FTP server */ extern int HsFtpCliGetFile(long session_handle, unsigned char *filename, __int64 fsize); /* * Get current directory listing from FTP server */ extern int HsFtpCliList(long session_handle); /* * Change directory on FTP server */ extern int HsFtpCliChDir(long session_handle, unsigned char *dir); /* * Create directory on FTP server */ extern int HsFtpCliCreateDir(long session_handle, unsigned char *dir); /* * Remove directory on FTP server */ extern int HsFtpCliRemoveDir(long session_handle, unsigned char *dir); /* * Delete file from server */ extern int HsFtpCliDeleteFile(long session_handle, unsigned char *filename); /* * Tick function to be called as often as possible from the main loop */ extern int HsFtpTick(void); /* * Return null terminated string describing HS FTP error code */ extern unsigned char *HsFtpGetErrStr(int rc); /* * Abort current receive or send transfer */ extern int HsFtpCliAbort(long session_handle); /* * Send NOOP (No Operation) command */ extern int HsFtpCliNoop(long session_handle); /* * Get current working directory */ extern int HsFtpCliGetCurrentDirectory(long session_handle); /* * Rename file or folder */ extern int HsFtpCliRename(long session_handle, unsigned char *oldname, unsigned char *newname); /* * Set configuration parameters */ extern void HsFtpSetConfig(hs_ftp_config_t *cfg); /* * Get HS FTP statistics */ extern void HsFtpGetStats(hsftp_stats_t *pStats); #endif /* _HS_TFTP_IF_H */