1 | /** @file
|
---|
2 | This EFI_MTFTP6_PROTOCOL interface implementation.
|
---|
3 |
|
---|
4 | It supports the following RFCs:
|
---|
5 | RFC1350 - THE TFTP PROTOCOL (REVISION 2)
|
---|
6 | RFC2090 - TFTP Multicast Option
|
---|
7 | RFC2347 - TFTP Option Extension
|
---|
8 | RFC2348 - TFTP Blocksize Option
|
---|
9 | RFC2349 - TFTP Timeout Interval and Transfer Size Options
|
---|
10 |
|
---|
11 | Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
|
---|
12 |
|
---|
13 | This program and the accompanying materials
|
---|
14 | are licensed and made available under the terms and conditions of the BSD License
|
---|
15 | which accompanies this distribution. The full text of the license may be found at
|
---|
16 | http://opensource.org/licenses/bsd-license.php.
|
---|
17 |
|
---|
18 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
---|
19 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
---|
20 |
|
---|
21 | **/
|
---|
22 |
|
---|
23 | #include "Mtftp6Impl.h"
|
---|
24 |
|
---|
25 | EFI_MTFTP6_PROTOCOL gMtftp6ProtocolTemplate = {
|
---|
26 | EfiMtftp6GetModeData,
|
---|
27 | EfiMtftp6Configure,
|
---|
28 | EfiMtftp6GetInfo,
|
---|
29 | EfiMtftp6ParseOptions,
|
---|
30 | EfiMtftp6ReadFile,
|
---|
31 | EfiMtftp6WriteFile,
|
---|
32 | EfiMtftp6ReadDirectory,
|
---|
33 | EfiMtftp6Poll
|
---|
34 | };
|
---|
35 |
|
---|
36 | /**
|
---|
37 | Returns the current operating mode data for the MTFTP6 instance.
|
---|
38 |
|
---|
39 | The GetModeData() function returns the current operating mode and
|
---|
40 | cached data packet for the MTFTP6 instance.
|
---|
41 |
|
---|
42 | @param[in] This Pointer to the EFI_MTFTP6_PROTOCOL instance.
|
---|
43 | @param[out] ModeData The buffer in which the EFI MTFTPv6 Protocol driver mode
|
---|
44 | data is returned.
|
---|
45 |
|
---|
46 | @retval EFI_SUCCESS The configuration data was returned successfully.
|
---|
47 | @retval EFI_OUT_OF_RESOURCES The required mode data could not be allocated.
|
---|
48 | @retval EFI_INVALID_PARAMETER This is NULL or ModeData is NULL.
|
---|
49 |
|
---|
50 | **/
|
---|
51 | EFI_STATUS
|
---|
52 | EFIAPI
|
---|
53 | EfiMtftp6GetModeData (
|
---|
54 | IN EFI_MTFTP6_PROTOCOL *This,
|
---|
55 | OUT EFI_MTFTP6_MODE_DATA *ModeData
|
---|
56 | )
|
---|
57 | {
|
---|
58 | MTFTP6_INSTANCE *Instance;
|
---|
59 | EFI_TPL OldTpl;
|
---|
60 |
|
---|
61 | if (This == NULL || ModeData == NULL) {
|
---|
62 | return EFI_INVALID_PARAMETER;
|
---|
63 | }
|
---|
64 |
|
---|
65 | OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
|
---|
66 | Instance = MTFTP6_INSTANCE_FROM_THIS (This);
|
---|
67 |
|
---|
68 | //
|
---|
69 | // Copy back the configure data if the instance already configured.
|
---|
70 | //
|
---|
71 | if (Instance->Config != NULL) {
|
---|
72 | CopyMem (
|
---|
73 | &ModeData->ConfigData,
|
---|
74 | Instance->Config,
|
---|
75 | sizeof (EFI_MTFTP6_CONFIG_DATA)
|
---|
76 | );
|
---|
77 | } else {
|
---|
78 | ZeroMem (
|
---|
79 | &ModeData->ConfigData,
|
---|
80 | sizeof (EFI_MTFTP6_CONFIG_DATA)
|
---|
81 | );
|
---|
82 | }
|
---|
83 |
|
---|
84 | //
|
---|
85 | // Set the current support options in mode data.
|
---|
86 | //
|
---|
87 | ModeData->SupportedOptionCount = MTFTP6_SUPPORTED_OPTIONS_NUM;
|
---|
88 | ModeData->SupportedOptions = (UINT8 **) mMtftp6SupportedOptions;
|
---|
89 |
|
---|
90 | gBS->RestoreTPL (OldTpl);
|
---|
91 |
|
---|
92 | return EFI_SUCCESS;
|
---|
93 | }
|
---|
94 |
|
---|
95 |
|
---|
96 | /**
|
---|
97 | Initializes, changes, or resets the default operational setting for
|
---|
98 | this EFI MTFTPv6 Protocol driver instance.
|
---|
99 |
|
---|
100 | The Configure() function is used to set and change the configuration
|
---|
101 | data for this EFI MTFTPv6 Protocol driver instance. The configuration
|
---|
102 | data can be reset to startup defaults by calling Configure() with
|
---|
103 | MtftpConfigData set to NULL. Whenever the instance is reset, any
|
---|
104 | pending operation is aborted. By changing the EFI MTFTPv6 Protocol
|
---|
105 | driver instance configuration data, the client can connect to
|
---|
106 | different MTFTPv6 servers. The configuration parameters in
|
---|
107 | MtftpConfigData are used as the default parameters in later MTFTPv6
|
---|
108 | operations and can be overridden in later operations.
|
---|
109 |
|
---|
110 | @param[in] This Pointer to the EFI_MTFTP6_PROTOCOL instance.
|
---|
111 | @param[in] MtftpConfigData Pointer to the configuration data structure.
|
---|
112 |
|
---|
113 | @retval EFI_SUCCESS The EFI MTFTPv6 Protocol instance was configured successfully.
|
---|
114 | @retval EFI_INVALID_PARAMETER One or more following conditions are TRUE:
|
---|
115 | - This is NULL.
|
---|
116 | - MtftpConfigData.StationIp is neither zero nor one
|
---|
117 | of the configured IP addresses in the underlying IPv6 driver.
|
---|
118 | - MtftpCofigData.ServerIp is not a valid IPv6 unicast address.
|
---|
119 | Note: It does not match the UEFI 2.3 Specification.
|
---|
120 | @retval EFI_ACCESS_DENIED - The configuration could not be changed at this time because there
|
---|
121 | is some MTFTP background operation in progress.
|
---|
122 | - MtftpCofigData.LocalPort is already in use.
|
---|
123 | Note: It does not match the UEFI 2.3 Specification.
|
---|
124 | @retval EFI_NO_MAPPING The underlying IPv6 driver was responsible for choosing a source
|
---|
125 | address for this instance, but no source address was available for use.
|
---|
126 | @retval EFI_OUT_OF_RESOURCES The EFI MTFTPv6 Protocol driver instance data could not be
|
---|
127 | allocated.
|
---|
128 | Note: It is not defined in the UEFI 2.3 Specification.
|
---|
129 | @retval EFI_DEVICE_ERROR An unexpected system or network error occurred. The EFI
|
---|
130 | MTFTPv6 Protocol driver instance is not configured.
|
---|
131 | Note: It is not defined in the UEFI 2.3 Specification.
|
---|
132 |
|
---|
133 | **/
|
---|
134 | EFI_STATUS
|
---|
135 | EFIAPI
|
---|
136 | EfiMtftp6Configure (
|
---|
137 | IN EFI_MTFTP6_PROTOCOL *This,
|
---|
138 | IN EFI_MTFTP6_CONFIG_DATA *MtftpConfigData OPTIONAL
|
---|
139 | )
|
---|
140 | {
|
---|
141 | MTFTP6_SERVICE *Service;
|
---|
142 | MTFTP6_INSTANCE *Instance;
|
---|
143 | EFI_UDP6_PROTOCOL *Udp6;
|
---|
144 | EFI_UDP6_CONFIG_DATA Udp6Cfg;
|
---|
145 | EFI_STATUS Status;
|
---|
146 | EFI_TPL OldTpl;
|
---|
147 |
|
---|
148 | if (This == NULL) {
|
---|
149 | return EFI_INVALID_PARAMETER;
|
---|
150 | }
|
---|
151 |
|
---|
152 | if (MtftpConfigData != NULL && !NetIp6IsValidUnicast (&MtftpConfigData->ServerIp)) {
|
---|
153 | return EFI_INVALID_PARAMETER;
|
---|
154 | }
|
---|
155 |
|
---|
156 | OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
|
---|
157 | Instance = MTFTP6_INSTANCE_FROM_THIS (This);
|
---|
158 | Service = Instance->Service;
|
---|
159 | Status = EFI_SUCCESS;
|
---|
160 |
|
---|
161 | if (MtftpConfigData == NULL) {
|
---|
162 | //
|
---|
163 | // Configure the instance as NULL to abort the current session.
|
---|
164 | //
|
---|
165 | Mtftp6OperationClean (Instance, EFI_ABORTED);
|
---|
166 | FreePool (Instance->Config);
|
---|
167 | Instance->Config = NULL;
|
---|
168 | } else {
|
---|
169 | //
|
---|
170 | // It's not allowed to configure one instance twice without configure null.
|
---|
171 | //
|
---|
172 | if (Instance->Config != NULL) {
|
---|
173 | Status = EFI_ACCESS_DENIED;
|
---|
174 | goto ON_EXIT;
|
---|
175 | }
|
---|
176 | //
|
---|
177 | // Allocate the configure buffer of the instance and store the user's data.
|
---|
178 | //
|
---|
179 | Instance->Config = AllocateZeroPool (sizeof (EFI_MTFTP6_CONFIG_DATA));
|
---|
180 |
|
---|
181 | if (Instance->Config == NULL) {
|
---|
182 | Status = EFI_OUT_OF_RESOURCES;
|
---|
183 | goto ON_EXIT;
|
---|
184 | }
|
---|
185 |
|
---|
186 | CopyMem (Instance->Config, MtftpConfigData, sizeof (EFI_MTFTP6_CONFIG_DATA));
|
---|
187 |
|
---|
188 | //
|
---|
189 | // Don't configure the udpio here because each operation might override
|
---|
190 | // the configuration, so delay udpio configuration in each operation.
|
---|
191 | //
|
---|
192 | Instance->UdpIo = UdpIoCreateIo (
|
---|
193 | Service->Controller,
|
---|
194 | Service->Image,
|
---|
195 | Mtftp6ConfigDummyUdpIo,
|
---|
196 | UDP_IO_UDP6_VERSION,
|
---|
197 | NULL
|
---|
198 | );
|
---|
199 |
|
---|
200 | if (Instance->UdpIo == NULL) {
|
---|
201 | Status = EFI_OUT_OF_RESOURCES;
|
---|
202 | goto ON_EXIT;
|
---|
203 | }
|
---|
204 |
|
---|
205 | //
|
---|
206 | // Continue to configure the downside Udp6 instance by user's data.
|
---|
207 | //
|
---|
208 | ZeroMem (&Udp6Cfg, sizeof (EFI_UDP6_CONFIG_DATA));
|
---|
209 |
|
---|
210 | Udp6Cfg.AcceptPromiscuous = FALSE;
|
---|
211 | Udp6Cfg.AcceptAnyPort = FALSE;
|
---|
212 | Udp6Cfg.AllowDuplicatePort = FALSE;
|
---|
213 | Udp6Cfg.TrafficClass = 0;
|
---|
214 | Udp6Cfg.HopLimit = 128;
|
---|
215 | Udp6Cfg.ReceiveTimeout = 0;
|
---|
216 | Udp6Cfg.TransmitTimeout = 0;
|
---|
217 | Udp6Cfg.StationPort = Instance->Config->LocalPort;
|
---|
218 | Udp6Cfg.RemotePort = Instance->Config->InitialServerPort;
|
---|
219 |
|
---|
220 | CopyMem (
|
---|
221 | &Udp6Cfg.StationAddress,
|
---|
222 | &Instance->Config->StationIp,
|
---|
223 | sizeof(EFI_IPv6_ADDRESS)
|
---|
224 | );
|
---|
225 |
|
---|
226 | CopyMem (
|
---|
227 | &Udp6Cfg.RemoteAddress,
|
---|
228 | &Instance->Config->ServerIp,
|
---|
229 | sizeof (EFI_IPv6_ADDRESS)
|
---|
230 | );
|
---|
231 |
|
---|
232 | Udp6 = Instance->UdpIo->Protocol.Udp6;
|
---|
233 | Status = Udp6->Configure (Udp6, &Udp6Cfg);
|
---|
234 |
|
---|
235 | if (EFI_ERROR (Status)) {
|
---|
236 | goto ON_EXIT;
|
---|
237 | }
|
---|
238 | }
|
---|
239 |
|
---|
240 | ON_EXIT:
|
---|
241 | if (EFI_ERROR (Status)) {
|
---|
242 | if (Instance->Config != NULL) {
|
---|
243 | FreePool (Instance->Config);
|
---|
244 | Instance->Config = NULL;
|
---|
245 | }
|
---|
246 | if (Instance->UdpIo != NULL) {
|
---|
247 | UdpIoFreeIo (Instance->UdpIo);
|
---|
248 | Instance->UdpIo = NULL;
|
---|
249 | }
|
---|
250 | }
|
---|
251 | gBS->RestoreTPL (OldTpl);
|
---|
252 | return Status;
|
---|
253 | }
|
---|
254 |
|
---|
255 |
|
---|
256 | /**
|
---|
257 | Get the information of the download from the server.
|
---|
258 |
|
---|
259 | The GetInfo() function assembles an MTFTPv6 request packet
|
---|
260 | with options, sends it to the MTFTPv6 server, and may return
|
---|
261 | an MTFTPv6 OACK, MTFTPv6 ERROR, or ICMP ERROR packet. Retries
|
---|
262 | occur only if no response packets are received from the MTFTPv6
|
---|
263 | server before the timeout expires.
|
---|
264 |
|
---|
265 | @param[in] This Pointer to the EFI_MTFTP6_PROTOCOL instance.
|
---|
266 | @param[in] OverrideData Data that is used to override the existing parameters. If NULL, the
|
---|
267 | default parameters that were set in the EFI_MTFTP6_PROTOCOL.Configure()
|
---|
268 | function are used.
|
---|
269 | @param[in] Filename Pointer to null-terminated ASCII file name string.
|
---|
270 | @param[in] ModeStr Pointer to null-terminated ASCII mode string. If NULL, octet will be used.
|
---|
271 | @param[in] OptionCount Number of option/value string pairs in OptionList.
|
---|
272 | @param[in] OptionList Pointer to array of option/value string pairs. Ignored if
|
---|
273 | OptionCount is zero.
|
---|
274 | @param[out] PacketLength The number of bytes in the returned packet.
|
---|
275 | @param[out] Packet The pointer to the received packet. This buffer must be freed by
|
---|
276 | the caller.
|
---|
277 |
|
---|
278 | @retval EFI_SUCCESS An MTFTPv6 OACK packet was received and is in the Packet.
|
---|
279 | Note: It does not match the UEFI 2.3 Specification.
|
---|
280 | @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
|
---|
281 | - This is NULL.
|
---|
282 | - Filename is NULL.
|
---|
283 | - OptionCount is not zero and OptionList is NULL.
|
---|
284 | - One or more options in OptionList have wrong format.
|
---|
285 | - PacketLength is NULL.
|
---|
286 | - OverrideData.ServerIp is not valid unicast IPv6 addresses.
|
---|
287 | @retval EFI_UNSUPPORTED One or more options in the OptionList are unsupported by
|
---|
288 | this implementation.
|
---|
289 | @retval EFI_NOT_STARTED The EFI MTFTPv6 Protocol driver has not been started.
|
---|
290 | @retval EFI_NO_MAPPING The underlying IPv6 driver was responsible for choosing a source
|
---|
291 | address for this instance, but no source address was available for use.
|
---|
292 | @retval EFI_ACCESS_DENIED The previous operation has not completed yet.
|
---|
293 | @retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated.
|
---|
294 | @retval EFI_TFTP_ERROR An MTFTPv6 ERROR packet was received and is in the Packet.
|
---|
295 | @retval EFI_NETWORK_UNREACHABLE An ICMP network unreachable error packet was received and the Packet is set to NULL.
|
---|
296 | Note: It is not defined in UEFI 2.3 Specification.
|
---|
297 | @retval EFI_HOST_UNREACHABLE An ICMP host unreachable error packet was received and the Packet is set to NULL.
|
---|
298 | Note: It is not defined in the UEFI 2.3 Specification.
|
---|
299 | @retval EFI_PROTOCOL_UNREACHABLE An ICMP protocol unreachable error packet was received and the Packet is set to NULL.
|
---|
300 | Note: It is not defined in the UEFI 2.3 Specification.
|
---|
301 | @retval EFI_PORT_UNREACHABLE An ICMP port unreachable error packet was received and the Packet is set to NULL.
|
---|
302 | @retval EFI_ICMP_ERROR Some other ICMP ERROR packet was received and the Packet is set to NULL.
|
---|
303 | Note: It does not match the UEFI 2.3 Specification.
|
---|
304 | @retval EFI_PROTOCOL_ERROR An unexpected MTFTPv6 packet was received and is in the Packet.
|
---|
305 | @retval EFI_TIMEOUT No responses were received from the MTFTPv6 server.
|
---|
306 | @retval EFI_DEVICE_ERROR An unexpected network error or system error occurred.
|
---|
307 | @retval EFI_NO_MEDIA There was a media error.
|
---|
308 |
|
---|
309 | **/
|
---|
310 | EFI_STATUS
|
---|
311 | EFIAPI
|
---|
312 | EfiMtftp6GetInfo (
|
---|
313 | IN EFI_MTFTP6_PROTOCOL *This,
|
---|
314 | IN EFI_MTFTP6_OVERRIDE_DATA *OverrideData OPTIONAL,
|
---|
315 | IN UINT8 *Filename,
|
---|
316 | IN UINT8 *ModeStr OPTIONAL,
|
---|
317 | IN UINT8 OptionCount,
|
---|
318 | IN EFI_MTFTP6_OPTION *OptionList OPTIONAL,
|
---|
319 | OUT UINT32 *PacketLength,
|
---|
320 | OUT EFI_MTFTP6_PACKET **Packet OPTIONAL
|
---|
321 | )
|
---|
322 | {
|
---|
323 | EFI_STATUS Status;
|
---|
324 | EFI_MTFTP6_TOKEN Token;
|
---|
325 | MTFTP6_GETINFO_CONTEXT Context;
|
---|
326 |
|
---|
327 | if (This == NULL ||
|
---|
328 | Filename == NULL ||
|
---|
329 | PacketLength == NULL ||
|
---|
330 | (OptionCount != 0 && OptionList == NULL) ||
|
---|
331 | (OverrideData != NULL && !NetIp6IsValidUnicast (&OverrideData->ServerIp))
|
---|
332 | ) {
|
---|
333 | return EFI_INVALID_PARAMETER;
|
---|
334 | }
|
---|
335 |
|
---|
336 | if (Packet != NULL) {
|
---|
337 | *Packet = NULL;
|
---|
338 | }
|
---|
339 |
|
---|
340 | *PacketLength = 0;
|
---|
341 |
|
---|
342 | Context.Packet = Packet;
|
---|
343 | Context.PacketLen = PacketLength;
|
---|
344 | Context.Status = EFI_SUCCESS;
|
---|
345 |
|
---|
346 | //
|
---|
347 | // Fill fields of the Token for GetInfo operation.
|
---|
348 | //
|
---|
349 | Token.Status = EFI_SUCCESS;
|
---|
350 | Token.Event = NULL;
|
---|
351 | Token.OverrideData = OverrideData;
|
---|
352 | Token.Filename = Filename;
|
---|
353 | Token.ModeStr = ModeStr;
|
---|
354 | Token.OptionCount = OptionCount;
|
---|
355 | Token.OptionList = OptionList;
|
---|
356 | Token.BufferSize = 0;
|
---|
357 | Token.Buffer = NULL;
|
---|
358 | Token.Context = &Context;
|
---|
359 | Token.CheckPacket = Mtftp6CheckPacket;
|
---|
360 | Token.TimeoutCallback = NULL;
|
---|
361 | Token.PacketNeeded = NULL;
|
---|
362 |
|
---|
363 | //
|
---|
364 | // Start the GetInfo operation by issue the Token.
|
---|
365 | //
|
---|
366 | Status = Mtftp6OperationStart (This, &Token, EFI_MTFTP6_OPCODE_RRQ);
|
---|
367 |
|
---|
368 | if (Status == EFI_ABORTED) {
|
---|
369 | //
|
---|
370 | // Return the status if failed to issue.
|
---|
371 | //
|
---|
372 | return Context.Status;
|
---|
373 | }
|
---|
374 |
|
---|
375 | return Status;
|
---|
376 | }
|
---|
377 |
|
---|
378 |
|
---|
379 | /**
|
---|
380 | Parse the options in an MTFTPv6 OACK packet.
|
---|
381 |
|
---|
382 | The ParseOptions() function parses the option fields in an MTFTPv6 OACK
|
---|
383 | packet and returns the number of options that were found, and optionally,
|
---|
384 | a list of pointers to the options in the packet. If one or more of the
|
---|
385 | option fields are not valid, then EFI_PROTOCOL_ERROR is returned and
|
---|
386 | *OptionCount and *OptionList stop at the last valid option.
|
---|
387 |
|
---|
388 | @param[in] This Pointer to the EFI_MTFTP6_PROTOCOL instance.
|
---|
389 | @param[in] PacketLen Length of the OACK packet to be parsed.
|
---|
390 | @param[in] Packet Pointer to the OACK packet to be parsed.
|
---|
391 | @param[out] OptionCount Pointer to the number of options in the following OptionList.
|
---|
392 | @param[out] OptionList Pointer to EFI_MTFTP6_OPTION storage. Each pointer in the
|
---|
393 | OptionList points to the corresponding MTFTP option buffer
|
---|
394 | in the Packet. Call the EFI Boot Service FreePool() to
|
---|
395 | release the OptionList if the options in this OptionList
|
---|
396 | are not needed anymore.
|
---|
397 |
|
---|
398 | @retval EFI_SUCCESS The OACK packet was valid and the OptionCount and
|
---|
399 | OptionList parameters have been updated.
|
---|
400 | @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
|
---|
401 | - PacketLen is 0.
|
---|
402 | - Packet is NULL or Packet is not a valid MTFTPv6 packet.
|
---|
403 | - OptionCount is NULL.
|
---|
404 | @retval EFI_NOT_FOUND No options were found in the OACK packet.
|
---|
405 | @retval EFI_OUT_OF_RESOURCES Storage for the OptionList array can not be allocated.
|
---|
406 | @retval EFI_PROTOCOL_ERROR One or more of the option fields is invalid.
|
---|
407 |
|
---|
408 | **/
|
---|
409 | EFI_STATUS
|
---|
410 | EFIAPI
|
---|
411 | EfiMtftp6ParseOptions (
|
---|
412 | IN EFI_MTFTP6_PROTOCOL *This,
|
---|
413 | IN UINT32 PacketLen,
|
---|
414 | IN EFI_MTFTP6_PACKET *Packet,
|
---|
415 | OUT UINT32 *OptionCount,
|
---|
416 | OUT EFI_MTFTP6_OPTION **OptionList OPTIONAL
|
---|
417 | )
|
---|
418 | {
|
---|
419 | if (This == NULL) {
|
---|
420 | return EFI_INVALID_PARAMETER;
|
---|
421 | }
|
---|
422 |
|
---|
423 | return Mtftp6ParseStart (Packet, PacketLen, OptionCount, OptionList);
|
---|
424 | }
|
---|
425 |
|
---|
426 |
|
---|
427 | /**
|
---|
428 | Download a file from an MTFTPv6 server.
|
---|
429 |
|
---|
430 | The ReadFile() function is used to initialize and start an MTFTPv6 download
|
---|
431 | process, and optionally, wait for completion. When the download operation
|
---|
432 | completes, whether successfully or not, the Token.Status field is updated
|
---|
433 | by the EFI MTFTPv6 Protocol driver, and then Token.Event is signaled if it
|
---|
434 | is not NULL.
|
---|
435 | Data can be downloaded from the MTFTPv6 server into either of the following
|
---|
436 | locations:
|
---|
437 | - A fixed buffer that is pointed to by Token.Buffer
|
---|
438 | - A download service function that is pointed to by Token.CheckPacket.
|
---|
439 | If both Token.Buffer and Token.CheckPacket are used, then Token.CheckPacket
|
---|
440 | will be called first. If the call is successful, the packet will be stored
|
---|
441 | in Token.Buffer.
|
---|
442 |
|
---|
443 | @param[in] This Pointer to the EFI_MTFTP6_PROTOCOL instance.
|
---|
444 | @param[in] Token Pointer to the token structure to provide the parameters that are
|
---|
445 | used in this operation.
|
---|
446 |
|
---|
447 | @retval EFI_SUCCESS The data file has been transferred successfully.
|
---|
448 | @retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated.
|
---|
449 | @retval EFI_BUFFER_TOO_SMALL BufferSize is not zero but not large enough to hold the
|
---|
450 | downloaded data in downloading process.
|
---|
451 | Note: It does not match the UEFI 2.3 Specification.
|
---|
452 | @retval EFI_ABORTED Current operation is aborted by user.
|
---|
453 | @retval EFI_NETWORK_UNREACHABLE An ICMP network unreachable error packet was received.
|
---|
454 | Note: It is not defined in the UEFI 2.3 Specification.
|
---|
455 | @retval EFI_HOST_UNREACHABLE An ICMP host unreachable error packet was received.
|
---|
456 | Note: It is not defined in the UEFI 2.3 Specification.
|
---|
457 | @retval EFI_PROTOCOL_UNREACHABLE An ICMP protocol unreachable error packet was received.
|
---|
458 | Note: It is not defined in the UEFI 2.3 Specification.
|
---|
459 | @retval EFI_PORT_UNREACHABLE An ICMP port unreachable error packet was received.
|
---|
460 | Note: It is not defined in the UEFI 2.3 Specification.
|
---|
461 | @retval EFI_ICMP_ERROR An ICMP ERROR packet was received.
|
---|
462 | @retval EFI_TIMEOUT No responses were received from the MTFTPv6 server.
|
---|
463 | @retval EFI_TFTP_ERROR An MTFTPv6 ERROR packet was received.
|
---|
464 | @retval EFI_DEVICE_ERROR An unexpected network error or system error occurred.
|
---|
465 | @retval EFI_NO_MEDIA There was a media error.
|
---|
466 |
|
---|
467 | **/
|
---|
468 | EFI_STATUS
|
---|
469 | EFIAPI
|
---|
470 | EfiMtftp6ReadFile (
|
---|
471 | IN EFI_MTFTP6_PROTOCOL *This,
|
---|
472 | IN EFI_MTFTP6_TOKEN *Token
|
---|
473 | )
|
---|
474 | {
|
---|
475 | return Mtftp6OperationStart (This, Token, EFI_MTFTP6_OPCODE_RRQ);
|
---|
476 | }
|
---|
477 |
|
---|
478 |
|
---|
479 | /**
|
---|
480 | Send a file to an MTFTPv6 server.
|
---|
481 |
|
---|
482 | The WriteFile() function is used to initialize an uploading operation
|
---|
483 | with the given option list and optionally wait for completion. If one
|
---|
484 | or more of the options is not supported by the server, the unsupported
|
---|
485 | options are ignored and a standard TFTP process starts instead. When
|
---|
486 | the upload process completes, whether successfully or not, Token.Event
|
---|
487 | is signaled, and the EFI MTFTPv6 Protocol driver updates Token.Status.
|
---|
488 | The caller can supply the data to be uploaded in the following two modes:
|
---|
489 | - Through the user-provided buffer
|
---|
490 | - Through a callback function
|
---|
491 | With the user-provided buffer, the Token.BufferSize field indicates
|
---|
492 | the length of the buffer, and the driver will upload the data in the
|
---|
493 | buffer. With an EFI_MTFTP6_PACKET_NEEDED callback function, the driver
|
---|
494 | will call this callback function to get more data from the user to upload.
|
---|
495 |
|
---|
496 | @param[in] This Pointer to the EFI_MTFTP6_PROTOCOL instance.
|
---|
497 | @param[in] Token Pointer to the token structure to provide the parameters that are
|
---|
498 | used in this operation.
|
---|
499 |
|
---|
500 | @retval EFI_SUCCESS The upload session has started.
|
---|
501 | @retval EFI_UNSUPPORTED The operation is not supported by this implementation.
|
---|
502 | @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
|
---|
503 | - This is NULL.
|
---|
504 | - Token is NULL.
|
---|
505 | - Token.Filename is NULL.
|
---|
506 | - Token.OptionCount is not zero and Token.OptionList is NULL.
|
---|
507 | - One or more options in Token.OptionList have wrong format.
|
---|
508 | - Token.Buffer and Token.PacketNeeded are both NULL.
|
---|
509 | - Token.OverrideData.ServerIp is not a valid unicast IPv6 address.
|
---|
510 | @retval EFI_UNSUPPORTED One or more options in the Token.OptionList are not
|
---|
511 | supported by this implementation.
|
---|
512 | @retval EFI_NOT_STARTED The EFI MTFTPv6 Protocol driver has not been started.
|
---|
513 | @retval EFI_NO_MAPPING The underlying IPv6 driver was responsible for choosing a source
|
---|
514 | address for this instance, but no source address was available for use.
|
---|
515 | @retval EFI_ALREADY_STARTED This Token is already being used in another MTFTPv6 session.
|
---|
516 | @retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated.
|
---|
517 | @retval EFI_ACCESS_DENIED The previous operation has not completed yet.
|
---|
518 | @retval EFI_DEVICE_ERROR An unexpected network error or system error occurred.
|
---|
519 |
|
---|
520 | **/
|
---|
521 | EFI_STATUS
|
---|
522 | EFIAPI
|
---|
523 | EfiMtftp6WriteFile (
|
---|
524 | IN EFI_MTFTP6_PROTOCOL *This,
|
---|
525 | IN EFI_MTFTP6_TOKEN *Token
|
---|
526 | )
|
---|
527 | {
|
---|
528 | return Mtftp6OperationStart (This, Token, EFI_MTFTP6_OPCODE_WRQ);
|
---|
529 | }
|
---|
530 |
|
---|
531 |
|
---|
532 | /**
|
---|
533 | Download a data file directory from an MTFTPv6 server.
|
---|
534 |
|
---|
535 | The ReadDirectory() function is used to return a list of files on the
|
---|
536 | MTFTPv6 server that are logically (or operationally) related to
|
---|
537 | Token.Filename. The directory request packet that is sent to the server
|
---|
538 | is built with the option list that was provided by the caller, if present.
|
---|
539 | The file information that the server returns is put into either of
|
---|
540 | the following locations:
|
---|
541 | - A fixed buffer that is pointed to by Token.Buffer.
|
---|
542 | - A download service function that is pointed to by Token.CheckPacket.
|
---|
543 | If both Token.Buffer and Token.CheckPacket are used, then Token.CheckPacket
|
---|
544 | will be called first. If the call is successful, the packet will be stored
|
---|
545 | in Token.Buffer.
|
---|
546 |
|
---|
547 | @param[in] This Pointer to the EFI_MTFTP6_PROTOCOL instance.
|
---|
548 | @param[in] Token Pointer to the token structure to provide the parameters that are
|
---|
549 | used in this operation.
|
---|
550 |
|
---|
551 | @retval EFI_SUCCESS The MTFTPv6 related file "directory" has been downloaded.
|
---|
552 | @retval EFI_UNSUPPORTED The EFI MTFTPv6 Protocol driver does not support this function.
|
---|
553 | @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
|
---|
554 | - This is NULL.
|
---|
555 | - Token is NULL.
|
---|
556 | - Token.Filename is NULL.
|
---|
557 | - Token.OptionCount is not zero and Token.OptionList is NULL.
|
---|
558 | - One or more options in Token.OptionList have wrong format.
|
---|
559 | - Token.Buffer and Token.CheckPacket are both NULL.
|
---|
560 | - Token.OverrideData.ServerIp is not valid unicast IPv6 addresses.
|
---|
561 | @retval EFI_UNSUPPORTED One or more options in the Token.OptionList are not
|
---|
562 | supported by this implementation.
|
---|
563 | @retval EFI_NOT_STARTED The EFI MTFTPv6 Protocol driver has not been started.
|
---|
564 | @retval EFI_NO_MAPPING The underlying IPv6 driver was responsible for choosing a source
|
---|
565 | address for this instance, but no source address was available for use.
|
---|
566 | @retval EFI_ALREADY_STARTED This Token is already being used in another MTFTPv6 session.
|
---|
567 | @retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated.
|
---|
568 | @retval EFI_ACCESS_DENIED The previous operation has not completed yet.
|
---|
569 | @retval EFI_DEVICE_ERROR An unexpected network error or system error occurred.
|
---|
570 |
|
---|
571 | **/
|
---|
572 | EFI_STATUS
|
---|
573 | EFIAPI
|
---|
574 | EfiMtftp6ReadDirectory (
|
---|
575 | IN EFI_MTFTP6_PROTOCOL *This,
|
---|
576 | IN EFI_MTFTP6_TOKEN *Token
|
---|
577 | )
|
---|
578 | {
|
---|
579 | return Mtftp6OperationStart (This, Token, EFI_MTFTP6_OPCODE_DIR);
|
---|
580 | }
|
---|
581 |
|
---|
582 |
|
---|
583 | /**
|
---|
584 | Polls for incoming data packets and processes outgoing data packets.
|
---|
585 |
|
---|
586 | The Poll() function can be used by network drivers and applications
|
---|
587 | to increase the rate that data packets are moved between the
|
---|
588 | communications device and the transmit and receive queues. In some
|
---|
589 | systems, the periodic timer event in the managed network driver may
|
---|
590 | not poll the underlying communications device fast enough to transmit
|
---|
591 | and/or receive all data packets without missing incoming packets or
|
---|
592 | dropping outgoing packets. Drivers and applications that are
|
---|
593 | experiencing packet loss should try calling the Poll() function
|
---|
594 | more often.
|
---|
595 |
|
---|
596 | @param[in] This The MTFTP6 protocol instance.
|
---|
597 |
|
---|
598 |
|
---|
599 | @retval EFI_SUCCESS Incoming or outgoing data was processed.
|
---|
600 | @retval EFI_NOT_STARTED This EFI MTFTPv6 Protocol instance has not been started.
|
---|
601 | @retval EFI_INVALID_PARAMETER This is NULL.
|
---|
602 | @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
|
---|
603 | @retval EFI_TIMEOUT Data was dropped out of the transmit and/or receive queue.
|
---|
604 | Consider increasing the polling rate.
|
---|
605 |
|
---|
606 | **/
|
---|
607 | EFI_STATUS
|
---|
608 | EFIAPI
|
---|
609 | EfiMtftp6Poll (
|
---|
610 | IN EFI_MTFTP6_PROTOCOL *This
|
---|
611 | )
|
---|
612 | {
|
---|
613 | MTFTP6_INSTANCE *Instance;
|
---|
614 | EFI_UDP6_PROTOCOL *Udp6;
|
---|
615 |
|
---|
616 | if (This == NULL) {
|
---|
617 | return EFI_INVALID_PARAMETER;
|
---|
618 | }
|
---|
619 |
|
---|
620 | Instance = MTFTP6_INSTANCE_FROM_THIS (This);
|
---|
621 |
|
---|
622 | //
|
---|
623 | // Check the instance whether configured or in destory.
|
---|
624 | //
|
---|
625 | if (Instance->Config == NULL) {
|
---|
626 | return EFI_NOT_STARTED;
|
---|
627 | } else if (Instance->InDestory) {
|
---|
628 | return EFI_DEVICE_ERROR;
|
---|
629 | }
|
---|
630 |
|
---|
631 | Udp6 = Instance->UdpIo->Protocol.Udp6;
|
---|
632 |
|
---|
633 | return Udp6->Poll (Udp6);
|
---|
634 | }
|
---|