tftp_server_misc.c File Reference

Helper functions for TFTP server. More...

#include "core/net.h"
#include "tftp/tftp_server.h"
#include "tftp/tftp_server_misc.h"
#include "debug.h"

Go to the source code of this file.

Macros

#define TRACE_LEVEL   TFTP_TRACE_LEVEL
 

Functions

void tftpServerTick (TftpServerContext *context)
 Handle periodic operations. More...
 
TftpClientConnectiontftpServerFindConnection (TftpServerContext *context, NetInterface *interface, const IpAddr *clientIpAddr, uint16_t clientPort)
 Find a connection that matches a given client. More...
 
TftpClientConnectiontftpServerOpenConnection (TftpServerContext *context, NetInterface *interface, const IpAddr *clientIpAddr, uint16_t clientPort)
 Create a new connection. More...
 
void tftpServerCloseConnection (TftpClientConnection *connection)
 Close connection. More...
 
void tftpServerAcceptRequest (TftpServerContext *context)
 Accept connection request. More...
 
void tftpServerProcessPacket (TftpServerContext *context, TftpClientConnection *connection)
 Process incoming packet. More...
 
void tftpServerProcessRrqPacket (TftpServerContext *context, NetInterface *interface, const IpAddr *clientIpAddr, uint16_t clientPort, const TftpRrqPacket *rrqPacket, size_t length)
 Process incoming RRQ packet. More...
 
void tftpServerProcessWrqPacket (TftpServerContext *context, NetInterface *interface, const IpAddr *clientIpAddr, uint16_t clientPort, const TftpWrqPacket *wrqPacket, size_t length)
 Process incoming WRQ packet. More...
 
void tftpServerProcessDataPacket (TftpClientConnection *connection, const TftpDataPacket *dataPacket, size_t length)
 Process incoming DATA packet. More...
 
void tftpServerProcessAckPacket (TftpClientConnection *connection, const TftpAckPacket *ackPacket, size_t length)
 Process incoming ACK packet. More...
 
void tftpServerProcessErrorPacket (TftpClientConnection *connection, const TftpErrorPacket *errorPacket, size_t length)
 Process incoming ERROR packet. More...
 
error_t tftpServerSendDataPacket (TftpClientConnection *connection)
 Send DATA packet. More...
 
error_t tftpServerSendAckPacket (TftpClientConnection *connection)
 Send ACK packet. More...
 
error_t tftpServerSendErrorPacket (TftpClientConnection *connection, uint16_t errorCode, const char_t *errorMsg)
 Send ERROR packet. More...
 
error_t tftpServerRetransmitPacket (TftpClientConnection *connection)
 Retransmit the last packet. More...
 

Detailed Description

Helper functions for TFTP server.

License

SPDX-License-Identifier: GPL-2.0-or-later

Copyright (C) 2010-2026 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.6.4

Definition in file tftp_server_misc.c.

Macro Definition Documentation

◆ TRACE_LEVEL

#define TRACE_LEVEL   TFTP_TRACE_LEVEL

Definition at line 32 of file tftp_server_misc.c.

Function Documentation

◆ tftpServerAcceptRequest()

void tftpServerAcceptRequest ( TftpServerContext context)

Accept connection request.

Parameters
[in]contextPointer to the TFTP server context

Definition at line 310 of file tftp_server_misc.c.

◆ tftpServerCloseConnection()

void tftpServerCloseConnection ( TftpClientConnection connection)

Close connection.

Parameters
[in]connectionPointer to the client connection

Definition at line 269 of file tftp_server_misc.c.

◆ tftpServerFindConnection()

TftpClientConnection* tftpServerFindConnection ( TftpServerContext context,
NetInterface interface,
const IpAddr clientIpAddr,
uint16_t  clientPort 
)

Find a connection that matches a given client.

Parameters
[in]contextPointer to the TFTP server context
[in]interfaceNetwork interface
[in]clientIpAddrIP address of the client
[in]clientPortPort number used by the client
Returns
Pointer to the matching connection, if any

Definition at line 114 of file tftp_server_misc.c.

◆ tftpServerOpenConnection()

TftpClientConnection* tftpServerOpenConnection ( TftpServerContext context,
NetInterface interface,
const IpAddr clientIpAddr,
uint16_t  clientPort 
)

Create a new connection.

Parameters
[in]contextPointer to the TFTP server context
[in]interfaceNetwork interface to be used
[in]clientIpAddrIP address of the client
[in]clientPortPort number used by the client
Returns
Pointer to the structure describing the connection

