Functions to filter access to the Telnet server and to work with user accounts. More...
Functions | |
bool | netTELNETs_AcceptClient (const NET_ADDR *addr) |
Accept or deny a connection from a remote Telnet client. [user-provided]. | |
uint8_t | netTELNETs_CheckUsername (const char *username) |
Check if an user account exist in the user database. [user-provided]. | |
bool | netTELNETs_CheckPassword (uint8_t user_id, const char *password) |
Check user account password in the user database. [user-provided]. | |
uint8_t | netTELNETs_GetUserId (void) |
Retrieve the user identification number. [thread-safe]. | |
Functions to filter access to the Telnet server and to work with user accounts.
To filter the access to the Telnet server based on the IP address and port of the connecting client, the optional function netTELNETs_AcceptClient is used. It is part of the template file Telnet_Server_Access.c. If this template file is missing in the project, the function will not be available and thus connections from all remote clients will be accepted. You need to adapt the function to the application's needs by specifying the rules for allowed/blocked clients. The Telnet server will use the information in this function to filter the access.
The multi-user login allows you to create different profiles for different users or groups of users. The profiles define the access rights to different commands executed on the Telnet server. The users which are allowed to access the Telnet server are stored in an user database.
If you want to use multi-user authentication, you need to check the Enable User Authentication in the configuration file (Net_Config_Telnet_Server.h). The default account is a system administrator account, which has no restrictions. All other accounts are created in a separate Telnet_Server_Multiuser.c module.
To enable a list of users, you need to adapt the function netTELNETs_CheckUsername, which checks if the user account exists for the provided credentials, and the function netTELNETs_CheckPassword, which checks if the password fits to the user account for the provided credentials.
The following function is included in the Network Component library rl_net.h:
bool netTELNETs_AcceptClient | ( | const NET_ADDR * | addr | ) |
Accept or deny a connection from a remote Telnet client. [user-provided].
[in] | addr | structure containing IP address and port of remote Telnet client. |
The function netTELNETs_AcceptClient checks if a connection from the remote client is allowed. This allows remote client filtering. You can selectively decide which clients are allowed to connect to the Telnet server.
The argument addr points to a buffer containing the IP address and port of the remote client.
Code Example
The following example is available in the user code template file Telnet_Server_Access.c. Customize it to the application's needs.
bool netTELNETs_CheckPassword | ( | uint8_t | user_id, |
const char * | password | ||
) |
Check user account password in the user database. [user-provided].
[in] | user_id | user identification number. |
[in] | password | pointer to password. |
The function netTELNETs_CheckPassword authenticates the password for a specified user ID on the server.
The argument user_id is the identification number of a user.
The argument password points to a null-terminated string representing the password that gets checked.
Code Example
The following example is available in the user code template file Telnet_Server_Multiuser.c. Customize it to the application's needs.
uint8_t netTELNETs_CheckUsername | ( | const char * | username | ) |
Check if an user account exist in the user database. [user-provided].
[in] | username | pointer to username. |
The function netTELNETs_CheckUsername authenticates the user name and returns the user identification number. A value of 0 is returned if the user does not exist.
The argument username points to a null-terminated string representing the user name that must be checked.
Code Example
The following example is available in the user code template file Telnet_Server_Multiuser.c. Customize it to the application's needs.
uint8_t netTELNETs_GetUserId | ( | void | ) |
Retrieve the user identification number. [thread-safe].
The function netTELNETs_GetUserId retrieves the user identification number when the Telnet console is protected with user authentication. It can be used to disable certain commands for unprivileged users.
Code Example