Network Component  
MDK Middleware for IPv4 and IPv6 Networking
 
Loading...
Searching...
No Matches
Control Interface

Functions to connect to a TFTP server. More...

Functions

netStatus netTFTPc_Put (const NET_ADDR *addr, const char *fname, const char *local_fname)
 Put a file to a remote TFTP server. [thread-safe].
 
netStatus netTFTPc_Get (const NET_ADDR *addr, const char *fname, const char *local_fname)
 Retrieve a file from a remote TFTP server. [thread-safe].
 

Description

Functions to connect to a TFTP server.

Due to the simplicity of the TFTP protocol, there are only two user commands for interaction with a remote TFTP server. netTFTPc_Get is used to download a file from the server, whereas netTFTPc_Put uploads a file onto the server. TFTP servers do not support directories, so all files will be up-/downloaded from the same root-directory.

Function Documentation

◆ netTFTPc_Get()

netStatus netTFTPc_Get ( const NET_ADDR addr,
const char *  fname,
const char *  local_fname 
)

Retrieve a file from a remote TFTP server. [thread-safe].

Parameters
[in]addrstructure containing IP address and port of remote TFTP server.
[in]fnamepointer to the remote file name, a null-terminated string.
[in]local_fnamepointer to the local file name, a null-terminated string.
Returns
status code that indicates the execution status of the function.

The function netTFTPc_Get is used to transfer a file from a remote TFTP server to the local system. The TFTP client starts a (UDP based) TFTP session by connecting to a TFTP server specified by the argument addr. This argument points to a structure containing the IP address and port of the TFTP server. If the specified port is 0, the client uses a standard TFTP server port 69 to connect to the server.

The argument fname points to the null-terminated name of the source file on the TFTP server.

The argument local_fname points to the null-terminated name of the destination file on the local system. If the destination file is not specified (local_fname has a value of NULL), then the fname will be used as the destination file name.

Possible netStatus return values:

  • netOK: TFTP client started successfully.
  • netInvalidParameter: Invalid parameter provided.
  • netWrongState: TFTP client is busy.
  • netFileError: Local file open failed.

Code Example

const NET_ADDR4 addr = { NET_ADDR_IP4, 0, 192, 168, 0, 253 };
if (netTFTPc_Get ((NET_ADDR *)&addr, "my_file.c", NULL) == netOK) {
printf("TFTP Client started.\n");
}
else {
printf("TFTP Client not ready.\n");
}

◆ netTFTPc_Put()

netStatus netTFTPc_Put ( const NET_ADDR addr,
const char *  fname,
const char *  local_fname 
)

Put a file to a remote TFTP server. [thread-safe].

Parameters
[in]addrstructure containing IP address and port of remote TFTP server.
[in]fnamepointer to the remote file name, a null-terminated string.
[in]local_fnamepointer to the local file name, a null-terminated string.
Returns
status code that indicates the execution status of the function.

The function netTFTPc_Put is used to transfer a file from the local system using the TFTP client to a remote TFTP server. This causes the TFTP client to start a (UDP based) TFTP session by connecting to the TFTP server specified by the argument addr. This points to the structure containing the IP address and port of the TFTP server. If the specified port is 0, the client uses a standard TFTP server port 69 to connect to the server.

The argument fname points to the null-terminated name of the destination file on the TFTP server. If the destination file is not specified (fname has a value of NULL), then the local_fname name will be used as the destination file name.

The argument local_fname points to the null-terminated name of the source file on the local system.

Possible netStatus return values:

  • netOK: TFTP client started successfully.
  • netInvalidParameter: Invalid parameter provided.
  • netWrongState: TFTP client is busy.
  • netFileError: Local file not found.

Code Example

const NET_ADDR4 addr = { NET_ADDR_IP4, 0, 192, 168, 0, 253 };
if (netTFTPc_Put ((NET_ADDR *)&addr, NULL, "my_file.c") == netOK) {
printf("TFTP Client started.\n");
}
else {
printf("TFTP Client not ready.\n");
}