tftp_client.c File Reference

TFTP client. More...

#include "tftp/tftp_client.h"
#include "tftp/tftp_client_misc.h"
#include "debug.h"

Go to the source code of this file.

Macros

#define TRACE_LEVEL   TFTP_TRACE_LEVEL
 

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.

Description

TFTP is a very simple protocol used to transfer files. Refer to the following RFCs for complete details:

  • RFC 1123: Requirements for Internet Hosts
  • RFC 1350: The TFTP Protocol (Revision 2)
  • RFC 1782: TFTP Option Extension
  • RFC 1783: TFTP Blocksize Option
  • RFC 1784: TFTP Timeout Interval and Transfer Size Options
Author
Oryx Embedded SARL (www.oryx-embedded.com)
Version
1.9.0

Definition in file tftp_client.c.

Macro Definition Documentation

◆ TRACE_LEVEL

#define TRACE_LEVEL   TFTP_TRACE_LEVEL

Definition at line 40 of file tftp_client.c.

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.