Network Component
Version 6.6
MDK-Professional Middleware for IP Networking
|
TFTP Client Routines provide access to a TFTP Server. More...
Functions | |
void | tftp_client_fclose (void *file) |
Close local file previously open in TFTP client. | |
void * | tftp_client_fopen (const char *fname, const char *mode) |
Open local file for reading or writing in TFTP client. | |
uint32_t | tftp_client_fread (void *file, uint8_t *buf, uint32_t len) |
Read block of data from local file in TFTP client. | |
uint32_t | tftp_client_fwrite (void *file, const uint8_t *buf, uint32_t len) |
Write block of data to local file in TFTP client. | |
void | tftp_client_notify (tftpClientEvent event) |
Notify the user application when TFTP client operation ends. | |
netStatus | tftp_client_put (const uint8_t *ip_addr, uint16_t port, const char *src, const char *dst) |
Put a file to remote TFTP server. | |
netStatus | tftp_client_get (const uint8_t *ip_addr, uint16_t port, const char *src, const char *dst) |
Retrieve a file from remote TFTP server. | |
enum | tftpClientEvent { tftpClientSuccess = 0, tftpClientTimeout, tftpClientAccessDenied, tftpClientFileNotFound, tftpClientDiskFull, tftpClientError } |
TFTP Client Events. More... | |
TFTP Client Routines provide access to a TFTP Server.
TFTP routines are not reentrant.
enum tftpClientEvent |
TFTP Client Events.
Parameter for:
void tftp_client_fclose | ( | void * | file | ) |
Close local file previously open in TFTP client.
[in] | file | pointer to the file to close. |
The function tftp_client_fclose closes the file identified by the file stream pointer in the function argument.
The function interfaces to the File System Component and will be called by the Network Component automatically. If another file system will be used, refer to the reference implementation in the TFTP_Client_FS.c module.
void * tftp_client_fopen | ( | const char * | fname, |
const char * | mode | ||
) |
Open local file for reading or writing in TFTP client.
[in] | fname | name of the file to open. |
[in] | mode | type of access:
|
The function tftp_client_fopen opens a local file for reading or writing.
The argument mode defines the type of access permitted for the file fname. mode can have one of the following values:
Mode | Description |
---|---|
"rb" | Opens the file for reading. If the file does not exist, the function fails. |
"wb" | Opens an empty file for writing. If the file exists already, then the content is cleared. |
The function interfaces to the File System Component and will be called by the Network Component automatically. If another file system will be used, refer to the reference implementation in the TFTP_Client_FS.c module.
uint32_t tftp_client_fread | ( | void * | file, |
uint8_t * | buf, | ||
uint32_t | len | ||
) |
Read block of data from local file in TFTP client.
[in] | file | pointer to the file to read from. |
[out] | buf | block of memory to write data to. |
[in] | len | length of data to read in bytes. |
The function tftp_client_fread reads len bytes from the file identified by the file stream pointer in the function argument.
The argument buf is a pointer to the buffer where the function stores the read data.
The function interfaces to the File System Component and will be called by the Network Component automatically. If another file system will be used, refer to the reference implementation in the TFTP_Client_FS.c module.
uint32_t tftp_client_fwrite | ( | void * | file, |
const uint8_t * | buf, | ||
uint32_t | len | ||
) |
Write block of data to local file in TFTP client.
[in] | file | pointer to the file to write to. |
[in] | buf | block of memory to be written. |
[in] | len | length of data to write in bytes. |
The function tftp_client_fwrite writes a block of data to the file identified by the file stream pointer.
The argument buf points to the buffer containing the data to write to the file.
The argument len specifies the number of bytes to write to the file.
The function interfaces to the File System Component and will be called by the Network Component automatically. If another file system will be used, refer to the reference implementation in the TFTP_Client_FS.c module.
netStatus tftp_client_get | ( | const uint8_t * | ip_addr, |
uint16_t | port, | ||
const char * | src, | ||
const char * | dst | ||
) |
Retrieve a file from remote TFTP server.
[in] | ip_addr | IP address of remote TFTP server. |
[in] | port | port number of TFTP server. |
[in] | src | remote file name, a null-terminated string. |
[in] | dst | local file name, a null-terminated string. |
The function tftp_client_get starts the TFTP client for transferring a file from a remote TFTP server to the local system. The TFTP client starts a TFTP session by connecting to a TFTP server on the UDP port specified in the function argument. If the port is not specified (port has a value of 0), then the system uses the standard TFTP server port 69.
The argument ip_addr points to an array of 4 bytes containing the dotted-decimal notation of the IP address of the TFTP server.
The arguments src and dst are pointers to 0-terminated names of source and destination files. Source file is a file on the TFTP server. Destination file is a local file to which the source file content will be copied. If the destination file is not specified (dst has a value of NULL), then the source file name will be used as the destination file name.
Code Example
void tftp_client_notify | ( | tftpClientEvent | event | ) |
Notify the user application when TFTP client operation ends.
[in] | event | TFTP client notification event. |
The function tftp_client_notify is called automatically when an TFTP event occurred and notifies the user application when the TFTP client operation ends.
The argument event is a tftpClientEvent signal:
Event | Description |
---|---|
tftpClientSuccess | The file has been successfully transferred |
tftpClientTimeout | TFTP Server response has timed out, and hence the TFTP client has aborted the operation |
tftpClientAccessDenied | File access on TFTP server is not allowed for a specified file |
tftpClientFileNotFound | The TFTP server was not able to find the specified file |
tftpClientDiskFull | The TFTP server has run out of disk space, file transfer is not possible |
tftpClientError | The TFTP client has encountered an error during file transfer process |
The function is in the TFTP_Client_UIF.c module.
Code Example
netStatus tftp_client_put | ( | const uint8_t * | ip_addr, |
uint16_t | port, | ||
const char * | src, | ||
const char * | dst | ||
) |
Put a file to remote TFTP server.
[in] | ip_addr | IP address of remote TFTP server. |
[in] | port | port number of TFTP server. |
[in] | src | local file name, a null-terminated string. |
[in] | dst | remote file name, a null-terminated string. |
The function tftp_client_put starts the TFTP client to transfer a file from the local system to remote TFTP server. This causes the TFTP client to start a TFTP session by connecting to a TFTP server on the UDP port specified in the function argument. If the port is not specified (port has a value of 0), then the system uses a standard TFTP server port 69.
The argument ip_addr points to an array of 4 bytes containing the dotted-decimal notation of the IP address of the TFTP server.
The arguments src and dst are pointers to 0-terminated names of source and destination files. Source file is the local file to be sent. Destination file resides on the TFTP server to which the source file content will be copied. If the destination file is not specified (dst has a value of NULL), then the source file name will be used as the destination file name.
Code Example