]> git.proxmox.com Git - mirror_edk2.git/blob - EdkModulePkg/Universal/Network/PxeBc/Dxe/tftp.h
Make variable names for protocol GUIDs consistent
[mirror_edk2.git] / EdkModulePkg / Universal / Network / PxeBc / Dxe / tftp.h
1 /*++
2
3 Copyright (c) 2006, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
8
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
11
12 Module Name:
13 tftp.h
14
15 Abstract:
16
17 --*/
18
19 #ifndef __TFTP_H__
20 #define __TFTP_H__
21
22 //
23 // Definitions for trivial file transfer protocol functionality with IP v4
24 // Per RFC 1350, July 1992 and RFC 2347, 8, and 9, May 1998
25 //
26 #pragma pack(1)
27 //
28 // max and min packet sizes
29 // (all data packets in transmission except last)
30 //
31 #define MAX_TFTP_PKT_SIZE (BUFFER_ALLOCATE_SIZE - 512)
32 #define MIN_TFTP_PKT_SIZE 512
33
34 //
35 // TFTPv4 OpCodes
36 //
37 #define TFTP_RRQ 1 // read request
38 #define TFTP_WRQ 2 // write request
39 #define TFTP_DATA 3 // data
40 #define TFTP_ACK 4 // acknowledgement
41 #define TFTP_ERROR 5 // error packet
42 #define TFTP_OACK 6 // option acknowledge
43 #define TFTP_DIR 7 // read directory request
44 #define TFTP_DATA8 8
45 #define TFTP_ACK8 9
46
47 //
48 // request packet (read or write)
49 // Fields shown (except file name) are not to be referenced directly,
50 // since their placement is variable within a request packet.
51 // All are null terminated case insensitive ascii strings.
52 //
53 struct Tftpv4Req {
54 UINT16 OpCode; // TFTP Op code
55 UINT8 FileName[2]; // file name
56 UINT8 Mode[2]; // "netascii" or "octet"
57 struct { // optionally, one or more option requests
58 UINT8 Option[2]; // option name
59 UINT8 Value[2]; // value requested
60 } OpReq[1];
61 };
62
63 //
64 // modes
65 //
66 #define MODE_ASCII "netascii"
67 #define MODE_BINARY "octet"
68
69 //
70 // option strings
71 //
72 #define OP_BLKSIZE "blksize" // block size option
73 #define OP_TIMEOUT "timeout" // time to wait before retransmitting
74 #define OP_TFRSIZE "tsize" // total transfer size option
75 #define OP_OVERWRITE "overwrite" // overwrite file option
76 #define OP_BIGBLKNUM "bigblk#" // big block number
77 // See RFC 2347, 8, and 9 for more information on TFTP options
78 // option acknowledge packet (optional)
79 // options not acknowledged are rejected
80 //
81 struct Tftpv4Oack {
82 UINT16 OpCode; // TFTP Op code
83 struct { // optionally, one or more option acknowledgements
84 UINT8 Option[2]; // option name (of those requested)
85 UINT8 Value[2]; // value acknowledged
86 } OpAck[1];
87 };
88
89 //
90 // acknowledge packet
91 //
92 struct Tftpv4Ack {
93 UINT16 OpCode; // TFTP Op code
94 UINT16 BlockNum;
95 };
96
97 //
98 // data packet
99 //
100 struct Tftpv4Data {
101 struct Tftpv4Ack Header;
102 UINT8 Data[512];
103 };
104
105 //
106 // big block number ack packet
107 //
108 struct Tftpv4Ack8 {
109 UINT16 OpCode;
110 UINT64 BlockNum;
111 };
112
113 //
114 // big block number data packet
115 //
116 struct Tftpv4Data8 {
117 struct Tftpv4Ack8 Header;
118 UINT8 Data[506];
119 };
120
121 //
122 // error packet
123 //
124 struct Tftpv4Error {
125 UINT16 OpCode; // TFTP Op code
126 UINT16 ErrCode; // error code
127 UINT8 ErrMsg[1]; // error message (nul terminated)
128 };
129
130 #pragma pack()
131 //
132 // error codes
133 //
134 #define TFTP_ERR_UNDEF 0 // Not defined, see error message (if any).
135 #define TFTP_ERR_NOT_FOUND 1 // File not found.
136 #define TFTP_ERR_ACCESS 2 // Access violation.
137 #define TFTP_ERR_FULL 3 // Disk full or allocation exceeded.
138 #define TFTP_ERR_ILLEGAL 4 // Illegal TFTP operation.
139 #define TFTP_ERR_BAD_ID 5 // Unknown transfer ID.
140 #define TFTP_ERR_EXISTS 6 // File already exists.
141 #define TFTP_ERR_NO_USER 7 // No such user.
142 #define TFTP_ERR_OPTION 8 // Option negotiation termination
143 //
144 // some defines
145 //
146 #define REQ_RESP_TIMEOUT 5 // Wait five seconds for request response.
147 #define ACK_TIMEOUT 4 // Wait four seconds for ack response.
148 #define NUM_ACK_RETRIES 3
149 #define NUM_MTFTP_OPEN_RETRIES 3
150
151 #endif /* __TFTP_H__ */
152
153 /* EOF - tftp.h */