TFTP client. More...
Go to the source code of this file.
| Data Structures | |
| struct | TftpClientContext | 
| TFTP client context.  More... | |
| Macros | |
| #define | TFTP_CLIENT_SUPPORT ENABLED | 
| #define | TFTP_CLIENT_TICK_INTERVAL 500 | 
| #define | TFTP_CLIENT_MAX_RETRIES 5 | 
| #define | TFTP_CLIENT_TIMEOUT 5000 | 
| #define | TFTP_CLIENT_FINAL_DELAY 10000 | 
| #define | TFTP_CLIENT_BLOCK_SIZE 512 | 
| #define | TFTP_CLIENT_PRIVATE_CONTEXT | 
| #define | TFTP_CLIENT_MAX_PACKET_SIZE (sizeof(TftpDataPacket) + TFTP_CLIENT_BLOCK_SIZE) | 
| Enumerations | |
| enum | TftpFileMode { TFTP_FILE_MODE_READ = 0, TFTP_FILE_MODE_WRITE = 1, TFTP_FILE_MODE_OCTET = 0, TFTP_FILE_MODE_NETASCII = 2 } | 
| File access modes.  More... | |
| enum | TftpClientState { TFTP_CLIENT_STATE_CLOSED = 0, TFTP_CLIENT_STATE_RRQ = 1, TFTP_CLIENT_STATE_WRQ = 2, TFTP_CLIENT_STATE_DATA = 3, TFTP_CLIENT_STATE_ACK = 4, TFTP_CLIENT_STATE_LAST_DATA = 5, TFTP_CLIENT_STATE_COMPLETE = 6, TFTP_CLIENT_STATE_ERROR = 7 } | 
| TFTP client state.  More... | |
| Functions | |
| error_t | tftpClientInit (TftpClientContext *context) | 
| TFTP client initialization.  More... | |
| error_t | tftpClientBindToInterface (TftpClientContext *context, NetInterface *interface) | 
| Bind the TFTP client to a particular network interface.  More... | |
| error_t | tftpClientConnect (TftpClientContext *context, const IpAddr *serverIpAddr, uint16_t serverPort) | 
| Specify the address of the TFTP server.  More... | |
| error_t | tftpClientOpenFile (TftpClientContext *context, const char_t *filename, uint_t mode) | 
| Open a file for reading or writing.  More... | |
| error_t | tftpClientWriteFile (TftpClientContext *context, const void *data, size_t length, size_t *written, uint_t flags) | 
| Write data to the file.  More... | |
| error_t | tftpClientFlushFile (TftpClientContext *context) | 
| Flush pending write operations.  More... | |
| error_t | tftpClientReadFile (TftpClientContext *context, void *data, size_t size, size_t *received, uint_t flags) | 
| Read data from the file.  More... | |
| error_t | tftpClientCloseFile (TftpClientContext *context) | 
| Close the file.  More... | |
| void | tftpClientDeinit (TftpClientContext *context) | 
| Release TFTP client context.  More... | |
Detailed Description
TFTP client.
License
SPDX-License-Identifier: GPL-2.0-or-later
Copyright (C) 2010-2025 Oryx Embedded SARL. All rights reserved.
This file is part of CycloneTCP Open.
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- Version
- 2.5.4
Definition in file tftp_client.h.
Macro Definition Documentation
◆ TFTP_CLIENT_BLOCK_SIZE
| #define TFTP_CLIENT_BLOCK_SIZE 512 | 
Definition at line 75 of file tftp_client.h.
◆ TFTP_CLIENT_FINAL_DELAY
| #define TFTP_CLIENT_FINAL_DELAY 10000 | 
Definition at line 68 of file tftp_client.h.
◆ TFTP_CLIENT_MAX_PACKET_SIZE
| #define TFTP_CLIENT_MAX_PACKET_SIZE (sizeof(TftpDataPacket) + TFTP_CLIENT_BLOCK_SIZE) | 
Definition at line 86 of file tftp_client.h.
◆ TFTP_CLIENT_MAX_RETRIES
| #define TFTP_CLIENT_MAX_RETRIES 5 | 
Definition at line 54 of file tftp_client.h.
◆ TFTP_CLIENT_PRIVATE_CONTEXT
| #define TFTP_CLIENT_PRIVATE_CONTEXT | 
Definition at line 82 of file tftp_client.h.
◆ TFTP_CLIENT_SUPPORT
| #define TFTP_CLIENT_SUPPORT ENABLED | 
Definition at line 40 of file tftp_client.h.
◆ TFTP_CLIENT_TICK_INTERVAL
| #define TFTP_CLIENT_TICK_INTERVAL 500 | 
Definition at line 47 of file tftp_client.h.
◆ TFTP_CLIENT_TIMEOUT
| #define TFTP_CLIENT_TIMEOUT 5000 | 
Definition at line 61 of file tftp_client.h.
Enumeration Type Documentation
◆ TftpClientState
| enum TftpClientState | 
TFTP client state.
Definition at line 111 of file tftp_client.h.
◆ TftpFileMode
| enum TftpFileMode | 
File access modes.
| Enumerator | |
|---|---|
| TFTP_FILE_MODE_READ | |
| TFTP_FILE_MODE_WRITE | |
| TFTP_FILE_MODE_OCTET | |
| TFTP_FILE_MODE_NETASCII | |
Definition at line 98 of file tftp_client.h.
Function Documentation
◆ tftpClientBindToInterface()
| error_t tftpClientBindToInterface | ( | TftpClientContext * | context, | 
| NetInterface * | interface | ||
| ) | 
Bind the TFTP client to a particular network interface.
- Parameters
- 
  [in] context Pointer to the TFTP client context [in] interface Network interface to be used 
