]>
Commit | Line | Data |
---|---|---|
83cbd279 | 1 | /** @file\r |
dab714aa | 2 | Support routines for MTFTP.\r |
3 | \r | |
e5eed7d3 HT |
4 | Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>\r |
5 | This program and the accompanying materials\r | |
83cbd279 | 6 | are licensed and made available under the terms and conditions of the BSD License\r |
7 | which accompanies this distribution. The full text of the license may be found at\r | |
dab714aa | 8 | http://opensource.org/licenses/bsd-license.php<BR>\r |
83cbd279 | 9 | \r |
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
12 | \r | |
83cbd279 | 13 | **/\r |
14 | \r | |
15 | #ifndef __EFI_MTFTP4_SUPPORT_H__\r | |
16 | #define __EFI_MTFTP4_SUPPORT_H__\r | |
17 | \r | |
18 | //\r | |
19 | // The structure representing a range of block numbers, [Start, End].\r | |
20 | // It is used to remember the holes in the MTFTP block space. If all\r | |
21 | // the holes are filled in, then the download or upload has completed.\r | |
22 | //\r | |
23 | typedef struct {\r | |
e48e37fc | 24 | LIST_ENTRY Link;\r |
83cbd279 | 25 | INTN Start;\r |
26 | INTN End;\r | |
27 | } MTFTP4_BLOCK_RANGE;\r | |
28 | \r | |
29 | \r | |
dab714aa | 30 | /**\r |
31 | Initialize the block range for either RRQ or WRQ. \r | |
32 | \r | |
33 | RRQ and WRQ have different requirements for Start and End. \r | |
34 | For example, during start up, WRQ initializes its whole valid block range \r | |
35 | to [0, 0xffff]. This is bacause the server will send us a ACK0 to inform us \r | |
36 | to start the upload. When the client received ACK0, it will remove 0 from the \r | |
37 | range, get the next block number, which is 1, then upload the BLOCK1. For RRQ\r | |
38 | without option negotiation, the server will directly send us the BLOCK1 in \r | |
39 | response to the client's RRQ. When received BLOCK1, the client will remove \r | |
40 | it from the block range and send an ACK. It also works if there is option \r | |
41 | negotiation.\r | |
42 | \r | |
43 | @param Head The block range head to initialize\r | |
44 | @param Start The Start block number.\r | |
45 | @param End The last block number.\r | |
46 | \r | |
47 | @retval EFI_OUT_OF_RESOURCES Failed to allocate memory for initial block range\r | |
48 | @retval EFI_SUCCESS The initial block range is created.\r | |
49 | \r | |
50 | **/\r | |
83cbd279 | 51 | EFI_STATUS\r |
52 | Mtftp4InitBlockRange (\r | |
e48e37fc | 53 | IN LIST_ENTRY *Head,\r |
83cbd279 | 54 | IN UINT16 Start,\r |
55 | IN UINT16 End\r | |
56 | );\r | |
57 | \r | |
dab714aa | 58 | /**\r |
59 | Get the first valid block number on the range list.\r | |
60 | \r | |
61 | @param Head The block range head\r | |
62 | \r | |
63 | @return The first valid block number, -1 if the block range is empty. \r | |
64 | \r | |
65 | **/\r | |
83cbd279 | 66 | INTN\r |
67 | Mtftp4GetNextBlockNum (\r | |
e48e37fc | 68 | IN LIST_ENTRY *Head\r |
83cbd279 | 69 | );\r |
70 | \r | |
dab714aa | 71 | /**\r |
72 | Set the last block number of the block range list. \r | |
73 | \r | |
74 | It will remove all the blocks after the Last. MTFTP initialize the block range\r | |
75 | to the maximum possible range, such as [0, 0xffff] for WRQ. When it gets the \r | |
76 | last block number, it will call this function to set the last block number.\r | |
77 | \r | |
78 | @param Head The block range list\r | |
79 | @param Last The last block number\r | |
80 | \r | |
81 | **/\r | |
83cbd279 | 82 | VOID\r |
83 | Mtftp4SetLastBlockNum (\r | |
e48e37fc | 84 | IN LIST_ENTRY *Head,\r |
83cbd279 | 85 | IN UINT16 Last\r |
86 | );\r | |
87 | \r | |
dab714aa | 88 | /**\r |
89 | Remove the block number from the block range list.\r | |
90 | \r | |
91 | @param Head The block range list to remove from\r | |
92 | @param Num The block number to remove\r | |
93 | \r | |
94 | @retval EFI_NOT_FOUND The block number isn't in the block range list\r | |
95 | @retval EFI_SUCCESS The block number has been removed from the list\r | |
96 | @retval EFI_OUT_OF_RESOURCES Failed to allocate resource\r | |
97 | \r | |
98 | **/\r | |
83cbd279 | 99 | EFI_STATUS\r |
100 | Mtftp4RemoveBlockNum (\r | |
e48e37fc | 101 | IN LIST_ENTRY *Head,\r |
83cbd279 | 102 | IN UINT16 Num\r |
103 | );\r | |
104 | \r | |
dab714aa | 105 | /**\r |
106 | Set the timeout for the instance. User a longer time for passive instances.\r | |
107 | \r | |
108 | @param Instance The Mtftp session to set time out\r | |
109 | \r | |
110 | **/\r | |
83cbd279 | 111 | VOID\r |
112 | Mtftp4SetTimeout (\r | |
dab714aa | 113 | IN OUT MTFTP4_PROTOCOL *Instance\r |
83cbd279 | 114 | );\r |
115 | \r | |
dab714aa | 116 | /**\r |
117 | Send the packet for the instance. \r | |
118 | \r | |
119 | It will first save a reference to the packet for later retransmission. \r | |
120 | Then determine the destination port, listen port for requests, and connected \r | |
121 | port for others. At last, send the packet out.\r | |
122 | \r | |
123 | @param Instance The Mtftp instance\r | |
124 | @param Packet The packet to send\r | |
125 | \r | |
126 | @retval EFI_SUCCESS The packet is sent out\r | |
127 | @retval Others Failed to transmit the packet.\r | |
128 | \r | |
129 | **/\r | |
83cbd279 | 130 | EFI_STATUS\r |
131 | Mtftp4SendPacket (\r | |
dab714aa | 132 | IN OUT MTFTP4_PROTOCOL *Instance,\r |
133 | IN OUT NET_BUF *Packet\r | |
83cbd279 | 134 | );\r |
135 | \r | |
dab714aa | 136 | /**\r |
137 | Build then transmit the request packet for the MTFTP session.\r | |
138 | \r | |
139 | @param Instance The Mtftp session\r | |
140 | \r | |
141 | @retval EFI_OUT_OF_RESOURCES Failed to allocate memory for the request\r | |
142 | @retval EFI_SUCCESS The request is built and sent\r | |
143 | @retval Others Failed to transmit the packet.\r | |
144 | \r | |
145 | **/\r | |
83cbd279 | 146 | EFI_STATUS\r |
147 | Mtftp4SendRequest (\r | |
148 | IN MTFTP4_PROTOCOL *Instance\r | |
149 | );\r | |
150 | \r | |
dab714aa | 151 | /**\r |
152 | Build then send an error message.\r | |
153 | \r | |
154 | @param Instance The MTFTP session\r | |
155 | @param ErrCode The error code \r | |
156 | @param ErrInfo The error message\r | |
157 | \r | |
158 | @retval EFI_OUT_OF_RESOURCES Failed to allocate memory for the error packet\r | |
159 | @retval EFI_SUCCESS The error packet is transmitted.\r | |
160 | @retval Others Failed to transmit the packet.\r | |
161 | \r | |
162 | **/\r | |
83cbd279 | 163 | EFI_STATUS\r |
164 | Mtftp4SendError (\r | |
165 | IN MTFTP4_PROTOCOL *Instance,\r | |
166 | IN UINT16 ErrCode,\r | |
dab714aa | 167 | IN UINT8 *ErrInfo\r |
83cbd279 | 168 | );\r |
169 | \r | |
dab714aa | 170 | /**\r |
171 | Retransmit the last packet for the instance.\r | |
172 | \r | |
173 | @param Instance The Mtftp instance\r | |
174 | \r | |
175 | @retval EFI_SUCCESS The last packet is retransmitted.\r | |
176 | @retval Others Failed to retransmit.\r | |
177 | \r | |
178 | **/\r | |
83cbd279 | 179 | EFI_STATUS\r |
180 | Mtftp4Retransmit (\r | |
181 | IN MTFTP4_PROTOCOL *Instance\r | |
182 | );\r | |
183 | \r | |
dab714aa | 184 | /**\r |
185 | The timer ticking function for the Mtftp service instance.\r | |
186 | \r | |
187 | @param Event The ticking event\r | |
188 | @param Context The Mtftp service instance\r | |
189 | \r | |
190 | **/\r | |
83cbd279 | 191 | VOID\r |
192 | EFIAPI\r | |
193 | Mtftp4OnTimerTick (\r | |
194 | IN EFI_EVENT Event,\r | |
195 | IN VOID *Context\r | |
196 | );\r | |
197 | #endif\r |