|
|
 |
|
|
 |
Collaboration diagram for FTP:
Detailed Description
File transfer protocol.
Internet File Transfer Protocol Server.
|
Data Structures |
| struct | FTPSESSION |
| | FTP session information structure. More...
|
FTP Server Configuration |
The Nut/OS Configurator may be used to override the default values.
|
|
#define | FTP_MAX_CMDBUF 128 |
| | UDP port of DHCP server.
|
FTP Server Configuration |
The Nut/OS Configurator may be used to override the default values.
|
|
#define | FTP_ROOTPATH "PNUT:" |
| | Default FTP root path.
|
|
#define | FTP_DATA_PORT 20 |
| | Default data port.
|
Functions |
| int | NutFtpRespondOk (FTPSESSION *session, int code) |
| | Send a positive response.
|
| int | NutFtpRespondBad (FTPSESSION *session, int code) |
| | Send a negative response.
|
| int | NutFtpSendMode (FTPSESSION *session, int binary) |
| | Send a response including the specified transfer mode.
|
| char * | CreateFullPathName (char *root, char *work, char *path) |
| | Create an absolute path name.
|
| TCPSOCKET * | NutFtpDataConnect (FTPSESSION *session) |
| | Establish an FTP connection for data transfer.
|
| int | NutRegisterFtpRoot (CONST char *path) |
| | Register the FTP server's root directory.
|
| int | NutRegisterFtpUser (CONST char *user, CONST char *pass) |
| | Register an FTP user.
|
| FTPSESSION * | NutFtpOpenSession (TCPSOCKET *sock) |
| | Open an FTP server session.
|
| void | NutFtpCloseSession (FTPSESSION *session) |
| | Close an FTP server session.
|
| int | NutFtpProcessCwd (FTPSESSION *session, char *path) |
| | Process an FTP client's CWD command.
|
| int | NutFtpProcessDelete (FTPSESSION *session, char *path) |
| | Process an FTP client's DELE command.
|
| int | NutFtpTransferFile (FTPSESSION *session, char *path, int mode) |
| | Transfer a file to or from the FTP client.
|
| int | NutFtpTransferDirectory (FTPSESSION *session, char *path) |
| | Process an FTP client's LIST or NLST command.
|
| int | NutFtpProcessMkd (FTPSESSION *session, char *path) |
| | Process an FTP client's MKD command.
|
| int | NutFtpProcessPass (FTPSESSION *session, char *pass) |
| | Process an FTP client's PASS command.
|
| int | NutFtpProcessPassiv (FTPSESSION *session) |
| | Process an FTP client's PASV command.
|
| int | NutFtpProcessPort (FTPSESSION *session, char *args) |
| | Process an FTP client's PORT command.
|
| int | NutFtpProcessPwd (FTPSESSION *session) |
| | Process an FTP client's PWD command.
|
| int | NutFtpProcessRmd (FTPSESSION *session, char *path) |
| | Process an FTP client's RMD command.
|
| int | NutFtpProcessSystem (FTPSESSION *session) |
| | Process an FTP client's SYST command.
|
| int | NutFtpProcessType (FTPSESSION *session, char *typecode) |
| | Process an FTP client's TYPE command.
|
| int | NutFtpProcessUser (FTPSESSION *session, char *user) |
| | Process an FTP client's USER command.
|
| int | NutFtpProcessRequest (FTPSESSION *session, char *request) |
| | Process an FTP request.
|
| int | NutFtpServerSession (TCPSOCKET *sock) |
| | Process an FTP sever session.
|
Function Documentation
| char* CreateFullPathName |
( |
char * |
root, |
|
|
char * |
work, |
|
|
char * |
path |
|
) |
|
|
|
|
Create an absolute path name.
Combines an absolute directory path with a relative path name to a full absolute path name. The absolute directory is split into two parts, the root and the current work directory. The resulting path will never be above the specified root.
- Parameters:
-
| root | Non-empty absolute root directory path including the device name, but without a trailing slash. |
| work | Absolute work directory path below root including a leading, but without a trailing slash. This path is ignored if the relative path starts with a slash. |
| path | Relative path name of a file or directory without any trailing slash. |
- Returns:
- Pointer to the resulting path name. The buffer for this name is allocated from heap memory. The caller is responsible for freeing it. In case of an error, a NULL pointer is returned.
|
|
|
Close an FTP server session.
- Parameters:
-
|
|
|
Establish an FTP connection for data transfer.
- Parameters:
-
- Returns:
- Socket descriptor of the newly created data connection or 0 if we were unable to establish the connection.
|
|
|
Open an FTP server session.
- Parameters:
-
| sock | Socket of an established TCP connection. |
- Returns:
- Pointer to an FTPSESSION structure, which can be used in subsequent API calls. NULL is returned in case of any error.
|
| int NutFtpProcessCwd |
( |
FTPSESSION * |
session, |
|
|
char * |
path |
|
) |
|
|
|
|
Process an FTP client's CWD command.
- Parameters:
-
- Returns:
- 0 if the command has been processed or -1 if the session has been aborted.
|
| int NutFtpProcessDelete |
( |
FTPSESSION * |
session, |
|
|
char * |
path |
|
) |
|
|
|
|
Process an FTP client's DELE command.
Causes the specified file to be deleted.
- Parameters:
-
- Returns:
- 0 if the command has been processed or -1 if the session has been aborted.
|
| int NutFtpProcessMkd |
( |
FTPSESSION * |
session, |
|
|
char * |
path |
|
) |
|
|
|
|
Process an FTP client's MKD command.
Causes the specified directory to be created.
- Parameters:
-
- Returns:
- 0 if the command has been processed or -1 if the session has been aborted.
|
| int NutFtpProcessPass |
( |
FTPSESSION * |
session, |
|
|
char * |
pass |
|
) |
|
|
|
|
Process an FTP client's PASS command.
Only one login per session is accepted.
- Parameters:
-
- Returns:
- 0 if the command has been processed or -1 if the session has been aborted.
|
|
|
Process an FTP client's PASV command.
This command requests the server to listen on a data port and to wait for a connection rather than initiate one upon receipt of a transfer command.
- Parameters:
-
- Returns:
- 0 if the command has been processed or -1 if the session has been aborted.
|
| int NutFtpProcessPort |
( |
FTPSESSION * |
session, |
|
|
char * |
args |
|
) |
|
|
|
|
Process an FTP client's PORT command.
- Parameters:
-
| session | Pointer to an FTPSESSION structure, obtained by a previous call to NutFtpOpenSession(). |
| args | Command argument, which is the concatenation of the 32-bit internet host address and a 16-bit TCP port address. This address information is broken into 8-bit fields and the value of each field is transmitted as a decimal number. |
- Returns:
- 0 if the command has been processed or -1 if the session has been aborted.
|
|
|
Process an FTP client's PWD command.
Causes the name of the current working directory to be returned in the reply.
- Parameters:
-
- Returns:
- 0 if the command has been processed or -1 if the session has been aborted.
|
| int NutFtpProcessRequest |
( |
FTPSESSION * |
session, |
|
|
char * |
request |
|
) |
|
|
|
|
Process an FTP request.
This routine implements the protocol interpreter of the FTP server.
- Parameters:
-
- Returns:
- -1 if the session ended. Otherwise 0 is returned.
|
| int NutFtpProcessRmd |
( |
FTPSESSION * |
session, |
|
|
char * |
path |
|
) |
|
|
|
|
Process an FTP client's RMD command.
Causes the specified directory to be removed.
- Parameters:
-
- Returns:
- 0 if the command has been processed or -1 if the session has been aborted.
|
|
|
Process an FTP client's SYST command.
- Parameters:
-
- Returns:
- 0 if the command has been processed or -1 if the session has been aborted.
|
| int NutFtpProcessType |
( |
FTPSESSION * |
session, |
|
|
char * |
typecode |
|
) |
|
|
|
|
Process an FTP client's TYPE command.
The type is not fully checked. Any argument starting with the letters 'A' or 'a' will switch the transfer mode to ASCII. Otherwise binary mode is set.
- Parameters:
-
- Returns:
- 0 if the command has been processed or -1 if the session has been aborted.
|
| int NutFtpProcessUser |
( |
FTPSESSION * |
session, |
|
|
char * |
user |
|
) |
|
|
|
|
Process an FTP client's USER command.
Only one login per session is accepted.
- Parameters:
-
- Returns:
- 0 if the command has been processed or -1 if the session has been aborted.
|
| int NutFtpRespondBad |
( |
FTPSESSION * |
session, |
|
|
int |
code |
|
) |
|
|
|
|
Send a negative response.
- Parameters:
-
- Returns:
- -1 if the session ended. Otherwise 0 is returned.
|
| int NutFtpRespondOk |
( |
FTPSESSION * |
session, |
|
|
int |
code |
|
) |
|
|
|
|
Send a positive response.
- Parameters:
-
- Returns:
- -1 if the session ended. Otherwise 0 is returned.
|
| int NutFtpSendMode |
( |
FTPSESSION * |
session, |
|
|
int |
binary |
|
) |
|
|
|
|
Send a response including the specified transfer mode.
- Parameters:
-
- Returns:
- -1 if the session ended. Otherwise 0 is returned.
|
|
|
Process an FTP sever session.
Processes FTP requests on an established connection with an FTP client. This routine completely implements an FTP server except TCP connect and disconnect.
For file transfers, the same maximum segment size and timeouts as set for this socket will be used for the data connection.
- Parameters:
-
| sock | Socket of an established TCP connection. |
- Returns:
- 0 if the session ended successfully or -1 if the session has been aborted.
|
| int NutFtpTransferDirectory |
( |
FTPSESSION * |
session, |
|
|
char * |
path |
|
) |
|
|
|
|
Process an FTP client's LIST or NLST command.
Causes a directory listing to be sent to the client.
- Parameters:
-
- Returns:
- 0 if the command has been processed or -1 if the session has been aborted.
|
| int NutFtpTransferFile |
( |
FTPSESSION * |
session, |
|
|
char * |
path, |
|
|
int |
mode |
|
) |
|
|
|
|
Transfer a file to or from the FTP client.
- Parameters:
-
| session | Pointer to an FTPSESSION structure, obtained by a previous call to NutFtpOpenSession(). |
| path | Full absolute path name of the file. |
| mode | If set to zero, the server will accept the data transferred via the data connection and to store the data as a file. If the file exists, then its contents will be replaced by the data being transferred. A new file is created, if the file does not already exist. If this parameter is not equal zero, then the server will transfer a copy of the specified file. |
- Returns:
- 0 if the command has been processed or -1 if the session has been aborted.
|
| int NutRegisterFtpRoot |
( |
CONST char * |
path |
) |
|
|
|
|
Register the FTP server's root directory.
Only one root directory is supported. Subsequent calls will override previous settings.
- Parameters:
-
| path | Path name of the root directory. Must include the device name followed by a colon followed by an absolute directory path. May be set to NULL for the default FTP_ROOTPATH. |
- Returns:
- 0 on success, -1 otherwise.
|
| int NutRegisterFtpUser |
( |
CONST char * |
user, |
|
|
CONST char * |
pass |
|
) |
|
|
|
|
Register an FTP user.
Only one username/password pair is supported. Subsequent calls will override previous settings.
- Warning:
- Not successfully registering any will make file systems accessible by anyone.
- Parameters:
-
| user | User's name. |
| pass | Uncrypted password for the specified user. |
- Returns:
- 0 on success. -1 is returned on failures, in which case no protection may be assumed.
|
|
 |
|