]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/Network/PxeBcDxe/Tftp.h
1. Sync the latest network stack. Add NetLibCreateIPv4DPathNode () in netlib library.
[mirror_edk2.git] / MdeModulePkg / Universal / Network / PxeBcDxe / Tftp.h
1 /** @file
2
3 Copyright (c) 2004, 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
20 #ifndef __TFTP_H__
21 #define __TFTP_H__
22
23 //
24 // Definitions for trivial file transfer protocol functionality with IP v4
25 // Per RFC 1350, July 1992 and RFC 2347, 8, and 9, May 1998
26 //
27 #pragma pack(1)
28 //
29 // max and min packet sizes
30 // (all data packets in transmission except last)
31 //
32 #define MAX_TFTP_PKT_SIZE (BUFFER_ALLOCATE_SIZE - 512)
33 #define MIN_TFTP_PKT_SIZE 512
34
35 //
36 // TFTPv4 OpCodes
37 //
38 #define TFTP_RRQ 1 // read request
39 #define TFTP_WRQ 2 // write request
40 #define TFTP_DATA 3 // data
41 #define TFTP_ACK 4 // acknowledgement
42 #define TFTP_ERROR 5 // error packet
43 #define TFTP_OACK 6 // option acknowledge
44 #define TFTP_DIR 7 // read directory request
45 #define TFTP_DATA8 8
46 #define TFTP_ACK8 9
47
48 //
49 // request packet (read or write)
50 // Fields shown (except file name) are not to be referenced directly,
51 // since their placement is variable within a request packet.
52 // All are null terminated case insensitive ascii strings.
53 //
54 struct Tftpv4Req {
55 UINT16 OpCode; // TFTP Op code
56 UINT8 FileName[2]; // file name
57 UINT8 Mode[2]; // "netascii" or "octet"
58 struct { // optionally, one or more option requests
59 UINT8 Option[2]; // option name
60 UINT8 Value[2]; // value requested
61 } OpReq[1];
62 };
63
64 //
65 // modes
66 //
67 #define MODE_ASCII "netascii"
68 #define MODE_BINARY "octet"
69
70 //
71 // option strings
72 //
73 #define OP_BLKSIZE "blksize" // block size option
74 #define OP_TIMEOUT "timeout" // time to wait before retransmitting
75 #define OP_TFRSIZE "tsize" // total transfer size option
76 #define OP_OVERWRITE "overwrite" // overwrite file option
77 #define OP_BIGBLKNUM "bigblk#" // big block number
78 // See RFC 2347, 8, and 9 for more information on TFTP options
79 // option acknowledge packet (optional)
80 // options not acknowledged are rejected
81 //
82 struct Tftpv4Oack {
83 UINT16 OpCode; // TFTP Op code
84 struct { // optionally, one or more option acknowledgements
85 UINT8 Option[2]; // option name (of those requested)
86 UINT8 Value[2]; // value acknowledged
87 } OpAck[1];
88 };
89
90 //
91 // acknowledge packet
92 //
93 struct Tftpv4Ack {
94 UINT16 OpCode; // TFTP Op code
95 UINT16 BlockNum;
96 };
97
98 //
99 // data packet
100 //
101 struct Tftpv4Data {
102 struct Tftpv4Ack Header;
103 UINT8 Data[512];
104 };
105
106 //
107 // big block number ack packet
108 //
109 struct Tftpv4Ack8 {
110 UINT16 OpCode;
111 UINT64 BlockNum;
112 };
113
114 //
115 // big block number data packet
116 //
117 struct Tftpv4Data8 {
118 struct Tftpv4Ack8 Header;
119 UINT8 Data[506];
120 };
121
122 //
123 // error packet
124 //
125 struct Tftpv4Error {
126 UINT16 OpCode; // TFTP Op code
127 UINT16 ErrCode; // error code
128 UINT8 ErrMsg[1]; // error message (nul terminated)
129 };
130
131 #pragma pack()
132 //
133 // error codes
134 //
135 #define TFTP_ERR_UNDEF 0 // Not defined, see error message (if any).
136 #define TFTP_ERR_NOT_FOUND 1 // File not found.
137 #define TFTP_ERR_ACCESS 2 // Access violation.
138 #define TFTP_ERR_FULL 3 // Disk full or allocation exceeded.
139 #define TFTP_ERR_ILLEGAL 4 // Illegal TFTP operation.
140 #define TFTP_ERR_BAD_ID 5 // Unknown transfer ID.
141 #define TFTP_ERR_EXISTS 6 // File already exists.
142 #define TFTP_ERR_NO_USER 7 // No such user.
143 #define TFTP_ERR_OPTION 8 // Option negotiation termination
144 //
145 // some defines
146 //
147 #define REQ_RESP_TIMEOUT 5 // Wait five seconds for request response.
148 #define ACK_TIMEOUT 4 // Wait four seconds for ack response.
149 #define NUM_ACK_RETRIES 3
150 #define NUM_MTFTP_OPEN_RETRIES 3
151
152 #endif /* __TFTP_H__ */
153
154 /* EOF - tftp.h */