STM32上FTP的是实现源代码

上传人:飞*** 文档编号:47491032 上传时间:2018-07-02 格式:PDF 页数:64 大小:61.42KB
返回 下载 相关 举报
STM32上FTP的是实现源代码_第1页
第1页 / 共64页
STM32上FTP的是实现源代码_第2页
第2页 / 共64页
STM32上FTP的是实现源代码_第3页
第3页 / 共64页
STM32上FTP的是实现源代码_第4页
第4页 / 共64页
STM32上FTP的是实现源代码_第5页
第5页 / 共64页
点击查看更多>>
资源描述

《STM32上FTP的是实现源代码》由会员分享,可在线阅读,更多相关《STM32上FTP的是实现源代码(64页珍藏版)》请在金锄头文库上搜索。

1、/ FTP server with support for only one user - we want to use it for file uploads #include “config.h“ #define _CLOSE_ERROR / test option #if defined USE_FTP /* = */ /* local definitions */ /* = */ #ifdef STRING_OPTIMISATION / 14 #define _fnBufferDec(x, y, z) fnBufferDec(x, y, z) / new decimal string

2、routine #else #define _fnBufferDec(x, y, z) fnDebugDec(x, y, z) / original decimal string routine #endif #if !defined FTP_DISPLAY_USER_FILES #undef INTERNAL_USER_FILES #endif #define OWN_TASK TASK_FTP #define FTP_STATE_CLOSED 0 / FTP command states #define FTP_STATE_CONNECTED 1 #define FTP_STATE_LOG

3、IN 2 #define FTP_STATE_ACTIVE_USER 3 #define FTP_STATE_PREPARE_CLOSE 4 #define MSG_DO_NOTHING 0 / Message states #define MSG_REPEAT_DA TA 1 #define MSG_REPEAT_CONTROL 2 #define MSG_SERVER_READY 10 / Command messages #define MSG_DIR_OK 11 #define MSG_ENTER_PASS 12 #define MSG_LOG_SUCCESS 13 #define M

4、SG_LOG_FAILED 14 #define MSG_FTP_DA TA 15 #define MSG_FTP_TYPE 16 #define MSG_FTP_DENIED 17 #define MSG_FTP_DIR 18 #define MSG_FTP_OK 19 #define MSG_DIR_CHANGED 20 #define MSG_FTP_UNKNOWN 21 #define MSG_DEL_OK 22 #define MSG_FILE_LENGTH 23 #define MSG_PASV_OK 24 #define MSG_BAD_DA TA_CONNECTION 25 #

5、define MSG_NOT_SUPPORTED 26 #define MSG_FTP_QUITTING 27 #define MSG_FTP_READY_FOR_RENAME 28 #define MSG_FTP_RENAME_SUCCESSFUL 29 #define MSG_DIR 40 / Data messages #define MSG_UPLOAD 41 #define FIRST_DA TA_MESSAGE MSG_DIR #ifdef FTP_VERIFY_DA TA_PORT / 4 if checking is enable modify return type of f

6、nGetDataPort() #define RTN_DATA_PORT int #else #define RTN_DATA_PORT void #endif #ifdef FTP_SUPPORTS_NAME_DISPLAY static const CHAR cFileType = , 1, , 5, 0, 2, , 5, 0, 2, ; static const CHAR cFileDate = , M, a, y, , 1, , 2, 0, 0, 9, ; / 13 static const CHAR cFileRights = -, r, w, x, r, w, x, r, w, x

7、; #define LENGTH_OF_FILE_TYPE sizeof(cFileType) #define LENGTH_OF_FILE_LENGTH 6 / 999k is max possible file size #define LENGTH_OF_FILE_DATE sizeof(cFileDate) #ifdef INTERNAL_USER_FILES / 13 #define LENGTH_OF_FILE_NAME MAX_FILE_NAME_LENGTH #else #define LENGTH_OF_FILE_NAME 7 / 13 reduced by 1 #endif

8、 #define LENGTH_OF_FILE_INFO (sizeof(cFileRights) + LENGTH_OF_FILE_TYPE + LENGTH_OF_FILE_LENGTH + LENGTH_OF_FILE_DATE + LENGTH_OF_FILE_NAME) #ifndef FILE_NAMES_PER_FTP_FRAME #define FILE_NAMES_PER_FTP_FRAME (LAN_BUFFER_SIZE - ETH_HEADER_LEN - IP_MIN_HLEN - MIN_TCP_HLEN - 22) / LENGTH_OF_FILE_INFO) #

9、endif #define FTP_DATA_BUFFER_LENGTH (FILE_NAMES_PER_FTP_FRAME * LENGTH_OF_FILE_INFO) / space for 6 files to be displayed in 1 message #else #define FTP_DATA_BUFFER_LENGTH 100 #define FILE_NAMES_PER_FTP_FRAME FTP_DATA_BUFFER_LENGTH / 10 #endif #define FTP_MODE_ASCII 0 #define FTP_MODE_BINARY 1 #defi

10、ne DATA_INACTIVE 0 #define DO_LIST 1 #define DO_SAVE 2 #define DOING_SA VE 3 #define SAVE_COMPLETE 4 #define WAIT_COMPLETE 5 #define DO_UPLOAD 6 #define DOING_UPLOAD 7 #ifdef SUB_FILE_SIZE #define SUBFILE_WRITE , ucSubFileInProgress #define SUB_FILE_ON ,SUB_FILE_TYPE #else #define SUBFILE_WRITE #def

11、ine SUB_FILE_ON #endif /* = */ /* local structure definitions */ /* = */ typedef struct stTCP_FTP_MESSAGE / definition of a data frame structure TCP_HEADER tTCP_Header; / reserve header space unsigned char ucTCP_MessageFTP_DA TA_BUFFER_LENGTH; / space for content TCP_FTP_MESSAGE; /* = */ /* local fu

12、nction prototype declarations */ /* = */ static int fnFTPListener(USOCKET cSocket, unsigned char ucEvent, unsigned char *ucIp_Data, unsigned short usPortLen); static int fnFTP_Data_Listener(USOCKET cSocket, unsigned char ucEvent, unsigned char *ucIp_Data, unsigned short usPortLen); static RTN_DATA_P

13、ORT fnGetDataPort(CHAR *ucIP_Port); static signed short fnSendFTP(unsigned char ucMsg); /* = */ /* constants */ /* = */ #ifdef SUPPORT_MIME_IDENTIFIER static unsigned char ucMimeType; #endif #ifdef FTP_UTFAT / 17 static UTDIRECTORY *ptr_utDirectory = 0; / directory object for a single user static UT

14、LISTDIRECTORY utListDirectory; / list directory object for a single user static UTLISTDIRECTORY utListLastDirectory; / backup in case of need to repeat static FILE_LISTING fileList = 0; static UTFILE utFile = 0; #endif static const CHAR cFTPServerReady = FTP_WELCOME_RESPONSE; static const CHAR cFTPBadPass = “530 Log BAD.rn“; static const CHAR cFTPEnterPass = “331 Enter pass.rn“; static const CHAR cFTPloginSuccessful = “230

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 行业资料 > 其它行业文档

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号