Network Component  Version 7.19.0
MDK Middleware for IPv4 and IPv6 Networking
Access Interface

Functions to filter access to the TFTP server. More...

Functions

bool netTFTPs_AcceptClient (const NET_ADDR *addr)
 Accept or deny connection from a remote TFTP client. [user-provided]. More...
 

Description

Functions to filter access to the TFTP server.

To filter the access to the TFTP server, the optional function netTFTPs_AcceptClient is used. It is part of the template file TFTP_Server_Access.c. If this template file is missing in the µVision 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 TFTP server will use the information in this function to filter the access.

Function Documentation

◆ netTFTPs_AcceptClient()

bool netTFTPs_AcceptClient ( const NET_ADDR addr)

Accept or deny connection from a remote TFTP client. [user-provided].

Parameters
[in]addrstructure containing IP address and port of remote TFTP client.
Returns
  • true = Connection from the remote client is allowed.
  • false = Connection is denied.

The function netTFTPs_AcceptClient checks if a connection from the remote client is allowed. This enables remote client filtering to decide which clients are allowed to connect to the TFTP server.

The argument addr points to a buffer containing the IP address and port of the remote machine.

Note
This function is optional. If missing, the library default function is used which accepts all remote clients.

Code Example

The following example is available in the user code template file TFTP_Server_Access.c. Customize it to the application's needs.

bool netTFTPs_AcceptClient (const NET_ADDR *addr) {
if (addr->addr_type == NET_ADDR_IP4) {
// IPv4 client
if (addr->addr[0] == 192 &&
addr->addr[1] == 168 &&
addr->addr[2] == 0 &&
addr->addr[3] == 1) {
// Accept connection from client at 192.168.0.1
return (true);
}
}
else {
// IPv6 client
const uint8_t ip6_addr[NET_ADDR_IP6_LEN] = {
0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x1c, 0x30, 0x6c, 0xff, 0xfe, 0xa2, 0x45, 0x5e };
if (memcmp (addr->addr, ip6_addr, NET_ADDR_IP6_LEN) == 0) {
// Accept connection from client at [fe80::1c30:6cff:fea2:455e]
return (true);
}
}
// Deny connection.
return (false);
}