- Returns
- Error code
Definition at line 84 of file tftp_client.c.
◆ tftpClientCloseFile()
| error_t tftpClientCloseFile | ( | TftpClientContext * | context | ) | 
Close the file.
- Parameters
- 
  [in] context Pointer to the TFTP client context 
- Returns
- Error code
Definition at line 527 of file tftp_client.c.
◆ tftpClientConnect()
| error_t tftpClientConnect | ( | TftpClientContext * | context, | 
| const IpAddr * | serverIpAddr, | ||
| uint16_t | serverPort | ||
| ) | 
Specify the address of the TFTP server.
- Parameters
- 
  [in] context Pointer to the TFTP client context [in] serverIpAddr IP address of the TFTP server to connect to [in] serverPort UDP port number 
- Returns
- Error code
Definition at line 107 of file tftp_client.c.
◆ tftpClientDeinit()
| void tftpClientDeinit | ( | TftpClientContext * | context | ) | 
Release TFTP client context.
- Parameters
- 
  [in] context Pointer to the TFTP client context 
Definition at line 549 of file tftp_client.c.
◆ tftpClientFlushFile()
| error_t tftpClientFlushFile | ( | TftpClientContext * | context | ) | 
Flush pending write operations.
- Parameters
- 
  [in] context Pointer to the TFTP client context 
- Returns
- Error code
Definition at line 360 of file tftp_client.c.
◆ tftpClientInit()
| error_t tftpClientInit | ( | TftpClientContext * | context | ) | 
TFTP client initialization.
- Parameters
- 
  [in] context Pointer to the TFTP client context 
- Returns
- Error code
Definition at line 60 of file tftp_client.c.
◆ tftpClientOpenFile()
| error_t tftpClientOpenFile | ( | TftpClientContext * | context, | 
| const char_t * | filename, | ||
| uint_t | mode | ||
| ) | 
Open a file for reading or writing.
- Parameters
- 
  [in] context Pointer to the TFTP client context [in] filename NULL-terminated string specifying the filename [in] mode File access mode 
- Returns
- Error code
Definition at line 136 of file tftp_client.c.
◆ tftpClientReadFile()
| error_t tftpClientReadFile | ( | TftpClientContext * | context, | 
| void * | data, | ||
| size_t | size, | ||
| size_t * | received, | ||
| uint_t | flags | ||
| ) | 
Read data from the file.
- Parameters
- 
  [in] context Pointer to the TFTP client context [in] data Pointer to the buffer where to copy the data [in] size Size of the buffer, in bytes [out] received Number of data bytes that have been read [in] flags Reserved parameter 
- Returns
- Error code
Definition at line 425 of file tftp_client.c.
◆ tftpClientWriteFile()
| error_t tftpClientWriteFile | ( | TftpClientContext * | context, | 
| const void * | data, | ||
| size_t | length, | ||
| size_t * | written, | ||
| uint_t | flags | ||
| ) | 
Write data to the file.
- Parameters
- 
  [in] context Pointer to the TFTP client context [in] data Pointer to a buffer containing the data to be written [in] length Number of data bytes to write [in] written Number of bytes that have been written [in] flags Reserved parameter 
- Returns
- Error code
Definition at line 271 of file tftp_client.c.
