tftp_common.h
Go to the documentation of this file.
1 /**
2  * @file tftp_common.h
3  * @brief Definitions common to TFTP client and server
4  *
5  * @section License
6  *
7  * SPDX-License-Identifier: GPL-2.0-or-later
8  *
9  * Copyright (C) 2010-2019 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 1.9.6
29  **/
30 
31 #ifndef _TFTP_COMMON_H
32 #define _TFTP_COMMON_H
33 
34 //Dependencies
35 #include "core/net.h"
36 
37 //TFTP port number
38 #define TFTP_PORT 69
39 
40 //C++ guard
41 #ifdef __cplusplus
42 extern "C" {
43 #endif
44 
45 
46 /**
47  * @brief TFTP opcodes
48  **/
49 
50 typedef enum
51 {
52  TFTP_OPCODE_RRQ = 1, ///<Read request
53  TFTP_OPCODE_WRQ = 2, ///<Write request
54  TFTP_OPCODE_DATA = 3, ///<Data
55  TFTP_OPCODE_ACK = 4, ///<Acknowledgment
56  TFTP_OPCODE_ERROR = 5, ///<Error
57  TFTP_OPCODE_OACK = 6 ///<Option acknowledgment
58 } TftpOpcode;
59 
60 
61 /**
62  * @brief TFTP error codes
63  **/
64 
65 typedef enum
66 {
76 
77 
78 //CodeWarrior or Win32 compiler?
79 #if defined(__CWCC__) || defined(_WIN32)
80  #pragma pack(push, 1)
81 #endif
82 
83 
84 /**
85  * @brief Read request packet (RRQ)
86  **/
87 
88 typedef __start_packed struct
89 {
90  uint16_t opcode; //0-1
93 
94 
95 /**
96  * @brief Write request packet (WRQ)
97  **/
98 
99 typedef __start_packed struct
100 {
101  uint16_t opcode; //0-1
102  char_t filename[]; //2
104 
105 
106 /**
107  * @brief Data packet (DATA)
108  **/
109 
110 typedef __start_packed struct
111 {
112  uint16_t opcode; //0-1
113  uint16_t block; //2-3
114  uint8_t data[]; //4
116 
117 
118 /**
119  * @brief Acknowledgment packet (ACK)
120  **/
121 
122 typedef __start_packed struct
123 {
124  uint16_t opcode; //0-1
125  uint16_t block; //2-3
127 
128 
129 /**
130  * @brief Error packet (ERROR)
131  **/
132 
133 typedef __start_packed struct
134 {
135  uint16_t opcode; //0-1
136  uint16_t errorCode; //2-3
139 
140 
141 //CodeWarrior or Win32 compiler?
142 #if defined(__CWCC__) || defined(_WIN32)
143  #pragma pack(pop)
144 #endif
145 
146 //C++ guard
147 #ifdef __cplusplus
148 }
149 #endif
150 
151 #endif
uint16_t block
Definition: tftp_common.h:113
char_t errorMsg[]
Definition: tftp_common.h:137
__start_packed struct @295 TftpRrqPacket
Read request packet (RRQ)
uint8_t data[]
Definition: tftp_common.h:114
__start_packed struct @298 TftpAckPacket
Acknowledgment packet (ACK)
Acknowledgment.
Definition: tftp_common.h:55
Write request.
Definition: tftp_common.h:53
uint16_t errorCode
Definition: tftp_common.h:136
__start_packed struct @299 TftpErrorPacket
Error packet (ERROR)
char_t filename[]
Definition: tftp_common.h:91
TftpErrorCode
TFTP error codes.
Definition: tftp_common.h:65
__start_packed struct _Ipv4Header __end_packed
uint16_t opcode
Definition: tftp_common.h:90
char char_t
Definition: compiler_port.h:43
TftpOpcode
TFTP opcodes.
Definition: tftp_common.h:50
__start_packed struct @296 TftpWrqPacket
Write request packet (WRQ)
TCP/IP stack core.
Option acknowledgment.
Definition: tftp_common.h:57
__start_packed struct @297 TftpDataPacket
Data packet (DATA)
Read request.
Definition: tftp_common.h:52