Definition at line 153 of file tftp_server_misc.c.

◆ tftpServerProcessAckPacket()

void tftpServerProcessAckPacket ( TftpClientConnection connection,
const TftpAckPacket ackPacket,
size_t  length 
)

Process incoming ACK packet.

Parameters
[in]connectionPointer to the client connection
[in]ackPacketPointer to the ACK packet
[in]lengthLength of the packet, in bytes

Definition at line 749 of file tftp_server_misc.c.

◆ tftpServerProcessDataPacket()

void tftpServerProcessDataPacket ( TftpClientConnection connection,
const TftpDataPacket dataPacket,
size_t  length 
)

Process incoming DATA packet.

Parameters
[in]connectionPointer to the client connection
[in]dataPacketPointer to the DATA packet
[in]lengthLength of the packet, in bytes

Definition at line 644 of file tftp_server_misc.c.

◆ tftpServerProcessErrorPacket()

void tftpServerProcessErrorPacket ( TftpClientConnection connection,
const TftpErrorPacket errorPacket,
size_t  length 
)

Process incoming ERROR packet.

Parameters
[in]connectionPointer to the client connection
[in]errorPacketPointer to the ERROR packet
[in]lengthLength of the packet, in bytes

Definition at line 804 of file tftp_server_misc.c.

◆ tftpServerProcessPacket()

void tftpServerProcessPacket ( TftpServerContext context,
TftpClientConnection connection 
)

Process incoming packet.

Parameters
[in]contextPointer to the TFTP server context
[in]connectionPointer to the client connection

Definition at line 366 of file tftp_server_misc.c.

◆ tftpServerProcessRrqPacket()

void tftpServerProcessRrqPacket ( TftpServerContext context,
NetInterface interface,
const IpAddr clientIpAddr,
uint16_t  clientPort,
const TftpRrqPacket rrqPacket,
size_t  length 
)

Process incoming RRQ packet.

Parameters
[in]contextPointer to the TFTP server context
[in]interfaceNetwork interface on which the packet was received
[in]clientIpAddrIP address of the client
[in]clientPortPort number used by the client
[in]rrqPacketPointer to the RRQ packet
[in]lengthLength of the packet, in bytes

Definition at line 427 of file tftp_server_misc.c.

◆ tftpServerProcessWrqPacket()

void tftpServerProcessWrqPacket ( TftpServerContext context,
NetInterface interface,
const IpAddr clientIpAddr,
uint16_t  clientPort,
const TftpWrqPacket wrqPacket,
size_t  length 
)

Process incoming WRQ packet.

Parameters
[in]contextPointer to the TFTP server context
[in]interfaceNetwork interface on which the packet was received
[in]clientIpAddrIP address of the client
[in]clientPortPort number used by the client
[in]wrqPacketPointer to the WRQ packet
[in]lengthLength of the packet, in bytes

Definition at line 535 of file tftp_server_misc.c.

◆ tftpServerRetransmitPacket()

error_t tftpServerRetransmitPacket ( TftpClientConnection connection)

Retransmit the last packet.

Parameters
[in]connectionPointer to the client connection
Returns
Error code

Definition at line 1028 of file tftp_server_misc.c.

◆ tftpServerSendAckPacket()

error_t tftpServerSendAckPacket ( TftpClientConnection connection)

Send ACK packet.

Parameters
[in]connectionPointer to the client connection
Returns
Error code

Definition at line 937 of file tftp_server_misc.c.

◆ tftpServerSendDataPacket()

error_t tftpServerSendDataPacket ( TftpClientConnection connection)

Send DATA packet.

Parameters
[in]connectionPointer to the client connection
Returns
Error code

Definition at line 840 of file tftp_server_misc.c.

◆ tftpServerSendErrorPacket()

error_t tftpServerSendErrorPacket ( TftpClientConnection connection,
uint16_t  errorCode,
const char_t errorMsg 
)

Send ERROR packet.

Parameters
[in]connectionPointer to the client connection
[in]errorCodeInteger indicating the nature of the error
[in]errorMsgError message intended for human consumption
Returns
Error code

Definition at line 979 of file tftp_server_misc.c.

◆ tftpServerTick()

void tftpServerTick ( TftpServerContext context)

Handle periodic operations.

Parameters
[in]contextPointer to the TFTP server context

Definition at line 49 of file tftp_server_misc.c.