Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062 #ifdef __cplusplus
00063 extern "C" {
00064 #endif
00065
00066 #ifndef __ARNFTP_H__
00067 #define __ARNFTP_H__
00068
00069 typedef unsigned char arn_uCHAR;
00070 typedef unsigned short arn_uSHORT;
00071 typedef unsigned long arn_uLONG;
00072 typedef arn_uLONG arn_uINT;
00073
00074 typedef signed char arn_sCHAR;
00075 typedef signed short arn_sSHORT;
00076 typedef signed long arn_sLONG;
00077 typedef arn_sLONG arn_sINT;
00078
00079 typedef char arn_CHAR;
00080 typedef short arn_SHORT;
00081 typedef long arn_LONG;
00082 typedef int arn_INT;
00083
00084
00085
00086 #define arnTRUE ((arn_uCHAR) 1)
00087 #define arnFALSE ((arn_uCHAR) 0)
00088 typedef arn_uCHAR arn_BOOL;
00089
00090 #define MAX_FILENAME_LEN 128
00091 #define FTP_FLAG_CMDREQUEST 0x01
00092 #define FTP_FLAG_DATAPENDING 0x02
00093 #define FTP_FLAG_LASTDATAACK 0x04
00094 #define FTP_FLAG_CTRL 0x80
00095 #define FTP_FLAG_DATA 0x40
00096
00097 struct ftp_state {
00098 struct uip_conn * dconn;
00099 arn_uCHAR* dataptr;
00100 arn_uLONG count;
00101 arn_uCHAR* fSAddr;
00102 arn_uLONG fSize;
00103 arn_uSHORT errorCode;
00104 arn_uSHORT localdataport;
00105 arn_uSHORT remotedataport;
00106 arn_uSHORT remotectrlport;
00107 arn_uCHAR Status;
00108 arn_uCHAR CmdSnt;
00109 arn_uCHAR AnsRcv;
00110 arn_uCHAR flags;
00111 arn_CHAR fname[MAX_FILENAME_LEN];
00112 arn_uCHAR data[MAX_FILENAME_LEN + 8];
00113 };
00114
00115
00116 void ftp_init(void);
00117 void ftp_appcall(void);
00118
00119
00120 typedef enum ftp_cmd_status {
00121 ftpcs_NONE = 0,
00122 ftpcs_INPROGRESS,
00123 ftpcs_SUCCESS,
00124 ftpcs_FAILED,
00125 ftpcs_USERNAME_REQ,
00126 ftpcs_PASSWORD_REQ
00127 } ftp_cmd_status_t;
00128 ftp_cmd_status_t ftp_connect(arn_CHAR* host,arn_uSHORT rport,struct uip_conn **sconn);
00129 ftp_cmd_status_t ftp_login(const struct uip_conn *sconn,arn_CHAR* username);
00130 ftp_cmd_status_t ftp_password(const struct uip_conn *sconn,arn_CHAR* password);
00131 ftp_cmd_status_t ftp_syst(const struct uip_conn *sconn,arn_CHAR* res);
00132 ftp_cmd_status_t ftp_port(const struct uip_conn *sconn,arn_uSHORT ldataport);
00133 ftp_cmd_status_t ftp_pasv(const struct uip_conn *sconn);
00134 ftp_cmd_status_t ftp_send(const struct uip_conn *sconn,arn_CHAR* filename,arn_uCHAR* sadd,arn_uLONG size);
00135 ftp_cmd_status_t ftp_quit(const struct uip_conn *sconn);
00136
00137
00138 #define STS_NONE 0
00139 #define STS_ERROR (STS_NONE + 1)
00140 #define STS_WAITFORCONN (STS_ERROR + 1)
00141 #define STS_CONNECTED (STS_WAITFORCONN + 1)
00142 #define STS_SENDINGFILE (STS_CONNECTED + 1)
00143 #define STS_UPOLOADOK (STS_SENDINGFILE + 1)
00144 #define STS_LOGGINGIN (STS_UPOLOADOK + 1)
00145 #define STS_LOGGEDIN (STS_LOGGINGIN + 1)
00146 #define STS_SYST_INPROG (STS_LOGGEDIN + 1)
00147 #define STS_SYST_OK (STS_SYST_INPROG + 1)
00148 #define STS_PORT_INPROG (STS_SYST_OK + 1)
00149 #define STS_PORT_OK (STS_PORT_INPROG + 1)
00150 #define STS_DATACONN_INPROG (STS_PORT_OK + 1)
00151 #define STS_DATACONN_OK (STS_DATACONN_INPROG + 1)
00152 #define STS_STOR_INPROG (STS_DATACONN_OK + 1)
00153 #define STS_START_DATASTORE (STS_STOR_INPROG + 1)
00154 #define STS_SENDDATA_INPROG (STS_START_DATASTORE + 1) // 16 , 0x10
00155 #define STS_SENDDATA_ENDING (STS_SENDDATA_INPROG + 1)
00156 #define STS_SENDDATA_OK (STS_SENDDATA_ENDING + 1)
00157 #define STS_DATACONN_CLOSED_OK (STS_SENDDATA_OK + 1)
00158 #define STS_QUIT_INPROG (STS_DATACONN_CLOSED_OK + 1)
00159 #define STS_QUIT_OK (STS_QUIT_INPROG + 1)
00160 #define STS_IDLE (STS_QUIT_OK + 1)
00161 arn_uCHAR ftp_getStatus(const struct uip_conn *sconn);
00162
00163 #define ERRC_NONE 0
00164 #define ERRC_HOSTNAMENOTIP (ERRC_NONE + 1)
00165 #define ERRC_CONN (ERRC_HOSTNAMENOTIP + 1)
00166 #define ERRC_FNAMETOLOONG (ERRC_CONN + 1)
00167 #define ERRC_SRV_WM (ERRC_FNAMETOLOONG + 1)
00168 #define ERRC_LOGIN (ERRC_SRV_WM + 1)
00169 #define ERRC_SYST (ERRC_LOGIN + 1)
00170 #define ERRC_PORT (ERRC_SYST + 1)
00171 #define ERRC_CONN_DATA (ERRC_PORT + 1)
00172 #define ERRC_STOR (ERRC_CONN_DATA + 1)
00173 #define ERRC_QUIT (ERRC_STOR + 1)
00174 #define ERRC_PASS (ERRC_QUIT + 1)
00175 arn_uCHAR ftp_getErrorCode(const struct uip_conn *sconn);
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188 #ifndef UIP_APPSTATE_SIZE
00189 #define UIP_APPSTATE_SIZE (sizeof(struct ftp_state))
00190 #endif
00191
00192
00193 #endif
00194
00195 #ifdef __cplusplus
00196 }
00197 #endif