Network Component  Version 6.6
MDK-Professional Middleware for IP Networking
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
TFTP Server

Trivial File Transfer Protocol (TFTP) is a simple protocol for exchanging files between two TCP/IP machines. TFTP servers allow connections from a TFTP Client for sending and receiving files. The TFTP protocol supports only file send and receive operations. File delete, file move, and file rename are not supported. Due to its limitations, TFTP is a complement to the regular FTP and not a replacement. It is used only when its simplicity is important, and its lack of features is acceptable. The most common application is bootstrapping, although it can be used for other purposes.

A TFTP Server can be used to upload HTTP Web pages or to download log files to a remote PC. In this case, the File System must present in the project.

File System Interface

All File System interface functions are located in TFTP_Server_FS.c, which will be automatically added to your project's Network folder. The file is preconfigured for the File System Component, so no modifications are required. If you want to use another type of file system or to use a different storage media such as a hard disk, you need to add a similar file to your project.

The following functions are implemented in this module:

Access Filtering

For access filtering the function tftp_accept_client is used. It is part of the file TFTP_Server_Access.c. You need to adapt the function to the application's needs.

Code Example TFTP_Server_Access.c

#include "rl_net.h"
// Accept or deny connection from remote TFTP client.
// If this function is missing, all remote clients are accepted.
bool tftp_accept_client (const uint8_t *ip_addr, uint16_t port) {
/* Example
if (ip_addr[0] == 192 &&
ip_addr[1] == 168 &&
ip_addr[2] == 0 &&
ip_addr[3] == 1) {
// Accept connection.
return (true);
}
// Deny connection.
return (false);
*/
return (true);
}

TFTP Server Configuration

net_config_tftp_server_h.png
TFTP Server Configuration File

The TFTP server configuration file Net_Config_TFTP_Server.h contains the following settings:

  • Number of TFTP Sessions specifies the number of available FTP sessions. The default value is one, and this enables only one concurrent client connection. You should increase this number if multiple TFTP clients must connect to the TFTP server at the same time.
  • Port Number specifies the listening TCP port number. The default TFTP server listening port is 69.
  • The Enable Firewall Support switch enables or disables the TFTP server operation mode. It is enabled if this value is set to 1. It then runs in Firewall Support mode and uses the listening UDP port not only to receive requests, but also to send the answers to the clients. If this value is set to 0, the TFTP server runs in RFC1350 compliant mode.
  • Idle Session Timeout in seconds is an inactive session timeout. The TFTP session closes if the TFTP file transfer is interrupted for some reason and the timeout timer expires.
  • Number of Retries specifies how many times the TFTP Server tries to retransmit the data before giving up.