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