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