]>
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 | |
216f7970 | 200 | if (Instance->UdpIo != NULL) {\r |
201 | Status = gBS->OpenProtocol (\r | |
202 | Instance->UdpIo->UdpHandle,\r | |
203 | &gEfiUdp6ProtocolGuid,\r | |
204 | (VOID **) &Udp6,\r | |
205 | Service->Image,\r | |
206 | Instance->Handle,\r | |
207 | EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER\r | |
208 | );\r | |
209 | if (EFI_ERROR (Status)) {\r | |
210 | goto ON_EXIT;\r | |
211 | }\r | |
212 | }\r | |
75dce340 | 213 | }\r |
a3bcde70 HT |
214 | \r |
215 | if (Instance->UdpIo == NULL) {\r | |
216 | Status = EFI_OUT_OF_RESOURCES;\r | |
217 | goto ON_EXIT;\r | |
218 | }\r | |
219 | \r | |
220 | //\r | |
221 | // Continue to configure the downside Udp6 instance by user's data.\r | |
222 | //\r | |
223 | ZeroMem (&Udp6Cfg, sizeof (EFI_UDP6_CONFIG_DATA));\r | |
224 | \r | |
225 | Udp6Cfg.AcceptPromiscuous = FALSE;\r | |
226 | Udp6Cfg.AcceptAnyPort = FALSE;\r | |
227 | Udp6Cfg.AllowDuplicatePort = FALSE;\r | |
228 | Udp6Cfg.TrafficClass = 0;\r | |
229 | Udp6Cfg.HopLimit = 128;\r | |
230 | Udp6Cfg.ReceiveTimeout = 0;\r | |
231 | Udp6Cfg.TransmitTimeout = 0;\r | |
232 | Udp6Cfg.StationPort = Instance->Config->LocalPort;\r | |
233 | Udp6Cfg.RemotePort = Instance->Config->InitialServerPort;\r | |
234 | \r | |
235 | CopyMem (\r | |
236 | &Udp6Cfg.StationAddress,\r | |
237 | &Instance->Config->StationIp,\r | |
238 | sizeof(EFI_IPv6_ADDRESS)\r | |
239 | );\r | |
240 | \r | |
241 | CopyMem (\r | |
242 | &Udp6Cfg.RemoteAddress,\r | |
243 | &Instance->Config->ServerIp,\r | |
244 | sizeof (EFI_IPv6_ADDRESS)\r | |
245 | );\r | |
246 | \r | |
247 | Udp6 = Instance->UdpIo->Protocol.Udp6;\r | |
248 | Status = Udp6->Configure (Udp6, &Udp6Cfg);\r | |
249 | \r | |
250 | if (EFI_ERROR (Status)) {\r | |
251 | goto ON_EXIT;\r | |
252 | }\r | |
253 | }\r | |
254 | \r | |
255 | ON_EXIT:\r | |
256 | if (EFI_ERROR (Status)) {\r | |
257 | if (Instance->Config != NULL) {\r | |
258 | FreePool (Instance->Config);\r | |
259 | Instance->Config = NULL;\r | |
260 | }\r | |
261 | if (Instance->UdpIo != NULL) {\r | |
262 | UdpIoFreeIo (Instance->UdpIo);\r | |
263 | Instance->UdpIo = NULL;\r | |
264 | }\r | |
265 | }\r | |
266 | gBS->RestoreTPL (OldTpl);\r | |
267 | return Status;\r | |
268 | }\r | |
269 | \r | |
270 | \r | |
271 | /**\r | |
272 | Get the information of the download from the server.\r | |
273 | \r | |
274 | The GetInfo() function assembles an MTFTPv6 request packet\r | |
275 | with options, sends it to the MTFTPv6 server, and may return\r | |
276 | an MTFTPv6 OACK, MTFTPv6 ERROR, or ICMP ERROR packet. Retries\r | |
277 | occur only if no response packets are received from the MTFTPv6\r | |
278 | server before the timeout expires.\r | |
279 | \r | |
280 | @param[in] This Pointer to the EFI_MTFTP6_PROTOCOL instance.\r | |
281 | @param[in] OverrideData Data that is used to override the existing parameters. If NULL, the\r | |
282 | default parameters that were set in the EFI_MTFTP6_PROTOCOL.Configure()\r | |
283 | function are used.\r | |
4f077902 SZ |
284 | @param[in] Filename Pointer to null-terminated ASCII file name string.\r |
285 | @param[in] ModeStr Pointer to null-terminated ASCII mode string. If NULL, octet will be used.\r | |
a3bcde70 HT |
286 | @param[in] OptionCount Number of option/value string pairs in OptionList.\r |
287 | @param[in] OptionList Pointer to array of option/value string pairs. Ignored if\r | |
288 | OptionCount is zero.\r | |
289 | @param[out] PacketLength The number of bytes in the returned packet.\r | |
290 | @param[out] Packet The pointer to the received packet. This buffer must be freed by\r | |
291 | the caller.\r | |
292 | \r | |
293 | @retval EFI_SUCCESS An MTFTPv6 OACK packet was received and is in the Packet.\r | |
294 | Note: It does not match the UEFI 2.3 Specification.\r | |
295 | @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:\r | |
296 | - This is NULL.\r | |
297 | - Filename is NULL.\r | |
298 | - OptionCount is not zero and OptionList is NULL.\r | |
299 | - One or more options in OptionList have wrong format.\r | |
300 | - PacketLength is NULL.\r | |
301 | - OverrideData.ServerIp is not valid unicast IPv6 addresses.\r | |
302 | @retval EFI_UNSUPPORTED One or more options in the OptionList are unsupported by\r | |
303 | this implementation.\r | |
304 | @retval EFI_NOT_STARTED The EFI MTFTPv6 Protocol driver has not been started.\r | |
305 | @retval EFI_NO_MAPPING The underlying IPv6 driver was responsible for choosing a source\r | |
306 | address for this instance, but no source address was available for use.\r | |
307 | @retval EFI_ACCESS_DENIED The previous operation has not completed yet.\r | |
308 | @retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated.\r | |
309 | @retval EFI_TFTP_ERROR An MTFTPv6 ERROR packet was received and is in the Packet.\r | |
310 | @retval EFI_NETWORK_UNREACHABLE An ICMP network unreachable error packet was received and the Packet is set to NULL.\r | |
311 | Note: It is not defined in UEFI 2.3 Specification.\r | |
312 | @retval EFI_HOST_UNREACHABLE An ICMP host unreachable error packet was received and the Packet is set to NULL.\r | |
313 | Note: It is not defined in the UEFI 2.3 Specification.\r | |
314 | @retval EFI_PROTOCOL_UNREACHABLE An ICMP protocol unreachable error packet was received and the Packet is set to NULL.\r | |
315 | Note: It is not defined in the UEFI 2.3 Specification.\r | |
316 | @retval EFI_PORT_UNREACHABLE An ICMP port unreachable error packet was received and the Packet is set to NULL.\r | |
317 | @retval EFI_ICMP_ERROR Some other ICMP ERROR packet was received and the Packet is set to NULL.\r | |
318 | Note: It does not match the UEFI 2.3 Specification.\r | |
319 | @retval EFI_PROTOCOL_ERROR An unexpected MTFTPv6 packet was received and is in the Packet.\r | |
320 | @retval EFI_TIMEOUT No responses were received from the MTFTPv6 server.\r | |
321 | @retval EFI_DEVICE_ERROR An unexpected network error or system error occurred.\r | |
322 | @retval EFI_NO_MEDIA There was a media error.\r | |
323 | \r | |
324 | **/\r | |
325 | EFI_STATUS\r | |
326 | EFIAPI\r | |
327 | EfiMtftp6GetInfo (\r | |
328 | IN EFI_MTFTP6_PROTOCOL *This,\r | |
329 | IN EFI_MTFTP6_OVERRIDE_DATA *OverrideData OPTIONAL,\r | |
330 | IN UINT8 *Filename,\r | |
331 | IN UINT8 *ModeStr OPTIONAL,\r | |
332 | IN UINT8 OptionCount,\r | |
333 | IN EFI_MTFTP6_OPTION *OptionList OPTIONAL,\r | |
334 | OUT UINT32 *PacketLength,\r | |
335 | OUT EFI_MTFTP6_PACKET **Packet OPTIONAL\r | |
336 | )\r | |
337 | {\r | |
338 | EFI_STATUS Status;\r | |
339 | EFI_MTFTP6_TOKEN Token;\r | |
340 | MTFTP6_GETINFO_CONTEXT Context;\r | |
341 | \r | |
342 | if (This == NULL ||\r | |
343 | Filename == NULL ||\r | |
344 | PacketLength == NULL ||\r | |
345 | (OptionCount != 0 && OptionList == NULL) ||\r | |
346 | (OverrideData != NULL && !NetIp6IsValidUnicast (&OverrideData->ServerIp))\r | |
347 | ) {\r | |
348 | return EFI_INVALID_PARAMETER;\r | |
349 | }\r | |
350 | \r | |
351 | if (Packet != NULL) {\r | |
352 | *Packet = NULL;\r | |
353 | }\r | |
354 | \r | |
355 | *PacketLength = 0;\r | |
356 | \r | |
357 | Context.Packet = Packet;\r | |
358 | Context.PacketLen = PacketLength;\r | |
359 | Context.Status = EFI_SUCCESS;\r | |
360 | \r | |
361 | //\r | |
362 | // Fill fields of the Token for GetInfo operation.\r | |
363 | //\r | |
364 | Token.Status = EFI_SUCCESS;\r | |
365 | Token.Event = NULL;\r | |
366 | Token.OverrideData = OverrideData;\r | |
367 | Token.Filename = Filename;\r | |
368 | Token.ModeStr = ModeStr;\r | |
369 | Token.OptionCount = OptionCount;\r | |
370 | Token.OptionList = OptionList;\r | |
371 | Token.BufferSize = 0;\r | |
372 | Token.Buffer = NULL;\r | |
373 | Token.Context = &Context;\r | |
374 | Token.CheckPacket = Mtftp6CheckPacket;\r | |
375 | Token.TimeoutCallback = NULL;\r | |
376 | Token.PacketNeeded = NULL;\r | |
377 | \r | |
378 | //\r | |
379 | // Start the GetInfo operation by issue the Token.\r | |
380 | //\r | |
381 | Status = Mtftp6OperationStart (This, &Token, EFI_MTFTP6_OPCODE_RRQ);\r | |
382 | \r | |
383 | if (Status == EFI_ABORTED) {\r | |
384 | //\r | |
385 | // Return the status if failed to issue.\r | |
386 | //\r | |
387 | return Context.Status;\r | |
388 | }\r | |
389 | \r | |
390 | return Status;\r | |
391 | }\r | |
392 | \r | |
393 | \r | |
394 | /**\r | |
395 | Parse the options in an MTFTPv6 OACK packet.\r | |
396 | \r | |
397 | The ParseOptions() function parses the option fields in an MTFTPv6 OACK\r | |
398 | packet and returns the number of options that were found, and optionally,\r | |
399 | a list of pointers to the options in the packet. If one or more of the\r | |
400 | option fields are not valid, then EFI_PROTOCOL_ERROR is returned and\r | |
401 | *OptionCount and *OptionList stop at the last valid option.\r | |
402 | \r | |
403 | @param[in] This Pointer to the EFI_MTFTP6_PROTOCOL instance.\r | |
404 | @param[in] PacketLen Length of the OACK packet to be parsed.\r | |
405 | @param[in] Packet Pointer to the OACK packet to be parsed.\r | |
406 | @param[out] OptionCount Pointer to the number of options in the following OptionList.\r | |
407 | @param[out] OptionList Pointer to EFI_MTFTP6_OPTION storage. Each pointer in the\r | |
408 | OptionList points to the corresponding MTFTP option buffer\r | |
409 | in the Packet. Call the EFI Boot Service FreePool() to\r | |
410 | release the OptionList if the options in this OptionList\r | |
411 | are not needed anymore.\r | |
412 | \r | |
413 | @retval EFI_SUCCESS The OACK packet was valid and the OptionCount and\r | |
414 | OptionList parameters have been updated.\r | |
415 | @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:\r | |
416 | - PacketLen is 0.\r | |
417 | - Packet is NULL or Packet is not a valid MTFTPv6 packet.\r | |
418 | - OptionCount is NULL.\r | |
419 | @retval EFI_NOT_FOUND No options were found in the OACK packet.\r | |
420 | @retval EFI_OUT_OF_RESOURCES Storage for the OptionList array can not be allocated.\r | |
421 | @retval EFI_PROTOCOL_ERROR One or more of the option fields is invalid.\r | |
422 | \r | |
423 | **/\r | |
424 | EFI_STATUS\r | |
425 | EFIAPI\r | |
426 | EfiMtftp6ParseOptions (\r | |
427 | IN EFI_MTFTP6_PROTOCOL *This,\r | |
428 | IN UINT32 PacketLen,\r | |
429 | IN EFI_MTFTP6_PACKET *Packet,\r | |
430 | OUT UINT32 *OptionCount,\r | |
431 | OUT EFI_MTFTP6_OPTION **OptionList OPTIONAL\r | |
432 | )\r | |
433 | {\r | |
434 | if (This == NULL) {\r | |
435 | return EFI_INVALID_PARAMETER;\r | |
436 | }\r | |
437 | \r | |
438 | return Mtftp6ParseStart (Packet, PacketLen, OptionCount, OptionList);\r | |
439 | }\r | |
440 | \r | |
441 | \r | |
442 | /**\r | |
443 | Download a file from an MTFTPv6 server.\r | |
444 | \r | |
445 | The ReadFile() function is used to initialize and start an MTFTPv6 download\r | |
446 | process, and optionally, wait for completion. When the download operation\r | |
447 | completes, whether successfully or not, the Token.Status field is updated\r | |
448 | by the EFI MTFTPv6 Protocol driver, and then Token.Event is signaled if it\r | |
449 | is not NULL.\r | |
450 | Data can be downloaded from the MTFTPv6 server into either of the following\r | |
451 | locations:\r | |
452 | - A fixed buffer that is pointed to by Token.Buffer\r | |
453 | - A download service function that is pointed to by Token.CheckPacket.\r | |
454 | If both Token.Buffer and Token.CheckPacket are used, then Token.CheckPacket\r | |
455 | will be called first. If the call is successful, the packet will be stored\r | |
456 | in Token.Buffer.\r | |
457 | \r | |
458 | @param[in] This Pointer to the EFI_MTFTP6_PROTOCOL instance.\r | |
459 | @param[in] Token Pointer to the token structure to provide the parameters that are\r | |
460 | used in this operation.\r | |
461 | \r | |
462 | @retval EFI_SUCCESS The data file has been transferred successfully.\r | |
463 | @retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated.\r | |
464 | @retval EFI_BUFFER_TOO_SMALL BufferSize is not zero but not large enough to hold the\r | |
465 | downloaded data in downloading process.\r | |
466 | Note: It does not match the UEFI 2.3 Specification.\r | |
467 | @retval EFI_ABORTED Current operation is aborted by user.\r | |
468 | @retval EFI_NETWORK_UNREACHABLE An ICMP network unreachable error packet was received.\r | |
469 | Note: It is not defined in the UEFI 2.3 Specification.\r | |
470 | @retval EFI_HOST_UNREACHABLE An ICMP host unreachable error packet was received.\r | |
471 | Note: It is not defined in the UEFI 2.3 Specification.\r | |
472 | @retval EFI_PROTOCOL_UNREACHABLE An ICMP protocol unreachable error packet was received.\r | |
473 | Note: It is not defined in the UEFI 2.3 Specification.\r | |
474 | @retval EFI_PORT_UNREACHABLE An ICMP port unreachable error packet was received.\r | |
475 | Note: It is not defined in the UEFI 2.3 Specification.\r | |
476 | @retval EFI_ICMP_ERROR An ICMP ERROR packet was received.\r | |
477 | @retval EFI_TIMEOUT No responses were received from the MTFTPv6 server.\r | |
478 | @retval EFI_TFTP_ERROR An MTFTPv6 ERROR packet was received.\r | |
479 | @retval EFI_DEVICE_ERROR An unexpected network error or system error occurred.\r | |
480 | @retval EFI_NO_MEDIA There was a media error.\r | |
481 | \r | |
482 | **/\r | |
483 | EFI_STATUS\r | |
484 | EFIAPI\r | |
485 | EfiMtftp6ReadFile (\r | |
486 | IN EFI_MTFTP6_PROTOCOL *This,\r | |
487 | IN EFI_MTFTP6_TOKEN *Token\r | |
488 | )\r | |
489 | {\r | |
490 | return Mtftp6OperationStart (This, Token, EFI_MTFTP6_OPCODE_RRQ);\r | |
491 | }\r | |
492 | \r | |
493 | \r | |
494 | /**\r | |
495 | Send a file to an MTFTPv6 server.\r | |
496 | \r | |
497 | The WriteFile() function is used to initialize an uploading operation\r | |
498 | with the given option list and optionally wait for completion. If one\r | |
499 | or more of the options is not supported by the server, the unsupported\r | |
500 | options are ignored and a standard TFTP process starts instead. When\r | |
501 | the upload process completes, whether successfully or not, Token.Event\r | |
502 | is signaled, and the EFI MTFTPv6 Protocol driver updates Token.Status.\r | |
503 | The caller can supply the data to be uploaded in the following two modes:\r | |
504 | - Through the user-provided buffer\r | |
505 | - Through a callback function\r | |
506 | With the user-provided buffer, the Token.BufferSize field indicates\r | |
507 | the length of the buffer, and the driver will upload the data in the\r | |
508 | buffer. With an EFI_MTFTP6_PACKET_NEEDED callback function, the driver\r | |
509 | will call this callback function to get more data from the user to upload.\r | |
510 | \r | |
511 | @param[in] This Pointer to the EFI_MTFTP6_PROTOCOL instance.\r | |
512 | @param[in] Token Pointer to the token structure to provide the parameters that are\r | |
513 | used in this operation.\r | |
514 | \r | |
515 | @retval EFI_SUCCESS The upload session has started.\r | |
516 | @retval EFI_UNSUPPORTED The operation is not supported by this implementation.\r | |
517 | @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:\r | |
518 | - This is NULL.\r | |
519 | - Token is NULL.\r | |
520 | - Token.Filename is NULL.\r | |
521 | - Token.OptionCount is not zero and Token.OptionList is NULL.\r | |
522 | - One or more options in Token.OptionList have wrong format.\r | |
523 | - Token.Buffer and Token.PacketNeeded are both NULL.\r | |
524 | - Token.OverrideData.ServerIp is not a valid unicast IPv6 address.\r | |
525 | @retval EFI_UNSUPPORTED One or more options in the Token.OptionList are not\r | |
526 | supported by this implementation.\r | |
527 | @retval EFI_NOT_STARTED The EFI MTFTPv6 Protocol driver has not been started.\r | |
528 | @retval EFI_NO_MAPPING The underlying IPv6 driver was responsible for choosing a source\r | |
529 | address for this instance, but no source address was available for use.\r | |
530 | @retval EFI_ALREADY_STARTED This Token is already being used in another MTFTPv6 session.\r | |
531 | @retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated.\r | |
532 | @retval EFI_ACCESS_DENIED The previous operation has not completed yet.\r | |
533 | @retval EFI_DEVICE_ERROR An unexpected network error or system error occurred.\r | |
534 | \r | |
535 | **/\r | |
536 | EFI_STATUS\r | |
537 | EFIAPI\r | |
538 | EfiMtftp6WriteFile (\r | |
539 | IN EFI_MTFTP6_PROTOCOL *This,\r | |
540 | IN EFI_MTFTP6_TOKEN *Token\r | |
541 | )\r | |
542 | {\r | |
543 | return Mtftp6OperationStart (This, Token, EFI_MTFTP6_OPCODE_WRQ);\r | |
544 | }\r | |
545 | \r | |
546 | \r | |
547 | /**\r | |
548 | Download a data file directory from an MTFTPv6 server.\r | |
549 | \r | |
550 | The ReadDirectory() function is used to return a list of files on the\r | |
551 | MTFTPv6 server that are logically (or operationally) related to\r | |
552 | Token.Filename. The directory request packet that is sent to the server\r | |
553 | is built with the option list that was provided by the caller, if present.\r | |
554 | The file information that the server returns is put into either of\r | |
555 | the following locations:\r | |
556 | - A fixed buffer that is pointed to by Token.Buffer.\r | |
557 | - A download service function that is pointed to by Token.CheckPacket.\r | |
558 | If both Token.Buffer and Token.CheckPacket are used, then Token.CheckPacket\r | |
559 | will be called first. If the call is successful, the packet will be stored\r | |
560 | in Token.Buffer.\r | |
561 | \r | |
562 | @param[in] This Pointer to the EFI_MTFTP6_PROTOCOL instance.\r | |
563 | @param[in] Token Pointer to the token structure to provide the parameters that are\r | |
564 | used in this operation.\r | |
565 | \r | |
566 | @retval EFI_SUCCESS The MTFTPv6 related file "directory" has been downloaded.\r | |
567 | @retval EFI_UNSUPPORTED The EFI MTFTPv6 Protocol driver does not support this function.\r | |
568 | @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:\r | |
569 | - This is NULL.\r | |
570 | - Token is NULL.\r | |
571 | - Token.Filename is NULL.\r | |
572 | - Token.OptionCount is not zero and Token.OptionList is NULL.\r | |
573 | - One or more options in Token.OptionList have wrong format.\r | |
574 | - Token.Buffer and Token.CheckPacket are both NULL.\r | |
575 | - Token.OverrideData.ServerIp is not valid unicast IPv6 addresses.\r | |
576 | @retval EFI_UNSUPPORTED One or more options in the Token.OptionList are not\r | |
577 | supported by this implementation.\r | |
578 | @retval EFI_NOT_STARTED The EFI MTFTPv6 Protocol driver has not been started.\r | |
579 | @retval EFI_NO_MAPPING The underlying IPv6 driver was responsible for choosing a source\r | |
580 | address for this instance, but no source address was available for use.\r | |
581 | @retval EFI_ALREADY_STARTED This Token is already being used in another MTFTPv6 session.\r | |
582 | @retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated.\r | |
583 | @retval EFI_ACCESS_DENIED The previous operation has not completed yet.\r | |
584 | @retval EFI_DEVICE_ERROR An unexpected network error or system error occurred.\r | |
585 | \r | |
586 | **/\r | |
587 | EFI_STATUS\r | |
588 | EFIAPI\r | |
589 | EfiMtftp6ReadDirectory (\r | |
590 | IN EFI_MTFTP6_PROTOCOL *This,\r | |
591 | IN EFI_MTFTP6_TOKEN *Token\r | |
592 | )\r | |
593 | {\r | |
594 | return Mtftp6OperationStart (This, Token, EFI_MTFTP6_OPCODE_DIR);\r | |
595 | }\r | |
596 | \r | |
597 | \r | |
598 | /**\r | |
599 | Polls for incoming data packets and processes outgoing data packets.\r | |
600 | \r | |
601 | The Poll() function can be used by network drivers and applications\r | |
602 | to increase the rate that data packets are moved between the\r | |
603 | communications device and the transmit and receive queues. In some\r | |
604 | systems, the periodic timer event in the managed network driver may\r | |
605 | not poll the underlying communications device fast enough to transmit\r | |
606 | and/or receive all data packets without missing incoming packets or\r | |
607 | dropping outgoing packets. Drivers and applications that are\r | |
608 | experiencing packet loss should try calling the Poll() function\r | |
609 | more often.\r | |
610 | \r | |
611 | @param[in] This The MTFTP6 protocol instance.\r | |
612 | \r | |
613 | \r | |
614 | @retval EFI_SUCCESS Incoming or outgoing data was processed.\r | |
615 | @retval EFI_NOT_STARTED This EFI MTFTPv6 Protocol instance has not been started.\r | |
616 | @retval EFI_INVALID_PARAMETER This is NULL.\r | |
617 | @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.\r | |
618 | @retval EFI_TIMEOUT Data was dropped out of the transmit and/or receive queue.\r | |
619 | Consider increasing the polling rate.\r | |
620 | \r | |
621 | **/\r | |
622 | EFI_STATUS\r | |
623 | EFIAPI\r | |
624 | EfiMtftp6Poll (\r | |
625 | IN EFI_MTFTP6_PROTOCOL *This\r | |
626 | )\r | |
627 | {\r | |
628 | MTFTP6_INSTANCE *Instance;\r | |
629 | EFI_UDP6_PROTOCOL *Udp6;\r | |
630 | \r | |
631 | if (This == NULL) {\r | |
632 | return EFI_INVALID_PARAMETER;\r | |
633 | }\r | |
634 | \r | |
635 | Instance = MTFTP6_INSTANCE_FROM_THIS (This);\r | |
636 | \r | |
637 | //\r | |
75dce340 | 638 | // Check the instance whether configured or in destroy.\r |
a3bcde70 HT |
639 | //\r |
640 | if (Instance->Config == NULL) {\r | |
641 | return EFI_NOT_STARTED;\r | |
a3bcde70 HT |
642 | }\r |
643 | \r | |
644 | Udp6 = Instance->UdpIo->Protocol.Udp6;\r | |
645 | \r | |
646 | return Udp6->Poll (Udp6);\r | |
647 | }\r |