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