tftp_server_misc.h
Go to the documentation of this file.
1 /**
2  * @file tftp_server_misc.h
3  * @brief Helper functions for TFTP server
4  *
5  * @section License
6  *
7  * SPDX-License-Identifier: GPL-2.0-or-later
8  *
9  * Copyright (C) 2010-2024 Oryx Embedded SARL. All rights reserved.
10  *
11  * This file is part of CycloneTCP Open.
12  *
13  * This program is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU General Public License
15  * as published by the Free Software Foundation; either version 2
16  * of the License, or (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program; if not, write to the Free Software Foundation,
25  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26  *
27  * @author Oryx Embedded SARL (www.oryx-embedded.com)
28  * @version 2.4.0
29  **/
30 
31 #ifndef _TFTP_SERVER_MISC_H
32 #define _TFTP_SERVER_MISC_H
33 
34 //Dependencies
35 #include "core/net.h"
36 #include "tftp/tftp_server.h"
37 
38 //C++ guard
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
42 
43 //TFTP server related functions
44 void tftpServerTick(TftpServerContext *context);
45 
47  const IpAddr *clientIpAddr, uint16_t clientPort);
48 
50 
52 
54  TftpClientConnection *connection);
55 
56 void tftpServerProcessRrqPacket(TftpServerContext *context, const IpAddr *clientIpAddr,
57  uint16_t clientPort, const TftpRrqPacket *rrqPacket, size_t length);
58 
59 void tftpServerProcessWrqPacket(TftpServerContext *context, const IpAddr *clientIpAddr,
60  uint16_t clientPort, const TftpWrqPacket *wrqPacket, size_t length);
61 
63  const TftpDataPacket *dataPacket, size_t length);
64 
66  const TftpAckPacket *ackPacket, size_t length);
67 
69  const TftpErrorPacket *errorPacket, size_t length);
70 
73 
75  uint16_t errorCode, const char_t *errorMsg);
76 
78 
79 //C++ guard
80 #ifdef __cplusplus
81 }
82 #endif
83 
84 #endif
char char_t
Definition: compiler_port.h:48
error_t
Error codes.
Definition: error.h:43
TCP/IP stack core.
IP network address.
Definition: ip.h:79
uint8_t length
Definition: tcp.h:368
TftpAckPacket
Definition: tftp_common.h:128
TftpDataPacket
Definition: tftp_common.h:117
uint16_t errorCode
Definition: tftp_common.h:138
char_t errorMsg[]
Definition: tftp_common.h:139
TftpRrqPacket
Definition: tftp_common.h:94
TftpErrorPacket
Definition: tftp_common.h:140
TftpWrqPacket
Definition: tftp_common.h:105
TFTP server.
#define TftpClientConnection
Definition: tftp_server.h:109
#define TftpServerContext
Definition: tftp_server.h:113
void tftpServerProcessWrqPacket(TftpServerContext *context, const IpAddr *clientIpAddr, uint16_t clientPort, const TftpWrqPacket *wrqPacket, size_t length)
Process incoming WRQ packet.
error_t tftpServerSendAckPacket(TftpClientConnection *connection)
Send ACK packet.
void tftpServerProcessPacket(TftpServerContext *context, TftpClientConnection *connection)
Process incoming packet.
void tftpServerProcessAckPacket(TftpClientConnection *connection, const TftpAckPacket *ackPacket, size_t length)
Process incoming ACK packet.
error_t tftpServerRetransmitPacket(TftpClientConnection *connection)
Retransmit the last packet.
void tftpServerAcceptRequest(TftpServerContext *context)
Accept connection request.
void tftpServerCloseConnection(TftpClientConnection *connection)
Close client connection.
void tftpServerProcessDataPacket(TftpClientConnection *connection, const TftpDataPacket *dataPacket, size_t length)
Process incoming DATA packet.
error_t tftpServerSendErrorPacket(TftpClientConnection *connection, uint16_t errorCode, const char_t *errorMsg)
Send ERROR packet.
void tftpServerTick(TftpServerContext *context)
Handle periodic operations.
void tftpServerProcessRrqPacket(TftpServerContext *context, const IpAddr *clientIpAddr, uint16_t clientPort, const TftpRrqPacket *rrqPacket, size_t length)
Process incoming RRQ packet.
error_t tftpServerSendDataPacket(TftpClientConnection *connection)
Send DATA packet.
void tftpServerProcessErrorPacket(TftpClientConnection *connection, const TftpErrorPacket *errorPacket, size_t length)
Process incoming ERROR packet.
TftpClientConnection * tftpServerOpenConnection(TftpServerContext *context, const IpAddr *clientIpAddr, uint16_t clientPort)
Create client connection.