tftp_client.h File Reference

TFTP client. More...

#include "core/net.h"
#include "tftp/tftp_common.h"

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-2024 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.

Author
Oryx Embedded SARL (www.oryx-embedded.com)
Version
2.4.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

TFTP client state.

Enumerator
TFTP_CLIENT_STATE_CLOSED 
TFTP_CLIENT_STATE_RRQ 
TFTP_CLIENT_STATE_WRQ 
TFTP_CLIENT_STATE_DATA 
TFTP_CLIENT_STATE_ACK 
TFTP_CLIENT_STATE_LAST_DATA 
TFTP_CLIENT_STATE_COMPLETE 
TFTP_CLIENT_STATE_ERROR 

Definition at line 111 of file tftp_client.h.

◆ 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]contextPointer to the TFTP client context
[in]interfaceNetwork interface to be used
Returns
Error code

Definition at line 83 of file tftp_client.c.

◆ tftpClientCloseFile()

error_t tftpClientCloseFile ( TftpClientContext context)

Close the file.

Parameters
[in]contextPointer to the TFTP client context
Returns
Error code

Definition at line 524 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]contextPointer to the TFTP client context
[in]serverIpAddrIP address of the TFTP server to connect to
[in]serverPortUDP port number
Returns
Error code

Definition at line 106 of file tftp_client.c.

◆ tftpClientDeinit()

void tftpClientDeinit ( TftpClientContext context)

Release TFTP client context.

Parameters
[in]contextPointer to the TFTP client context

Definition at line 546 of file tftp_client.c.

◆ tftpClientFlushFile()

error_t tftpClientFlushFile ( TftpClientContext context)

Flush pending write operations.

Parameters
[in]contextPointer to the TFTP client context
Returns
Error code

Definition at line 357 of file tftp_client.c.

◆ tftpClientInit()

error_t tftpClientInit ( TftpClientContext context)

TFTP client initialization.

Parameters
[in]contextPointer to the TFTP client context
Returns
Error code

Definition at line 59 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]contextPointer to the TFTP client context
[in]filenameNULL-terminated string specifying the filename
[in]modeFile access mode
Returns
Error code

Definition at line 135 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]contextPointer to the TFTP client context
[in]dataPointer to the buffer where to copy the data
[in]sizeSize of the buffer, in bytes
[out]receivedNumber of data bytes that have been read
[in]flagsReserved parameter
Returns
Error code

Definition at line 422 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]contextPointer to the TFTP client context
[in]dataPointer to a buffer containing the data to be written
[in]lengthNumber of data bytes to write
[in]writtenNumber of bytes that have been written
[in]flagsReserved parameter
Returns
Error code

Definition at line 270 of file tftp_client.c.