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