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_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

void 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)
 Establish connection with 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 tftpClientReadFile (TftpClientContext *context, void *data, size_t size, size_t *received, uint_t flags)
 Read data from the file. More...
 
error_t tftpClientFlushFile (TftpClientContext *context)
 Flush pending write operations. More...
 
void tftpClientCloseFile (TftpClientContext *context)
 Close the file. More...
 

Detailed Description

TFTP client.

License

Copyright (C) 2010-2018 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
1.9.0

Definition in file tftp_client.h.

Macro Definition Documentation

◆ TFTP_CLIENT_BLOCK_SIZE

#define TFTP_CLIENT_BLOCK_SIZE   512

Definition at line 73 of file tftp_client.h.

◆ TFTP_CLIENT_FINAL_DELAY

#define TFTP_CLIENT_FINAL_DELAY   10000

Definition at line 66 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 79 of file tftp_client.h.

◆ TFTP_CLIENT_MAX_RETRIES

#define TFTP_CLIENT_MAX_RETRIES   5

Definition at line 52 of file tftp_client.h.

◆ TFTP_CLIENT_SUPPORT

#define TFTP_CLIENT_SUPPORT   ENABLED

Definition at line 38 of file tftp_client.h.

◆ TFTP_CLIENT_TICK_INTERVAL

#define TFTP_CLIENT_TICK_INTERVAL   500

Definition at line 45 of file tftp_client.h.

◆ TFTP_CLIENT_TIMEOUT

#define TFTP_CLIENT_TIMEOUT   5000

Definition at line 59 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 104 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 91 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 77 of file tftp_client.c.

◆ tftpClientCloseFile()

void tftpClientCloseFile ( TftpClientContext context)

Close the file.

Parameters
[in]contextPointer to the TFTP client context

Definition at line 502 of file tftp_client.c.

◆ tftpClientConnect()

error_t tftpClientConnect ( TftpClientContext context,
const IpAddr serverIpAddr,
uint16_t  serverPort 
)

Establish connection with 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 100 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 446 of file tftp_client.c.

◆ tftpClientInit()

void tftpClientInit ( TftpClientContext context)

TFTP client initialization.

Parameters
[in]contextPointer to the TFTP client context

Definition at line 56 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 129 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 343 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 256 of file tftp_client.c.