1 /*
2  * FreeRTOS V202212.00
3  * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a copy of
6  * this software and associated documentation files (the "Software"), to deal in
7  * the Software without restriction, including without limitation the rights to
8  * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9  * the Software, and to permit persons to whom the Software is furnished to do so,
10  * subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice shall be included in all
13  * copies or substantial portions of the Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17  * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19  * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21  *
22  * https://www.FreeRTOS.org
23  * https://github.com/FreeRTOS
24  *
25  */
26 
27 #ifndef __FTPCMD_H__
28 
29 #define __FTPCMD_H__
30 
31 #define REPL_110              "110 Restart marker reply.\r\n"
32 #define REPL_120              "120 Try again in 2 minutes.\r\n"
33 #define REPL_125              "125 Data connection already open; transfer starting.\r\n"
34 #define REPL_150              "150 File status okay; about to open data connection.\r\n"
35 #define REPL_200              "200 NOOP command successful.\r\n"
36 #define REPL_200_PROGRESS     "200 NOOP: data transfer in progress.\r\n"
37 #define REPL_202              "202 Command not implemented, superfluous at this site.\r\n"
38 #define REPL_211              "221 System status, or system help reply.\r\n"
39 #define REPL_211_STATUS       "221-status of %s.\r\n"
40 #define REPL_211_END          "221 End of status.\r\n"
41 #define REPL_212              "212 Directory status.\r\n"
42 #define REPL_213              "213 File status.\r\n"
43 #define REPL_214              "214 Help message.\r\n"
44 #define REPL_214_END          "214 End Help message.\r\n"
45 #define REPL_215              "215 %s system type.\r\n"
46 #define REPL_220              "220 Service ready for new user.\r\n"
47 #define REPL_221              "221 Service closing control connection.\r\n"
48 #define REPL_225              "225 Data connection open; no transfer in progress.\r\n"
49 #define REPL_226              "226 Closing data connection.\r\n"
50 #define REPL_227              "227 Entering Passive Mode (%s,%s,%s,%s,%s,%s).\r\n"
51 #define REPL_227_D            "227 Entering Passive Mode (%u,%u,%u,%u,%u,%u).\r\n"
52 #define REPL_230              "230 User logged in, proceed.\r\n"
53 #define REPL_250              "250 Requested file action okay, completed.\r\n"
54 #define REPL_257              "257 %s created.\r\n"
55 /*	#define REPL_257_PWD "257 \"%s\" is current working dir.\r\n" */
56 #define REPL_257_PWD          "257 \"%s\"\r\n"
57 #define REPL_331              "331 Only anonymous user is accepted.\r\n"
58 #define REPL_331_ANON         "331 Anonymous login okay\r\n"
59 #define REPL_332              "332 Need account for login.\r\n"
60 #define REPL_350              "350 Requested file action pending further information.\r\n"
61 #define REPL_421              "421 Service not available, closing control connection.\r\n"
62 #define REPL_425              "425 Can't open data connection.\r\n"
63 #define REPL_426              "426 Connection closed; transfer aborted.\r\n"
64 #define REPL_450              "450 Requested file action not taken.\r\n"
65 #define REPL_451              "451 Requested action aborted. Local error in processing.\r\n"
66 #define REPL_452              "452 Requested action not taken.\r\n"
67 #define REPL_500              "500 Syntax error, command unrecognized.\r\n"
68 #define REPL_501              "501 Syntax error in parameters or arguments.\r\n"
69 #define REPL_502              "502 Command not implemented.\r\n"
70 #define REPL_503              "503 Bad sequence of commands.\r\n"
71 #define REPL_504              "504 Command not implemented for that parameter.\r\n"
72 #define REPL_530              "530 Not logged in.\r\n"
73 #define REPL_532              "532 Need account for storing files.\r\n"
74 #define REPL_550              "550 Requested action not taken.\r\n"
75 #define REPL_551              "551 Requested action aborted. Page type unknown.\r\n"
76 #define REPL_552              "552 Requested file action aborted.\r\n"
77 #define REPL_553              "553 Requested action not taken.\r\n"
78 #define REPL_553_READ_ONLY    "553 Read-only file-system.\r\n"
79 
80 enum EFTPCommand
81 {
82     ECMD_USER,
83     ECMD_PASS,
84     ECMD_ACCT,
85     ECMD_CWD,
86     ECMD_CDUP,
87     ECMD_SMNT,
88     ECMD_QUIT,
89     ECMD_REIN,
90     ECMD_PORT,
91     ECMD_PASV,
92     ECMD_TYPE,
93     ECMD_STRU,
94     ECMD_MODE,
95     ECMD_RETR,
96     ECMD_STOR,
97     ECMD_STOU,
98     ECMD_APPE,
99     ECMD_ALLO,
100     ECMD_REST,
101     ECMD_RNFR,
102     ECMD_RNTO,
103     ECMD_ABOR,
104     ECMD_SIZE,
105     ECMD_MDTM,
106     ECMD_DELE,
107     ECMD_RMD,
108     ECMD_MKD,
109     ECMD_PWD,
110     ECMD_LIST,
111     ECMD_NLST,
112     ECMD_SITE,
113     ECMD_SYST,
114     ECMD_FEAT,
115     ECMD_STAT,
116     ECMD_HELP,
117     ECMD_NOOP,
118     ECMD_EMPTY,
119     ECMD_CLOSE,
120     ECMD_UNKNOWN,
121 };
122 
123 typedef struct xFTP_COMMAND
124 {
125     BaseType_t xCommandLength;
126     const char pcCommandName[ 7 ];
127     const unsigned char ucCommandType;
128     const unsigned char checkLogin;
129     const unsigned char checkNullArg;
130 } FTPCommand_t;
131 
132 #define FTP_CMD_COUNT    ( ECMD_UNKNOWN + 1 )
133 
134 extern const FTPCommand_t xFTPCommands[ FTP_CMD_COUNT ];
135 
136 #endif // __FTPCMD_H__
137