1 /**************************************************************************/
2 /*                                                                        */
3 /*       Copyright (c) Microsoft Corporation. All rights reserved.        */
4 /*                                                                        */
5 /*       This software is licensed under the Microsoft Software License   */
6 /*       Terms for Microsoft Azure RTOS. Full text of the license can be  */
7 /*       found in the LICENSE file at https://aka.ms/AzureRTOS_EULA       */
8 /*       and in the root directory of this software.                      */
9 /*                                                                        */
10 /**************************************************************************/
11 
12 
13 /**************************************************************************/
14 /**************************************************************************/
15 /**                                                                       */
16 /** NetX Duo Component                                                    */
17 /**                                                                       */
18 /**   File Transfer Protocol (FTP)                                        */
19 /**                                                                       */
20 /**************************************************************************/
21 /**************************************************************************/
22 
23 
24 /**************************************************************************/
25 /*                                                                        */
26 /*  APPLICATION INTERFACE DEFINITION                       RELEASE        */
27 /*                                                                        */
28 /*    nxd_ftp_server.h                                    PORTABLE C      */
29 /*                                                           6.1.9        */
30 /*  AUTHOR                                                                */
31 /*                                                                        */
32 /*    Yuxin Zhou, Microsoft Corporation                                   */
33 /*                                                                        */
34 /*  DESCRIPTION                                                           */
35 /*                                                                        */
36 /*    This file defines the NetX Duo File Transfer Protocol (FTP over     */
37 /*    IPv6) component, including all data types and external references.  */
38 /*    It is assumed that nx_api.h and nx_port.h have already been         */
39 /*    included, along with fx_api.h and fx_port.h.                        */
40 /*                                                                        */
41 /*  RELEASE HISTORY                                                       */
42 /*                                                                        */
43 /*    DATE              NAME                      DESCRIPTION             */
44 /*                                                                        */
45 /*  05-19-2020     Yuxin Zhou               Initial Version 6.0           */
46 /*  09-30-2020     Yuxin Zhou               Modified comment(s),          */
47 /*                                            resulting in version 6.1    */
48 /*  10-15-2021     Yuxin Zhou               Modified comment(s),          */
49 /*                                            fixed the issue of clearing */
50 /*                                            data socket, included       */
51 /*                                            necessary header file,      */
52 /*                                            resulting in version 6.1.9  */
53 /*                                                                        */
54 /**************************************************************************/
55 
56 #ifndef NXD_FTP_SERVER_H
57 #define NXD_FTP_SERVER_H
58 
59 /* Determine if a C++ compiler is being used.  If so, ensure that standard
60    C is used to process the API information.  */
61 
62 #ifdef   __cplusplus
63 
64 /* Yes, C++ compiler is present.  Use standard C.  */
65 extern   "C" {
66 
67 #endif
68 
69 #include "nx_api.h"
70 
71 
72 #ifndef      NX_FTP_NO_FILEX
73 #include    "fx_api.h"
74 #else
75 #include    "filex_stub.h"
76 #endif
77 
78 
79 /* Define the FTP Server ID.  */
80 
81 #define NXD_FTP_SERVER_ID                           0x46545201UL
82 
83 
84 /* Define the maximum number of clients the FTP Server can accommodate.  */
85 
86 #ifndef NX_FTP_MAX_CLIENTS
87 #define NX_FTP_MAX_CLIENTS                  4
88 #endif
89 
90 
91 /* Define FTP TCP socket create options.  */
92 
93 
94 #ifndef NX_FTP_CONTROL_TOS
95 #define NX_FTP_CONTROL_TOS                  NX_IP_NORMAL
96 #endif
97 
98 #ifndef NX_FTP_DATA_TOS
99 #define NX_FTP_DATA_TOS                     NX_IP_NORMAL
100 #endif
101 
102 #ifndef NX_FTP_FRAGMENT_OPTION
103 #define NX_FTP_FRAGMENT_OPTION              NX_DONT_FRAGMENT
104 #endif
105 
106 #ifndef NX_FTP_CONTROL_WINDOW_SIZE
107 #define NX_FTP_CONTROL_WINDOW_SIZE          400
108 #endif
109 
110 #ifndef NX_FTP_DATA_WINDOW_SIZE
111 #define NX_FTP_DATA_WINDOW_SIZE             2048
112 #endif
113 
114 
115 #ifndef NX_FTP_TIME_TO_LIVE
116 #define NX_FTP_TIME_TO_LIVE                 0x80
117 #endif
118 
119 #ifndef NX_FTP_SERVER_TIMEOUT
120 #define NX_FTP_SERVER_TIMEOUT               NX_IP_PERIODIC_RATE
121 #endif
122 
123 #ifndef NX_FTP_SERVER_PRIORITY
124 #define NX_FTP_SERVER_PRIORITY              16
125 #endif
126 
127 #ifndef NX_FTP_SERVER_TIME_SLICE
128 #define NX_FTP_SERVER_TIME_SLICE            2
129 #endif
130 
131 #ifndef NX_FTP_USERNAME_SIZE
132 #define NX_FTP_USERNAME_SIZE                20
133 #endif
134 
135 #ifndef NX_FTP_PASSWORD_SIZE
136 #define NX_FTP_PASSWORD_SIZE                20
137 #endif
138 
139 #ifndef NX_FTP_ACTIVITY_TIMEOUT
140 #define NX_FTP_ACTIVITY_TIMEOUT             240         /* Seconds allowed with no activity                    */
141 #endif
142 
143 #ifndef NX_FTP_TIMEOUT_PERIOD
144 #define NX_FTP_TIMEOUT_PERIOD               60          /* Number of seconds to check                          */
145 #endif
146 
147 #ifndef NX_PHYSICAL_TRAILER
148 #define NX_PHYSICAL_TRAILER                 4           /* Number of bytes to reserve at the end of buffer     */
149 #endif
150 
151 /* Define the FTP data port retry parameters.  */
152 
153 #ifndef NX_FTP_SERVER_RETRY_SECONDS
154 #define NX_FTP_SERVER_RETRY_SECONDS         2           /* 2 second initial timeout                            */
155 #endif
156 
157 #ifndef NX_FTP_SERVER_TRANSMIT_QUEUE_DEPTH
158 #define NX_FTP_SERVER_TRANSMIT_QUEUE_DEPTH  20          /* Maximum of 20 queued transmit packets               */
159 #endif
160 
161 #ifndef NX_FTP_SERVER_RETRY_MAX
162 #define NX_FTP_SERVER_RETRY_MAX             10          /* Maximum of 10 retries per packet                    */
163 #endif
164 
165 #ifndef NX_FTP_SERVER_RETRY_SHIFT
166 #define NX_FTP_SERVER_RETRY_SHIFT           1           /* Every retry is twice as long                        */
167 #endif
168 
169 /* The minimum FTP Server packet size must accomodate the largest expected packet sent e.g. the LIST command:
170    The filename can be up to 256 bytes, plus file info (which has a fixed size of 52 bytes).
171    Note the 256 value is the assumed max size of a filename, defined by FX_MAX_LONG_NAME_LEN.
172                                                                                             .
173    File download (data) packets can be split up over multiple packets, but commands should be in one packet. */
174 
175 #ifndef NX_FTP_SERVER_MIN_PACKET_PAYLOAD
176 #define NX_FTP_SERVER_MIN_PACKET_PAYLOAD   (256 + 52 + NX_TCP_PACKET + NX_PHYSICAL_TRAILER)
177 #endif
178 
179 
180 /* Define open types.  */
181 
182 #define NX_FTP_OPEN_FOR_READ                0x01        /* FTP file open for reading                           */
183 #define NX_FTP_OPEN_FOR_WRITE               0x02        /* FTP file open for writing                           */
184 
185 
186 /* Define transfer modes. Note: just support stream mode and block mode yet.  */
187 
188 #define NX_FTP_TRANSFER_MODE_STREAM         0           /* FTP stream transfer mode                            */
189 #define NX_FTP_TRANSFER_MODE_BLOCK          1           /* FTP block transfer mode                             */
190 #define NX_FTP_TRANSFER_MODE_COMPRESSED     2           /* FTP compressed transfer mode                        */
191 
192 
193 /* Define Server thread events.  */
194 
195 #define NX_FTP_SERVER_CONNECT               0x01        /* FTP connection is present                           */
196 #define NX_FTP_SERVER_DATA_DISCONNECT       0x02        /* FTP data disconnection is present                   */
197 #define NX_FTP_SERVER_COMMAND               0x04        /* FTP client command is present                       */
198 #define NX_FTP_SERVER_DATA                  0x08        /* FTP client data is present                          */
199 #define NX_FTP_SERVER_ACTIVITY_TIMEOUT      0x10        /* FTP activity timeout check                          */
200 #define NX_FTP_SERVER_CONTROL_DISCONNECT    0x20        /* FTP client disconnect of control socket             */
201 #define NX_FTP_STOP_EVENT                   0x40        /* FTP stop service                                    */
202 #define NX_FTP_ANY_EVENT                    0xFF        /* Any FTP event                                       */
203 
204 
205 /* Define return code constants.  */
206 
207 #define NX_FTP_ERROR                        0xD0        /* Generic FTP internal error - deprecated             */
208 #define NX_FTP_TIMEOUT                      0xD1        /* FTP timeout occurred                                */
209 #define NX_FTP_FAILED                       0xD2        /* FTP error                                           */
210 #define NX_FTP_NOT_CONNECTED                0xD3        /* FTP not connected error                             */
211 #define NX_FTP_NOT_DISCONNECTED             0xD4        /* FTP not disconnected error                          */
212 #define NX_FTP_NOT_OPEN                     0xD5        /* FTP not opened error                                */
213 #define NX_FTP_NOT_CLOSED                   0xD6        /* FTP not closed error                                */
214 #define NX_FTP_END_OF_FILE                  0xD7        /* FTP end of file status                              */
215 #define NX_FTP_END_OF_LISTING               0xD8        /* FTP end of directory listing status                 */
216 #define NX_FTP_EXPECTED_1XX_CODE            0xD9        /* Expected a 1xx response from server                 */
217 #define NX_FTP_EXPECTED_2XX_CODE            0xDA        /* Expected a 2xx response from server                 */
218 #define NX_FTP_EXPECTED_22X_CODE            0xDB        /* Expected a 22x response from server                 */
219 #define NX_FTP_EXPECTED_23X_CODE            0xDC        /* Expected a 23x response from server                 */
220 #define NX_FTP_EXPECTED_3XX_CODE            0xDD        /* Expected a 3xx response from server                 */
221 #define NX_FTP_EXPECTED_33X_CODE            0xDE        /* Expected a 33x response from server                 */
222 #define NX_FTP_INVALID_NUMBER               0xDF        /* Extraced an invalid number from server response     */
223 #define NX_FTP_INVALID_ADDRESS              0x1D0       /* Invalid IP address parsed from FTP command          */
224 #define NX_FTP_INVALID_COMMAND              0x1D1       /* Invalid FTP command (bad syntax, unknown command)   */
225 #define NX_FTP_INVALID_LOGIN                0x1D2       /* Unable to perform successful user login             */
226 #define NX_FTP_INSUFFICIENT_PACKET_PAYLOAD  0x1D3       /* Packet payload less than the max length filename    */
227 #define NX_FTP_SERVER_INVALID_SIZE          0x1D4       /* Invalid FTP file size                               */
228 #define NX_FTP_SERVER_END_OF_BLOCK          0x1D5       /* FTP end of block                                    */
229 
230 /* Define FTP connection states.  */
231 
232 #define NX_FTP_STATE_NOT_CONNECTED          1           /* FTP not connected                                   */
233 #define NX_FTP_STATE_CONNECTED              2           /* FTP connected                                       */
234 #define NX_FTP_STATE_OPEN                   3           /* FTP file open for reading                           */
235 #define NX_FTP_STATE_WRITE_OPEN             4           /* FTP file open for writing                           */
236 
237 
238 /* Define the FTP Server TCP port numbers.  */
239 
240 #define NX_FTP_SERVER_CONTROL_PORT          21          /* Control Port for FTP server                         */
241 #define NX_FTP_SERVER_DATA_PORT             20          /* Data Port for FTP server                            */
242 
243 /* Define the size for buffer to store an IPv6 address represented in ASCII. */
244 #define NX_FTP_IPV6_ADDRESS_BUFSIZE         60
245 
246 /* Define the FTP basic commands.  The ASCII command will be parsed and converted to the numerical
247    representation shown below.  */
248 
249 #define NX_FTP_NOOP                         0
250 #define NX_FTP_USER                         1
251 #define NX_FTP_PASS                         2
252 #define NX_FTP_QUIT                         3
253 #define NX_FTP_RETR                         4
254 #define NX_FTP_STOR                         5
255 #define NX_FTP_RNFR                         6
256 #define NX_FTP_RNTO                         7
257 #define NX_FTP_DELE                         8
258 #define NX_FTP_RMD                          9
259 #define NX_FTP_MKD                          10
260 #define NX_FTP_NLST                         11
261 #define NX_FTP_PORT                         12
262 #define NX_FTP_CWD                          13
263 #define NX_FTP_PWD                          14
264 #define NX_FTP_TYPE                         15
265 #define NX_FTP_LIST                         16
266 #define NX_FTP_CDUP                         17
267 #define NX_FTP_INVALID                      18
268 #define NX_FTP_EPRT                         19
269 #define NX_FTP_PASV                         20
270 #define NX_FTP_EPSV                         21
271 #define NX_FTP_MODE                         22
272 
273 
274 
275 /* Define the per client request structure for the FTP Server data structure.  */
276 
277 typedef struct NX_FTP_CLIENT_REQUEST_STRUCT
278 {
279     UINT            nx_ftp_client_request_data_port;                /* Client's data port                  */
280     UINT            nx_ftp_client_request_ip_type;                  /* Client IP type (IPv4 or IPv6)       */
281     UINT            nx_ftp_client_request_open_type;                /* Open type of client request         */
282     UINT            nx_ftp_client_request_authenticated;            /* Authenticated flag                  */
283     CHAR            nx_ftp_client_request_read_only;                /* Read-only flag                      */
284     CHAR            nx_ftp_client_request_transfer_type;            /* FTP Data transfer type              */
285     CHAR            nx_ftp_client_request_login;                    /* FTP Login flag                      */
286     CHAR            nx_ftp_client_request_passive_transfer_enabled; /* Client enabled for passive transfer */
287     UINT            nx_ftp_client_request_transfer_mode;            /* Client transfer mode                */
288     ULONG           nx_ftp_client_request_activity_timeout;         /* Timeout for client activity         */
289     ULONG           nx_ftp_client_request_total_bytes;              /* Total bytes read or written         */
290     ULONG           nx_ftp_client_request_block_bytes;              /* Block bytes in block mode           */
291     CHAR            nx_ftp_client_request_username[NX_FTP_USERNAME_SIZE];
292     CHAR            nx_ftp_client_request_password[NX_FTP_PASSWORD_SIZE];
293     NX_PACKET       *nx_ftp_client_request_packet;                  /* Previous request packet             */
294     FX_FILE         nx_ftp_client_request_file;                     /* File control block                  */
295     FX_LOCAL_PATH   nx_ftp_client_local_path;                       /* Local path control block            */
296     NX_TCP_SOCKET   nx_ftp_client_request_control_socket;           /* Client control socket               */
297     NX_TCP_SOCKET   nx_ftp_client_request_data_socket;              /* Client data socket                  */
298 } NX_FTP_CLIENT_REQUEST;
299 
300 
301 /* Define the FTP Server data structure.  */
302 
303 typedef struct NX_FTP_SERVER_STRUCT
304 {
305     ULONG           nx_ftp_server_id;                               /* FTP Server ID                       */
306     CHAR           *nx_ftp_server_name;                             /* Name of this FTP server             */
307     NX_IP          *nx_ftp_server_ip_ptr;                           /* Pointer to associated IP structure  */
308 
309     NX_PACKET_POOL *nx_ftp_server_packet_pool_ptr;                  /* Pointer to FTP server packet pool   */
310     FX_MEDIA       *nx_ftp_server_media_ptr;                        /* Pointer to media control block      */
311     ULONG           nx_ftp_server_connection_requests;              /* Number of connection requests       */
312     ULONG           nx_ftp_server_disconnection_requests;           /* Number of disconnection requests    */
313     ULONG           nx_ftp_server_login_errors;                     /* Number of login errors              */
314     ULONG           nx_ftp_server_authentication_errors;            /* Number of access w/o authentication */
315     ULONG           nx_ftp_server_total_bytes_sent;                 /* Number of total bytes sent          */
316     ULONG           nx_ftp_server_total_bytes_received;             /* Number of total bytes received      */
317     ULONG           nx_ftp_server_unknown_commands;                 /* Number of unknown commands received */
318     ULONG           nx_ftp_server_allocation_errors;                /* Number of allocation errors         */
319     ULONG           nx_ftp_server_relisten_errors;                  /* Number of relisten errors           */
320     ULONG           nx_ftp_server_activity_timeouts;                /* Number of activity timeouts         */
321     UINT            nx_ftp_server_data_port;                        /* Port the data socket binds          */
322     NX_FTP_CLIENT_REQUEST                                           /* FTP client request array            */
323                     nx_ftp_server_client_list[NX_FTP_MAX_CLIENTS];
324     TX_EVENT_FLAGS_GROUP
325                     nx_ftp_server_event_flags;                      /* FTP server thread events            */
326     TX_TIMER        nx_ftp_server_timer;                            /* FTP server activity timeout timer   */
327     TX_THREAD       nx_ftp_server_thread;                           /* FTP server thread                   */
328     UINT            (*nx_ftp_login)(struct NX_FTP_SERVER_STRUCT *ftp_server_ptr, NXD_ADDRESS *client_ipduo_address, UINT client_port, CHAR *name, CHAR *password, CHAR *extra_info);
329     UINT            (*nx_ftp_logout)(struct NX_FTP_SERVER_STRUCT *ftp_server_ptr, NXD_ADDRESS *client_ipduo_address, UINT client_port, CHAR *name, CHAR *password, CHAR *extra_info);
330 #ifndef NX_DISABLE_IPV4
331     UINT            (*nx_ftp_login_ipv4)(struct NX_FTP_SERVER_STRUCT *ftp_server_ptr, ULONG client_address, UINT client_port, CHAR *name, CHAR *password, CHAR *extra_info);
332     UINT            (*nx_ftp_logout_ipv4)(struct NX_FTP_SERVER_STRUCT *ftp_server_ptr, ULONG client_address, UINT client_port, CHAR *name, CHAR *password, CHAR *extra_info);
333 #endif /* NX_DISABLE_IPV4 */
334 
335     struct NX_FTP_SERVER_STRUCT
336                     *nx_ftp_next_server_ptr,
337                     *nx_ftp_previous_server_ptr;
338 } NX_FTP_SERVER;
339 
340 
341 #ifndef NX_FTP_SOURCE_CODE
342 
343 /* Application caller is present, perform API mapping.  */
344 
345 /* Determine if error checking is desired.  If so, map API functions
346    to the appropriate error checking front-ends.  Otherwise, map API
347    functions to the core functions that actually perform the work.
348    Note: error checking is enabled by default.  */
349 
350 #ifdef NX_DISABLE_ERROR_CHECKING
351 
352 /* Services without error checking.  */
353 
354 #define nx_ftp_server_create                        _nx_ftp_server_create
355 #define nxd_ftp_server_create                       _nxd_ftp_server_create
356 #define nx_ftp_server_delete                        _nx_ftp_server_delete
357 #define nx_ftp_server_start                         _nx_ftp_server_start
358 #define nx_ftp_server_stop                          _nx_ftp_server_stop
359 
360 #else
361 
362 /* Services with error checking.  */
363 
364 #define nx_ftp_server_create                        _nxe_ftp_server_create
365 #define nxd_ftp_server_create                       _nxde_ftp_server_create
366 #define nx_ftp_server_delete                        _nxe_ftp_server_delete
367 #define nx_ftp_server_start                         _nxe_ftp_server_start
368 #define nx_ftp_server_stop                          _nxe_ftp_server_stop
369 
370 #endif
371 
372 /* Define the prototypes accessible to the application software.  */
373 UINT        nx_ftp_server_create(NX_FTP_SERVER *ftp_server_ptr, CHAR *ftp_server_name, NX_IP *ip_ptr, FX_MEDIA *media_ptr, VOID *stack_ptr, ULONG stack_size, NX_PACKET_POOL *pool_ptr,
374                 UINT (*ftp_login_ipv4)(struct NX_FTP_SERVER_STRUCT *ftp_server_ptr, ULONG client_ip_address, UINT client_port, CHAR *name, CHAR *password, CHAR *extra_info),
375                 UINT (*ftp_logout_ipv4)(struct NX_FTP_SERVER_STRUCT *ftp_server_ptr, ULONG client_ip_address, UINT client_port, CHAR *name, CHAR *password, CHAR *extra_info));
376 UINT        nxd_ftp_server_create(NX_FTP_SERVER *ftp_server_ptr, CHAR *ftp_server_name, NX_IP *ip_ptr, FX_MEDIA *media_ptr, VOID *stack_ptr, ULONG stack_size, NX_PACKET_POOL *pool_ptr,
377                 UINT (*ftp_login)(struct NX_FTP_SERVER_STRUCT *ftp_server_ptr, NXD_ADDRESS *client_ipduo_address, UINT client_port, CHAR *name, CHAR *password, CHAR *extra_info),
378                 UINT (*ftp_logout)(struct NX_FTP_SERVER_STRUCT *ftp_server_ptr, NXD_ADDRESS *client_ipduo_address, UINT client_port, CHAR *name, CHAR *password, CHAR *extra_info));
379 UINT        nx_ftp_server_delete(NX_FTP_SERVER *ftp_server_ptr);
380 UINT        nx_ftp_server_start(NX_FTP_SERVER *ftp_server_ptr);
381 UINT        nx_ftp_server_stop(NX_FTP_SERVER *ftp_server_ptr);
382 
383 #else
384 
385 /* FTP source code is being compiled, do not perform any API mapping.  */
386 UINT        _nxe_ftp_server_create(NX_FTP_SERVER *ftp_server_ptr, CHAR *ftp_server_name, NX_IP *ip_ptr, FX_MEDIA *media_ptr, VOID *stack_ptr, ULONG stack_size, NX_PACKET_POOL *pool_ptr,
387                 UINT (*ftp_login_ipv4)(struct NX_FTP_SERVER_STRUCT *ftp_server_ptr, ULONG client_ip_address, UINT client_port, CHAR *name, CHAR *password, CHAR *extra_info),
388                 UINT (*ftp_logout_ipv4)(struct NX_FTP_SERVER_STRUCT *ftp_server_ptr, ULONG client_ip_address, UINT client_port, CHAR *name, CHAR *password, CHAR *extra_info));
389 UINT        _nx_ftp_server_create(NX_FTP_SERVER *ftp_server_ptr, CHAR *ftp_server_name, NX_IP *ip_ptr, FX_MEDIA *media_ptr, VOID *stack_ptr, ULONG stack_size, NX_PACKET_POOL *pool_ptr,
390                 UINT (*ftp_login_ipv4)(struct NX_FTP_SERVER_STRUCT *ftp_server_ptr, ULONG client_ip_address, UINT client_port, CHAR *name, CHAR *password, CHAR *extra_info),
391                 UINT (*ftp_logout_ipv4)(struct NX_FTP_SERVER_STRUCT *ftp_server_ptr, ULONG client_ip_address, UINT client_port, CHAR *name, CHAR *password, CHAR *extra_info));
392 UINT        _nxde_ftp_server_create(NX_FTP_SERVER *ftp_server_ptr, CHAR *ftp_server_name, NX_IP *ip_ptr, FX_MEDIA *media_ptr, VOID *stack_ptr, ULONG stack_size, NX_PACKET_POOL *pool_ptr,
393                 UINT (*ftp_login)(struct NX_FTP_SERVER_STRUCT *ftp_server_ptr, NXD_ADDRESS *client_ipduo_address, UINT client_port, CHAR *name, CHAR *password, CHAR *extra_info),
394                 UINT (*ftp_logout)(struct NX_FTP_SERVER_STRUCT *ftp_server_ptr, NXD_ADDRESS *client_ipduo_address, UINT client_port, CHAR *name, CHAR *password, CHAR *extra_info));
395 UINT        _nxd_ftp_server_create(NX_FTP_SERVER *ftp_server_ptr, CHAR *ftp_server_name, NX_IP *ip_ptr, FX_MEDIA *media_ptr, VOID *stack_ptr, ULONG stack_size, NX_PACKET_POOL *pool_ptr,
396                 UINT (*ftp_login)(struct NX_FTP_SERVER_STRUCT *ftp_server_ptr, NXD_ADDRESS *client_ipduo_address, UINT client_port, CHAR *name, CHAR *password, CHAR *extra_info),
397                 UINT (*ftp_logout)(struct NX_FTP_SERVER_STRUCT *ftp_server_ptr, NXD_ADDRESS *client_ipduo_address, UINT client_port, CHAR *name, CHAR *password, CHAR *extra_info));
398 UINT        _nxe_ftp_server_delete(NX_FTP_SERVER *ftp_server_ptr);
399 UINT        _nx_ftp_server_delete(NX_FTP_SERVER *ftp_server_ptr);
400 UINT        _nxe_ftp_server_start(NX_FTP_SERVER *ftp_server_ptr);
401 UINT        _nx_ftp_server_start(NX_FTP_SERVER *ftp_server_ptr);
402 UINT        _nxe_ftp_server_stop(NX_FTP_SERVER *ftp_server_ptr);
403 UINT        _nx_ftp_server_stop(NX_FTP_SERVER *ftp_server_ptr);
404 
405 /* Internal FTP functions. */
406 UINT        _nx_ftp_server_create_internal(NX_FTP_SERVER *ftp_server_ptr, CHAR *ftp_server_name, NX_IP *ip_ptr, FX_MEDIA *media_ptr, VOID *stack_ptr, ULONG stack_size, NX_PACKET_POOL *pool_ptr,
407                 UINT (*ftp_login)(struct NX_FTP_SERVER_STRUCT *ftp_server_ptr, NXD_ADDRESS *client_address, UINT client_port, CHAR *name, CHAR *password, CHAR *extra_info),
408                 UINT (*ftp_logout)(struct NX_FTP_SERVER_STRUCT *ftp_server_ptr, NXD_ADDRESS *client_address, UINT client_port, CHAR *name, CHAR *password, CHAR *extra_info));
409 VOID        _nx_ftp_server_response(NX_TCP_SOCKET *socket, NX_PACKET *packet_ptr, CHAR *reply_code, CHAR *message);
410 VOID        _nx_ftp_server_directory_response(NX_TCP_SOCKET *socket, NX_PACKET *packet_ptr, CHAR *reply_code, CHAR *message, CHAR *directory);
411 VOID        _nx_ftp_server_thread_entry(ULONG ftp_server_address);
412 VOID        _nx_ftp_server_command_process(NX_FTP_SERVER *ftp_server_ptr);
413 VOID        _nx_ftp_server_connect_process(NX_FTP_SERVER *ftp_server_ptr);
414 VOID        _nx_ftp_server_command_present(NX_TCP_SOCKET *control_socket_ptr);
415 VOID        _nx_ftp_server_connection_present(NX_TCP_SOCKET *control_socket_ptr, UINT port);
416 VOID        _nx_ftp_server_data_disconnect(NX_TCP_SOCKET *data_socket_ptr);
417 VOID        _nx_ftp_server_data_disconnect_process(NX_FTP_SERVER *ftp_server_ptr);
418 VOID        _nx_ftp_server_data_present(NX_TCP_SOCKET *data_socket_ptr);
419 VOID        _nx_ftp_server_data_process(NX_FTP_SERVER *ftp_server_ptr);
420 UINT        _nx_ftp_server_parse_command(NX_PACKET *packet_ptr);
421 VOID        _nx_ftp_server_timeout(ULONG ftp_server_address);
422 VOID        _nx_ftp_server_timeout_processing(NX_FTP_SERVER *ftp_server_ptr);
423 VOID        _nx_ftp_server_control_disconnect(NX_TCP_SOCKET *control_socket_ptr);
424 VOID        _nx_ftp_server_control_disconnect_processing(NX_FTP_SERVER *ftp_server_ptr);
425 VOID        _nx_ftp_server_data_socket_cleanup(NX_FTP_SERVER *ftp_server_ptr, NX_FTP_CLIENT_REQUEST *client_req_ptr);
426 
427 #endif  /* NX_FTP_SOURCE_CODE */
428 
429 /* Internal functions. */
430 #ifdef FEATURE_NX_IPV6
431 UINT        _nx_ftp_utility_parse_IPv6_address(CHAR *buffer_ptr, UINT buffer_length, NXD_ADDRESS *ipduo_address);
432 UINT        _nx_ftp_utility_parse_port_number(CHAR *buffer_ptr, UINT buffer_length, UINT *portnumber);
433 UINT        _nx_ftp_server_utility_fill_port_number(CHAR *buffer_ptr, UINT port_number);
434 #endif
435 
436 UINT        _nx_ftp_packet_allocate(NX_PACKET_POOL *pool_ptr, NX_FTP_CLIENT_REQUEST *client_request_ptr, NX_PACKET **packet_ptr, UINT packet_type, UINT wait_option);
437 VOID        _nx_ftp_server_block_size_get(NX_FTP_SERVER *ftp_server_ptr, UINT ftp_command, CHAR *filename, ULONG *block_size);
438 UINT        _nx_ftp_server_block_header_send(NX_PACKET_POOL *pool_ptr, NX_FTP_CLIENT_REQUEST *client_request_ptr, ULONG block_size);
439 UINT        _nx_ftp_server_block_header_retrieve(NX_FTP_CLIENT_REQUEST *client_request_ptr, NX_PACKET *packet_ptr);
440 
441 
442 /* Determine if a C++ compiler is being used.  If so, complete the standard
443    C conditional started above.  */
444 #ifdef   __cplusplus
445         }
446 #endif
447 
448 #endif    /* NXD_FTP_SERVER_H */
449