![]() |
Network Component
Version 7.2
MDK Middleware for IPv4 and IPv6 Networking
|
Functions to work with the FTP server. More...
Functions | |
netStatus | netFTPs_Start (void) |
Start FTP server. [thread-safe]. | |
netStatus | netFTPs_Stop (void) |
Stop FTP server. [thread-safe]. | |
bool | netFTPs_Running (void) |
Check if FTP server is running. [thread-safe]. | |
uint16_t | netFTPs_GetPort (void) |
Get port number of FTP server. [thread-safe]. | |
netStatus | netFTPs_SetPort (uint16_t port) |
Set port number of FTP server. [thread-safe]. | |
const char * | netFTPs_GetUsername (void) |
Retrieve username of the built-in user account. [thread-safe]. | |
netStatus | netFTPs_SetUsername (const char *username) |
Set username of the built-in user account. [thread-safe]. | |
const char * | netFTPs_GetPassword (void) |
Retrieve password of the built-in user account. [thread-safe]. | |
netStatus | netFTPs_SetPassword (const char *password) |
Reset password of the built-in user account. [thread-safe]. | |
bool | netFTPs_LoginActive (void) |
Determine if FTP server authentication is enabled. [thread-safe]. | |
netStatus | netFTPs_LoginOnOff (bool login) |
Enable or disable FTP server authentication. [thread-safe]. | |
Functions to work with the FTP server.
Like all services, the FTP server is normally started automatically if NET_START_SERVICE
is set to 1 in the Net_Config.c configuration file. If it is disabled, the FTP server needs to be started manually in the user application using netFTPs_Start. At runtime, it is always possible to stop the FTP server using the function netFTPs_Stop. The user application can check for a running server using the netFTPs_Running function.
To change the port of the FTP server at runtime, first call netFTPs_Stop (if the server is running) and then use the netFTPs_SetPort function. Afterwards, the FTP server needs to be (re-)started by the application calling netFTPs_Start.
Code Example
The FTP server supports a built-in user account if the FTP_SERVER_AUTH_ADMIN
is set to 1. In this case, the user specified by FTP_SERVER_AUTH_USER
is created and the password FTP_SERVER_AUTH_PASS
is used for this user. The FTP server control interface provides functions to work with this built-in account. To retrieve the username in the application, use netFTPs_GetUsername. To change this username at runtime, use netFTPs_SetUsername. The same pair of functions is available for managing the password (netFTPs_GetPassword/netFTPs_SetPassword).
It is also possible to check if this login is active (netFTPs_LoginActive) and to enable or disable it at runtime using netFTPs_LoginOnOff. Please note that the function netFTPs_LoginOnOff is only available at runtime if the define FTP_SERVER_AUTH_ENABLE
is set to 1 in the Net_Config_FTP_Server.h file. Otherwise, this command will not be compiled into the project to save resources. For more complex account management, use the Access and Multi-User Interface.
const char * netFTPs_GetPassword | ( | void | ) |
Retrieve password of the built-in user account. [thread-safe].
The function netFTPs_GetPassword returns the password of the built-in user account if FTP_SERVER_AUTH_ADMIN
is set to 1 in the Net_Config_FTP.h file. If this define is set to 0, the function is not available at runtime and returns NULL.
Code Example (see netFTPs_LoginActive)
uint16_t netFTPs_GetPort | ( | void | ) |
Get port number of FTP server. [thread-safe].
The function netFTPs_GetPort returns the port of the FTP server.
Code Example
const char * netFTPs_GetUsername | ( | void | ) |
Retrieve username of the built-in user account. [thread-safe].
The function netFTPs_GetUsername returns the user name of the built-in user if FTP_SERVER_AUTH_ADMIN
is set to 1 in the Net_Config_FTP.h file. If this define is set to 0, the function is not available at runtime and returns NULL.
Code Example (see netFTPs_LoginActive)
bool netFTPs_LoginActive | ( | void | ) |
Determine if FTP server authentication is enabled. [thread-safe].
The function netFTPs_LoginActive checks if the FTP server is set up for user authentication.
Code Example
netStatus netFTPs_LoginOnOff | ( | bool | login | ) |
Enable or disable FTP server authentication. [thread-safe].
[in] | login | new authentication state:
|
The function netFTPs_LoginOnOff enables or disables the user authentication on the FTP server. If FTP_SERVER_AUTH_ENABLE
is set to 0 in the Net_Config_FTP.h file, the function is not available at runtime.
The argument login switches the log-in on (true) or off (false).
Code Example
bool netFTPs_Running | ( | void | ) |
Check if FTP server is running. [thread-safe].
The function netFTPs_Running is used to check whether the FTP server is running. A return value of true shows a running FTP server.
Code Example (see netFTPs_SetPort)
netStatus netFTPs_SetPassword | ( | const char * | password | ) |
Reset password of the built-in user account. [thread-safe].
[in] | password | new password, a null-terminated string. |
The function netFTPs_SetPassword sets the password of the built-in user if FTP_SERVER_AUTH_ADMIN
is set to 1 in the Net_Config_FTP.h file. If this define is set to 0, the function is not available at runtime.
The argument password is a pointer to the password that is to be set, which is a null-terminated string. The function copies the content of the password to the password of the build-in user. The maximum length of the password string is limited to 15 characters.
Code Example (see netFTPs_SetUsername)
netStatus netFTPs_SetPort | ( | uint16_t | port | ) |
Set port number of FTP server. [thread-safe].
[in] | port | port number. |
The function netFTPs_SetPort sets the port of the FTP server. The FTP server must not run while setting the port. If required, stop it first using netFTPs_Stop.
The argument port specifies the port number to be used.
Code Example
netStatus netFTPs_SetUsername | ( | const char * | username | ) |
Set username of the built-in user account. [thread-safe].
[in] | username | new username, a null-terminated string. |
The function netFTPs_SetUsername sets the user name of the built-in user if FTP_SERVER_AUTH_ADMIN
is set to 1 in the Net_Config_FTP.h file. If this define is set to 0, the function is not available at runtime.
The argument username is a pointer to the user name to be set, which is a null-terminated string. The function copies the content of the username to the user name of the built-in user. The maximum length of the username string is limited to 15 characters.
Code Example
netStatus netFTPs_Start | ( | void | ) |
Start FTP server. [thread-safe].
The function netFTPs_Start is used to start the FTP server at runtime.
NET_START_SERVICE
to 1 in Net_Config.c, all selected services will be started automatically. Thus, you only need to call this function, if you have either stopped the FTP server previously using netFTPs_Stop or have set NET_START_SERVICE
to 0.Code Example (see netFTPs_SetPort)
netStatus netFTPs_Stop | ( | void | ) |
Stop FTP server. [thread-safe].
The function netFTPs_Stop is used to stop the FTP server at runtime. To re-start the FTP server, use netFTPs_Start.
Code Example (see netFTPs_SetPort)