]> git.proxmox.com Git - mirror_edk2.git/blame - NetworkPkg/HttpBootDxe/HttpBootClient.c
NetworkPkg: Fix some typos of "according"
[mirror_edk2.git] / NetworkPkg / HttpBootDxe / HttpBootClient.c
CommitLineData
d933e70a
JW
1/** @file\r
2 Implementation of the boot file download function.\r
3\r
221463c2 4Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.<BR>\r
90f658c4 5(C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>\r
d933e70a
JW
6This program and the accompanying materials are licensed and made available under \r
7the terms and conditions of the BSD License that accompanies this distribution. \r
8The full text of the license may be found at\r
9http://opensource.org/licenses/bsd-license.php. \r
10 \r
11THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
12WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
13\r
14**/\r
15\r
16#include "HttpBootDxe.h"\r
17\r
18/**\r
19 Update the IP and URL device path node to include the boot resource information.\r
20\r
21 @param[in] Private The pointer to the driver's private data.\r
22\r
23 @retval EFI_SUCCESS Device patch successfully updated.\r
24 @retval EFI_OUT_OF_RESOURCES Could not allocate needed resources.\r
25 @retval Others Unexpected error happened.\r
26 \r
27**/\r
28EFI_STATUS\r
29HttpBootUpdateDevicePath (\r
30 IN HTTP_BOOT_PRIVATE_DATA *Private\r
31 )\r
32{\r
33 EFI_DEV_PATH *Node;\r
34 EFI_DEVICE_PATH_PROTOCOL *TmpDevicePath;\r
35 EFI_DEVICE_PATH_PROTOCOL *NewDevicePath;\r
36 UINTN Length;\r
37 EFI_STATUS Status;\r
38\r
39 TmpDevicePath = NULL;\r
40 \r
41 //\r
42 // Update the IP node with DHCP assigned information.\r
43 //\r
44 if (!Private->UsingIpv6) {\r
45 Node = AllocateZeroPool (sizeof (IPv4_DEVICE_PATH));\r
46 if (Node == NULL) {\r
47 return EFI_OUT_OF_RESOURCES;\r
48 }\r
49 Node->Ipv4.Header.Type = MESSAGING_DEVICE_PATH;\r
50 Node->Ipv4.Header.SubType = MSG_IPv4_DP;\r
51 SetDevicePathNodeLength (Node, sizeof (IPv4_DEVICE_PATH));\r
52 CopyMem (&Node->Ipv4.LocalIpAddress, &Private->StationIp, sizeof (EFI_IPv4_ADDRESS));\r
53 Node->Ipv4.RemotePort = Private->Port;\r
54 Node->Ipv4.Protocol = EFI_IP_PROTO_TCP;\r
55 Node->Ipv4.StaticIpAddress = FALSE;\r
56 CopyMem (&Node->Ipv4.GatewayIpAddress, &Private->GatewayIp, sizeof (EFI_IPv4_ADDRESS));\r
57 CopyMem (&Node->Ipv4.SubnetMask, &Private->SubnetMask, sizeof (EFI_IPv4_ADDRESS));\r
b659408b
ZL
58 } else {\r
59 Node = AllocateZeroPool (sizeof (IPv6_DEVICE_PATH));\r
60 if (Node == NULL) {\r
d933e70a
JW
61 return EFI_OUT_OF_RESOURCES;\r
62 }\r
b659408b
ZL
63 Node->Ipv6.Header.Type = MESSAGING_DEVICE_PATH;\r
64 Node->Ipv6.Header.SubType = MSG_IPv6_DP;\r
65 SetDevicePathNodeLength (Node, sizeof (IPv6_DEVICE_PATH));\r
66 Node->Ipv6.PrefixLength = IP6_PREFIX_LENGTH;\r
67 Node->Ipv6.RemotePort = Private->Port;\r
68 Node->Ipv6.Protocol = EFI_IP_PROTO_TCP; \r
69 Node->Ipv6.IpAddressOrigin = 0;\r
70 CopyMem (&Node->Ipv6.LocalIpAddress, &Private->StationIp.v6, sizeof (EFI_IPv6_ADDRESS));\r
71 CopyMem (&Node->Ipv6.RemoteIpAddress, &Private->ServerIp.v6, sizeof (EFI_IPv6_ADDRESS));\r
72 CopyMem (&Node->Ipv6.GatewayIpAddress, &Private->GatewayIp.v6, sizeof (EFI_IPv6_ADDRESS));\r
73 }\r
74 \r
75 TmpDevicePath = AppendDevicePathNode (Private->ParentDevicePath, (EFI_DEVICE_PATH_PROTOCOL*) Node);\r
76 FreePool (Node);\r
77 if (TmpDevicePath == NULL) {\r
78 return EFI_OUT_OF_RESOURCES;\r
d933e70a
JW
79 }\r
80\r
81 //\r
82 // Update the URI node with the boot file URI.\r
83 //\r
84 Length = sizeof (EFI_DEVICE_PATH_PROTOCOL) + AsciiStrSize (Private->BootFileUri);\r
85 Node = AllocatePool (Length);\r
86 if (Node == NULL) {\r
87 FreePool (TmpDevicePath);\r
88 return EFI_OUT_OF_RESOURCES;\r
89 }\r
90 Node->DevPath.Type = MESSAGING_DEVICE_PATH;\r
91 Node->DevPath.SubType = MSG_URI_DP;\r
92 SetDevicePathNodeLength (Node, Length);\r
93 CopyMem ((UINT8*) Node + sizeof (EFI_DEVICE_PATH_PROTOCOL), Private->BootFileUri, AsciiStrSize (Private->BootFileUri));\r
94 \r
95 NewDevicePath = AppendDevicePathNode (TmpDevicePath, (EFI_DEVICE_PATH_PROTOCOL*) Node);\r
96 FreePool (Node);\r
97 FreePool (TmpDevicePath);\r
98 if (NewDevicePath == NULL) {\r
99 return EFI_OUT_OF_RESOURCES;\r
100 }\r
101\r
b659408b
ZL
102 if (!Private->UsingIpv6) {\r
103 //\r
104 // Reinstall the device path protocol of the child handle.\r
105 //\r
106 Status = gBS->ReinstallProtocolInterface (\r
107 Private->Ip4Nic->Controller,\r
108 &gEfiDevicePathProtocolGuid,\r
109 Private->Ip4Nic->DevicePath,\r
110 NewDevicePath\r
111 );\r
112 if (EFI_ERROR (Status)) {\r
113 return Status;\r
114 }\r
115 \r
116 FreePool (Private->Ip4Nic->DevicePath);\r
117 Private->Ip4Nic->DevicePath = NewDevicePath;\r
118 } else {\r
119 //\r
120 // Reinstall the device path protocol of the child handle.\r
121 //\r
122 Status = gBS->ReinstallProtocolInterface (\r
123 Private->Ip6Nic->Controller,\r
124 &gEfiDevicePathProtocolGuid,\r
125 Private->Ip6Nic->DevicePath,\r
126 NewDevicePath\r
127 );\r
128 if (EFI_ERROR (Status)) {\r
129 return Status;\r
130 }\r
131 FreePool (Private->Ip6Nic->DevicePath);\r
132 Private->Ip6Nic->DevicePath = NewDevicePath;\r
d933e70a
JW
133 }\r
134 \r
d933e70a
JW
135 return EFI_SUCCESS;\r
136}\r
137\r
138/**\r
139 Parse the boot file URI information from the selected Dhcp4 offer packet.\r
140\r
141 @param[in] Private The pointer to the driver's private data.\r
142\r
143 @retval EFI_SUCCESS Successfully parsed out all the boot information.\r
144 @retval Others Failed to parse out the boot information.\r
145\r
146**/\r
147EFI_STATUS\r
b659408b 148HttpBootDhcp4ExtractUriInfo (\r
d933e70a
JW
149 IN HTTP_BOOT_PRIVATE_DATA *Private\r
150 )\r
151{\r
152 HTTP_BOOT_DHCP4_PACKET_CACHE *SelectOffer;\r
153 HTTP_BOOT_DHCP4_PACKET_CACHE *HttpOffer;\r
154 UINT32 SelectIndex;\r
155 UINT32 ProxyIndex;\r
156 EFI_DHCP4_PACKET_OPTION *Option;\r
157 EFI_STATUS Status;\r
158\r
159 ASSERT (Private != NULL);\r
160 ASSERT (Private->SelectIndex != 0);\r
161 SelectIndex = Private->SelectIndex - 1;\r
162 ASSERT (SelectIndex < HTTP_BOOT_OFFER_MAX_NUM);\r
163\r
164 Status = EFI_SUCCESS;\r
165\r
166 //\r
167 // SelectOffer contains the IP address configuration and name server configuration.\r
168 // HttpOffer contains the boot file URL.\r
169 //\r
170 SelectOffer = &Private->OfferBuffer[SelectIndex].Dhcp4;\r
fa848a40
FS
171 if (Private->FilePathUri == NULL) {\r
172 //\r
173 // In Corporate environment, we need a HttpOffer.\r
174 //\r
175 if ((SelectOffer->OfferType == HttpOfferTypeDhcpIpUri) || \r
176 (SelectOffer->OfferType == HttpOfferTypeDhcpIpUriDns) ||\r
177 (SelectOffer->OfferType == HttpOfferTypeDhcpNameUriDns)) {\r
178 HttpOffer = SelectOffer;\r
179 } else {\r
180 ASSERT (Private->SelectProxyType != HttpOfferTypeMax);\r
181 ProxyIndex = Private->OfferIndex[Private->SelectProxyType][0];\r
182 HttpOffer = &Private->OfferBuffer[ProxyIndex].Dhcp4;\r
183 }\r
184 Private->BootFileUriParser = HttpOffer->UriParser;\r
185 Private->BootFileUri = (CHAR8*) HttpOffer->OptList[HTTP_BOOT_DHCP4_TAG_INDEX_BOOTFILE]->Data;\r
d933e70a 186 } else {\r
fa848a40
FS
187 //\r
188 // In Home environment the BootFileUri comes from the FilePath.\r
189 //\r
190 Private->BootFileUriParser = Private->FilePathUriParser;\r
191 Private->BootFileUri = Private->FilePathUri;\r
d933e70a
JW
192 }\r
193\r
221463c2
JW
194 //\r
195 // Check the URI scheme.\r
196 //\r
197 Status = HttpBootCheckUriScheme (Private->BootFileUri);\r
198 if (EFI_ERROR (Status)) {\r
199 DEBUG ((EFI_D_ERROR, "HttpBootDhcp4ExtractUriInfo: %r.\n", Status));\r
200 return Status;\r
201 }\r
202\r
d933e70a
JW
203 //\r
204 // Configure the default DNS server if server assigned.\r
205 //\r
fa848a40
FS
206 if ((SelectOffer->OfferType == HttpOfferTypeDhcpNameUriDns) || \r
207 (SelectOffer->OfferType == HttpOfferTypeDhcpDns) ||\r
208 (SelectOffer->OfferType == HttpOfferTypeDhcpIpUriDns)) {\r
d933e70a
JW
209 Option = SelectOffer->OptList[HTTP_BOOT_DHCP4_TAG_INDEX_DNS_SERVER];\r
210 ASSERT (Option != NULL);\r
211 Status = HttpBootRegisterIp4Dns (\r
212 Private,\r
213 Option->Length,\r
214 Option->Data\r
215 );\r
216 if (EFI_ERROR (Status)) {\r
217 return Status;\r
218 }\r
219 }\r
220\r
221 //\r
222 // Extract the port from URL, and use default HTTP port 80 if not provided.\r
223 //\r
224 Status = HttpUrlGetPort (\r
fa848a40
FS
225 Private->BootFileUri,\r
226 Private->BootFileUriParser,\r
d933e70a
JW
227 &Private->Port\r
228 );\r
229 if (EFI_ERROR (Status) || Private->Port == 0) {\r
230 Private->Port = 80;\r
231 }\r
232 \r
d933e70a
JW
233 //\r
234 // All boot informations are valid here.\r
235 //\r
236 AsciiPrint ("\n URI: %a", Private->BootFileUri);\r
237\r
238 //\r
239 // Update the device path to include the IP and boot URI information.\r
240 //\r
241 Status = HttpBootUpdateDevicePath (Private);\r
242\r
243 return Status;\r
244}\r
245\r
b659408b
ZL
246/**\r
247 Parse the boot file URI information from the selected Dhcp6 offer packet.\r
248\r
249 @param[in] Private The pointer to the driver's private data.\r
250\r
251 @retval EFI_SUCCESS Successfully parsed out all the boot information.\r
252 @retval Others Failed to parse out the boot information.\r
253\r
254**/\r
255EFI_STATUS\r
256HttpBootDhcp6ExtractUriInfo (\r
257 IN HTTP_BOOT_PRIVATE_DATA *Private\r
258 )\r
259{\r
260 HTTP_BOOT_DHCP6_PACKET_CACHE *SelectOffer;\r
261 HTTP_BOOT_DHCP6_PACKET_CACHE *HttpOffer;\r
262 UINT32 SelectIndex;\r
263 UINT32 ProxyIndex;\r
264 EFI_DHCP6_PACKET_OPTION *Option;\r
265 EFI_IPv6_ADDRESS IpAddr;\r
266 CHAR8 *HostName;\r
b9679cd7 267 UINTN HostNameSize;\r
b659408b
ZL
268 CHAR16 *HostNameStr;\r
269 EFI_STATUS Status;\r
270\r
271 ASSERT (Private != NULL);\r
272 ASSERT (Private->SelectIndex != 0);\r
273 SelectIndex = Private->SelectIndex - 1;\r
274 ASSERT (SelectIndex < HTTP_BOOT_OFFER_MAX_NUM);\r
275\r
276 Status = EFI_SUCCESS;\r
277 HostName = NULL;\r
278 //\r
279 // SelectOffer contains the IP address configuration and name server configuration.\r
280 // HttpOffer contains the boot file URL.\r
281 //\r
282 SelectOffer = &Private->OfferBuffer[SelectIndex].Dhcp6;\r
fa848a40
FS
283 if (Private->FilePathUri == NULL) {\r
284 //\r
285 // In Corporate environment, we need a HttpOffer.\r
286 //\r
287 if ((SelectOffer->OfferType == HttpOfferTypeDhcpIpUri) ||\r
288 (SelectOffer->OfferType == HttpOfferTypeDhcpIpUriDns) ||\r
289 (SelectOffer->OfferType == HttpOfferTypeDhcpNameUriDns)) {\r
290 HttpOffer = SelectOffer;\r
291 } else {\r
292 ASSERT (Private->SelectProxyType != HttpOfferTypeMax);\r
293 ProxyIndex = Private->OfferIndex[Private->SelectProxyType][0];\r
294 HttpOffer = &Private->OfferBuffer[ProxyIndex].Dhcp6;\r
295 }\r
296 Private->BootFileUriParser = HttpOffer->UriParser;\r
297 Private->BootFileUri = (CHAR8*) HttpOffer->OptList[HTTP_BOOT_DHCP6_IDX_BOOT_FILE_URL]->Data;\r
b659408b 298 } else {\r
fa848a40
FS
299 //\r
300 // In Home environment the BootFileUri comes from the FilePath.\r
301 //\r
302 Private->BootFileUriParser = Private->FilePathUriParser;\r
303 Private->BootFileUri = Private->FilePathUri;\r
b659408b
ZL
304 }\r
305\r
306 //\r
221463c2
JW
307 // Check the URI scheme.\r
308 //\r
309 Status = HttpBootCheckUriScheme (Private->BootFileUri);\r
310 if (EFI_ERROR (Status)) {\r
311 DEBUG ((EFI_D_ERROR, "HttpBootDhcp6ExtractUriInfo: %r.\n", Status));\r
312 return Status;\r
313 }\r
314\r
315 //\r
b659408b
ZL
316 // Set the Local station address to IP layer.\r
317 //\r
318 Status = HttpBootSetIp6Address (Private);\r
319 if (EFI_ERROR (Status)) {\r
320 return Status;\r
321 }\r
08c6239d
JW
322\r
323 //\r
324 // Register the IPv6 gateway address to the network device.\r
325 //\r
326 Status = HttpBootSetIp6Gateway (Private);\r
327 if (EFI_ERROR (Status)) {\r
328 return Status;\r
329 }\r
b659408b
ZL
330 \r
331 //\r
332 // Configure the default DNS server if server assigned.\r
333 //\r
fa848a40
FS
334 if ((SelectOffer->OfferType == HttpOfferTypeDhcpNameUriDns) || \r
335 (SelectOffer->OfferType == HttpOfferTypeDhcpDns) ||\r
336 (SelectOffer->OfferType == HttpOfferTypeDhcpIpUriDns)) {\r
b659408b
ZL
337 Option = SelectOffer->OptList[HTTP_BOOT_DHCP6_IDX_DNS_SERVER];\r
338 ASSERT (Option != NULL);\r
339 Status = HttpBootSetIp6Dns (\r
340 Private,\r
341 HTONS (Option->OpLen),\r
342 Option->Data\r
343 );\r
344 if (EFI_ERROR (Status)) {\r
345 return Status;\r
346 }\r
347 }\r
348 \r
349 //\r
350 // Extract the HTTP server Ip frome URL. This is used to Check route table \r
351 // whether can send message to HTTP Server Ip through the GateWay.\r
352 //\r
353 Status = HttpUrlGetIp6 (\r
fa848a40
FS
354 Private->BootFileUri,\r
355 Private->BootFileUriParser,\r
b659408b
ZL
356 &IpAddr\r
357 );\r
358 \r
359 if (EFI_ERROR (Status)) {\r
360 //\r
361 // The Http server address is expressed by Name Ip, so perform DNS resolution\r
362 //\r
363 Status = HttpUrlGetHostName (\r
fa848a40
FS
364 Private->BootFileUri,\r
365 Private->BootFileUriParser,\r
b659408b
ZL
366 &HostName\r
367 );\r
368 if (EFI_ERROR (Status)) {\r
369 return Status;\r
370 }\r
b9679cd7
SZ
371\r
372 HostNameSize = AsciiStrSize (HostName);\r
373 HostNameStr = AllocateZeroPool (HostNameSize * sizeof (CHAR16));\r
b659408b
ZL
374 if (HostNameStr == NULL) {\r
375 Status = EFI_OUT_OF_RESOURCES;\r
376 goto Error;\r
377 }\r
378 \r
b9679cd7 379 AsciiStrToUnicodeStrS (HostName, HostNameStr, HostNameSize);\r
b659408b
ZL
380 Status = HttpBootDns (Private, HostNameStr, &IpAddr);\r
381 FreePool (HostNameStr);\r
382 if (EFI_ERROR (Status)) {\r
383 goto Error;\r
384 } \r
385 } \r
386 \r
08c6239d 387 CopyMem (&Private->ServerIp.v6, &IpAddr, sizeof (EFI_IPv6_ADDRESS));\r
b659408b
ZL
388 \r
389 //\r
390 // Extract the port from URL, and use default HTTP port 80 if not provided.\r
391 //\r
392 Status = HttpUrlGetPort (\r
fa848a40
FS
393 Private->BootFileUri,\r
394 Private->BootFileUriParser,\r
b659408b
ZL
395 &Private->Port\r
396 );\r
397 if (EFI_ERROR (Status) || Private->Port == 0) {\r
398 Private->Port = 80;\r
399 }\r
400 \r
b659408b
ZL
401 //\r
402 // All boot informations are valid here.\r
403 //\r
404 AsciiPrint ("\n URI: %a", Private->BootFileUri);\r
405 //\r
406 // Update the device path to include the IP and boot URI information.\r
407 //\r
408 Status = HttpBootUpdateDevicePath (Private);\r
409\r
410Error:\r
411 \r
412 if (HostName != NULL) {\r
413 FreePool (HostName);\r
414 }\r
415 \r
416 return Status;\r
417}\r
418\r
419\r
d933e70a
JW
420/**\r
421 Discover all the boot information for boot file.\r
422\r
423 @param[in, out] Private The pointer to the driver's private data.\r
424\r
425 @retval EFI_SUCCESS Successfully obtained all the boot information .\r
426 @retval Others Failed to retrieve the boot information.\r
427\r
428**/\r
429EFI_STATUS\r
430HttpBootDiscoverBootInfo (\r
431 IN OUT HTTP_BOOT_PRIVATE_DATA *Private\r
432 )\r
433{\r
434 EFI_STATUS Status;\r
435 \r
436 //\r
437 // Start D.O.R.A/S.A.R.R exchange to acquire station ip address and\r
438 // other Http boot information.\r
439 //\r
440 Status = HttpBootDhcp (Private);\r
441 if (EFI_ERROR (Status)) {\r
442 return Status;\r
443 }\r
444\r
445 if (!Private->UsingIpv6) {\r
b659408b 446 Status = HttpBootDhcp4ExtractUriInfo (Private);\r
d933e70a 447 } else {\r
b659408b 448 Status = HttpBootDhcp6ExtractUriInfo (Private);\r
d933e70a
JW
449 }\r
450\r
451 return Status;\r
452}\r
453\r
454/**\r
455 Create a HttpIo instance for the file download.\r
456\r
457 @param[in] Private The pointer to the driver's private data.\r
458\r
459 @retval EFI_SUCCESS Successfully created.\r
460 @retval Others Failed to create HttpIo.\r
461\r
462**/\r
463EFI_STATUS\r
464HttpBootCreateHttpIo (\r
465 IN HTTP_BOOT_PRIVATE_DATA *Private\r
466 )\r
467{\r
468 HTTP_IO_CONFIG_DATA ConfigData;\r
469 EFI_STATUS Status;\r
75372581 470 EFI_HANDLE ImageHandle;\r
d933e70a
JW
471\r
472 ASSERT (Private != NULL);\r
473\r
474 ZeroMem (&ConfigData, sizeof (HTTP_IO_CONFIG_DATA));\r
475 if (!Private->UsingIpv6) {\r
b659408b 476 ConfigData.Config4.HttpVersion = HttpVersion11;\r
d933e70a
JW
477 ConfigData.Config4.RequestTimeOut = HTTP_BOOT_REQUEST_TIMEOUT;\r
478 IP4_COPY_ADDRESS (&ConfigData.Config4.LocalIp, &Private->StationIp.v4);\r
479 IP4_COPY_ADDRESS (&ConfigData.Config4.SubnetMask, &Private->SubnetMask.v4);\r
75372581 480 ImageHandle = Private->Ip4Nic->ImageHandle;\r
d933e70a 481 } else {\r
b659408b
ZL
482 ConfigData.Config6.HttpVersion = HttpVersion11;\r
483 ConfigData.Config6.RequestTimeOut = HTTP_BOOT_REQUEST_TIMEOUT;\r
484 IP6_COPY_ADDRESS (&ConfigData.Config6.LocalIp, &Private->StationIp.v6);\r
75372581 485 ImageHandle = Private->Ip6Nic->ImageHandle;\r
d933e70a
JW
486 }\r
487\r
488 Status = HttpIoCreateIo (\r
75372581 489 ImageHandle,\r
d933e70a
JW
490 Private->Controller,\r
491 Private->UsingIpv6 ? IP_VERSION_6 : IP_VERSION_4,\r
492 &ConfigData,\r
493 &Private->HttpIo\r
494 );\r
495 if (EFI_ERROR (Status)) {\r
496 return Status;\r
497 }\r
498\r
499 Private->HttpCreated = TRUE;\r
500 return EFI_SUCCESS;\r
501}\r
502\r
d933e70a
JW
503/**\r
504 Release all the resource of a cache item.\r
505\r
506 @param[in] Cache The pointer to the cache item.\r
507\r
508**/\r
509VOID\r
510HttpBootFreeCache (\r
511 IN HTTP_BOOT_CACHE_CONTENT *Cache\r
512 )\r
513{\r
514 UINTN Index;\r
515 LIST_ENTRY *Entry;\r
516 LIST_ENTRY *NextEntry;\r
517 HTTP_BOOT_ENTITY_DATA *EntityData;\r
518\r
519 if (Cache != NULL) {\r
520 //\r
521 // Free the request data\r
522 //\r
523 if (Cache->RequestData != NULL) {\r
524 if (Cache->RequestData->Url != NULL) {\r
525 FreePool (Cache->RequestData->Url);\r
526 }\r
527 FreePool (Cache->RequestData);\r
528 }\r
529\r
530 //\r
531 // Free the response header\r
532 //\r
533 if (Cache->ResponseData != NULL) {\r
534 if (Cache->ResponseData->Headers != NULL) {\r
535 for (Index = 0; Index < Cache->ResponseData->HeaderCount; Index++) {\r
536 FreePool (Cache->ResponseData->Headers[Index].FieldName);\r
537 FreePool (Cache->ResponseData->Headers[Index].FieldValue);\r
538 }\r
539 FreePool (Cache->ResponseData->Headers);\r
540 }\r
541 }\r
542\r
543 //\r
544 // Free the response body\r
545 //\r
546 NET_LIST_FOR_EACH_SAFE (Entry, NextEntry, &Cache->EntityDataList) {\r
547 EntityData = NET_LIST_USER_STRUCT (Entry, HTTP_BOOT_ENTITY_DATA, Link);\r
548 if (EntityData->Block != NULL) {\r
549 FreePool (EntityData->Block);\r
550 }\r
551 RemoveEntryList (&EntityData->Link);\r
552 FreePool (EntityData);\r
553 }\r
554\r
555 FreePool (Cache);\r
556 }\r
557}\r
558\r
559/**\r
560 Clean up all cached data.\r
561\r
562 @param[in] Private The pointer to the driver's private data.\r
563\r
564**/\r
565VOID\r
566HttpBootFreeCacheList (\r
567 IN HTTP_BOOT_PRIVATE_DATA *Private\r
568 )\r
569{\r
570 LIST_ENTRY *Entry;\r
571 LIST_ENTRY *NextEntry;\r
572 HTTP_BOOT_CACHE_CONTENT *Cache;\r
573 \r
574 NET_LIST_FOR_EACH_SAFE (Entry, NextEntry, &Private->CacheList) {\r
575 Cache = NET_LIST_USER_STRUCT (Entry, HTTP_BOOT_CACHE_CONTENT, Link);\r
576 RemoveEntryList (&Cache->Link);\r
577 HttpBootFreeCache (Cache);\r
578 }\r
579}\r
580\r
7552c24e
FS
581/**\r
582 Get the file content from cached data.\r
583\r
584 @param[in] Private The pointer to the driver's private data.\r
585 @param[in] Uri Uri of the file to be retrieved from cache.\r
586 @param[in, out] BufferSize On input the size of Buffer in bytes. On output with a return\r
587 code of EFI_SUCCESS, the amount of data transferred to\r
588 Buffer. On output with a return code of EFI_BUFFER_TOO_SMALL,\r
589 the size of Buffer required to retrieve the requested file.\r
590 @param[out] Buffer The memory buffer to transfer the file to. IF Buffer is NULL,\r
591 then the size of the requested file is returned in\r
592 BufferSize.\r
587d204c 593 @param[out] ImageType The image type of the downloaded file.\r
7552c24e
FS
594\r
595 @retval EFI_SUCCESS Successfully created.\r
596 @retval Others Failed to create HttpIo.\r
597\r
598**/\r
599EFI_STATUS\r
600HttpBootGetFileFromCache (\r
601 IN HTTP_BOOT_PRIVATE_DATA *Private,\r
602 IN CHAR16 *Uri,\r
603 IN OUT UINTN *BufferSize,\r
587d204c
FS
604 OUT UINT8 *Buffer,\r
605 OUT HTTP_BOOT_IMAGE_TYPE *ImageType\r
7552c24e
FS
606 )\r
607{\r
608 LIST_ENTRY *Entry;\r
609 LIST_ENTRY *Entry2;\r
610 HTTP_BOOT_CACHE_CONTENT *Cache;\r
611 HTTP_BOOT_ENTITY_DATA *EntityData;\r
612 UINTN CopyedSize;\r
613 \r
587d204c 614 if (Uri == NULL || BufferSize == 0 || Buffer == NULL || ImageType == NULL) {\r
7552c24e
FS
615 return EFI_INVALID_PARAMETER;\r
616 }\r
617\r
7552c24e
FS
618 NET_LIST_FOR_EACH (Entry, &Private->CacheList) {\r
619 Cache = NET_LIST_USER_STRUCT (Entry, HTTP_BOOT_CACHE_CONTENT, Link);\r
620 //\r
621 // Compare the URI to see whether we already have a cache for this file.\r
622 //\r
623 if ((Cache->RequestData != NULL) &&\r
624 (Cache->RequestData->Url != NULL) &&\r
625 (StrCmp (Uri, Cache->RequestData->Url) == 0)) \r
626 {\r
627 //\r
587d204c
FS
628 // Hit in cache, record image type.\r
629 //\r
630 *ImageType = Cache->ImageType;\r
631\r
632 //\r
633 // Check buffer size.\r
7552c24e
FS
634 //\r
635 if (*BufferSize < Cache->EntityLength) {\r
636 *BufferSize = Cache->EntityLength;\r
637 return EFI_BUFFER_TOO_SMALL;\r
638 }\r
639\r
640 //\r
641 // Fill data to buffer.\r
642 //\r
643 CopyedSize = 0;\r
644 NET_LIST_FOR_EACH (Entry2, &Cache->EntityDataList) {\r
645 EntityData = NET_LIST_USER_STRUCT (Entry2, HTTP_BOOT_ENTITY_DATA, Link);\r
646 if (*BufferSize > CopyedSize) {\r
647 CopyMem (\r
648 Buffer + CopyedSize,\r
649 EntityData->DataStart,\r
650 MIN (EntityData->DataLength, *BufferSize - CopyedSize)\r
651 );\r
652 CopyedSize += MIN (EntityData->DataLength, *BufferSize - CopyedSize);\r
653 }\r
654 }\r
655 *BufferSize = CopyedSize;\r
7552c24e
FS
656 return EFI_SUCCESS;\r
657 }\r
658 }\r
659\r
660 return EFI_NOT_FOUND;\r
661}\r
662\r
d933e70a
JW
663/**\r
664 A callback function to intercept events during message parser.\r
665\r
666 This function will be invoked during HttpParseMessageBody() with various events type. An error\r
667 return status of the callback function will cause the HttpParseMessageBody() aborted.\r
668\r
669 @param[in] EventType Event type of this callback call.\r
670 @param[in] Data A pointer to data buffer.\r
671 @param[in] Length Length in bytes of the Data.\r
672 @param[in] Context Callback context set by HttpInitMsgParser().\r
673\r
674 @retval EFI_SUCCESS Continue to parser the message body.\r
675 @retval Others Abort the parse.\r
676 \r
677**/\r
678EFI_STATUS\r
679EFIAPI\r
680HttpBootGetBootFileCallback (\r
681 IN HTTP_BODY_PARSE_EVENT EventType,\r
682 IN CHAR8 *Data,\r
683 IN UINTN Length,\r
684 IN VOID *Context\r
685 )\r
686{\r
687 HTTP_BOOT_CALLBACK_DATA *CallbackData;\r
688 HTTP_BOOT_ENTITY_DATA *NewEntityData;\r
689\r
690 //\r
691 // We only care about the entity data.\r
692 //\r
693 if (EventType != BodyParseEventOnData) {\r
694 return EFI_SUCCESS;\r
695 }\r
696\r
697 CallbackData = (HTTP_BOOT_CALLBACK_DATA *) Context;\r
d933e70a
JW
698 //\r
699 // Copy data if caller has provided a buffer.\r
700 //\r
701 if (CallbackData->BufferSize > CallbackData->CopyedSize) {\r
702 CopyMem (\r
703 CallbackData->Buffer + CallbackData->CopyedSize,\r
704 Data,\r
705 MIN (Length, CallbackData->BufferSize - CallbackData->CopyedSize)\r
706 );\r
707 CallbackData->CopyedSize += MIN (Length, CallbackData->BufferSize - CallbackData->CopyedSize);\r
708 }\r
709\r
7fd71047
FS
710 //\r
711 // The caller doesn't provide a buffer, save the block into cache list.\r
712 //\r
713 if (CallbackData->Cache != NULL) {\r
714 NewEntityData = AllocatePool (sizeof (HTTP_BOOT_ENTITY_DATA));\r
715 if (NewEntityData == NULL) {\r
716 return EFI_OUT_OF_RESOURCES;\r
717 }\r
718 if (CallbackData->NewBlock) {\r
719 NewEntityData->Block = CallbackData->Block;\r
720 CallbackData->Block = NULL;\r
721 }\r
722 NewEntityData->DataLength = Length;\r
723 NewEntityData->DataStart = (UINT8*) Data;\r
724 InsertTailList (&CallbackData->Cache->EntityDataList, &NewEntityData->Link);\r
725 }\r
d933e70a
JW
726 return EFI_SUCCESS;\r
727}\r
728\r
729/**\r
730 This function download the boot file by using UEFI HTTP protocol.\r
731 \r
732 @param[in] Private The pointer to the driver's private data.\r
733 @param[in] HeaderOnly Only request the response header, it could save a lot of time if\r
734 the caller only want to know the size of the requested file.\r
735 @param[in, out] BufferSize On input the size of Buffer in bytes. On output with a return\r
736 code of EFI_SUCCESS, the amount of data transferred to\r
737 Buffer. On output with a return code of EFI_BUFFER_TOO_SMALL,\r
738 the size of Buffer required to retrieve the requested file.\r
739 @param[out] Buffer The memory buffer to transfer the file to. IF Buffer is NULL,\r
740 then the size of the requested file is returned in\r
741 BufferSize.\r
587d204c 742 @param[out] ImageType The image type of the downloaded file.\r
d933e70a
JW
743\r
744 @retval EFI_SUCCESS The file was loaded.\r
745 @retval EFI_INVALID_PARAMETER BufferSize is NULL or Buffer Size is not NULL but Buffer is NULL.\r
746 @retval EFI_OUT_OF_RESOURCES Could not allocate needed resources\r
747 @retval EFI_BUFFER_TOO_SMALL The BufferSize is too small to read the current directory entry.\r
748 BufferSize has been updated with the size needed to complete\r
749 the request.\r
750 @retval Others Unexpected error happened.\r
751\r
752**/\r
753EFI_STATUS\r
754HttpBootGetBootFile (\r
755 IN HTTP_BOOT_PRIVATE_DATA *Private,\r
756 IN BOOLEAN HeaderOnly,\r
757 IN OUT UINTN *BufferSize,\r
587d204c
FS
758 OUT UINT8 *Buffer,\r
759 OUT HTTP_BOOT_IMAGE_TYPE *ImageType\r
d933e70a
JW
760 )\r
761{\r
762 EFI_STATUS Status;\r
072289f4 763 EFI_HTTP_STATUS_CODE StatusCode;\r
d933e70a
JW
764 CHAR8 *HostName;\r
765 EFI_HTTP_REQUEST_DATA *RequestData;\r
ef422fc5
PA
766 HTTP_IO_RESPONSE_DATA *ResponseData;\r
767 HTTP_IO_RESPONSE_DATA ResponseBody;\r
d933e70a
JW
768 HTTP_IO *HttpIo;\r
769 HTTP_IO_HEADER *HttpIoHeader;\r
770 VOID *Parser;\r
771 HTTP_BOOT_CALLBACK_DATA Context;\r
772 UINTN ContentLength;\r
773 HTTP_BOOT_CACHE_CONTENT *Cache;\r
774 UINT8 *Block;\r
b9679cd7 775 UINTN UrlSize;\r
d933e70a 776 CHAR16 *Url;\r
7552c24e
FS
777 BOOLEAN IdentityMode;\r
778 UINTN ReceivedSize;\r
d933e70a
JW
779 \r
780 ASSERT (Private != NULL);\r
781 ASSERT (Private->HttpCreated);\r
782\r
587d204c 783 if (BufferSize == NULL || ImageType == NULL) {\r
d933e70a
JW
784 return EFI_INVALID_PARAMETER;\r
785 }\r
786\r
787 if (*BufferSize != 0 && Buffer == NULL) {\r
788 return EFI_INVALID_PARAMETER;\r
789 }\r
790\r
791 //\r
792 // First, check whether we already cached the requested Uri.\r
793 //\r
b9679cd7
SZ
794 UrlSize = AsciiStrSize (Private->BootFileUri);\r
795 Url = AllocatePool (UrlSize * sizeof (CHAR16));\r
d933e70a
JW
796 if (Url == NULL) {\r
797 return EFI_OUT_OF_RESOURCES;\r
798 }\r
b9679cd7 799 AsciiStrToUnicodeStrS (Private->BootFileUri, Url, UrlSize);\r
d933e70a 800 if (!HeaderOnly) {\r
587d204c 801 Status = HttpBootGetFileFromCache (Private, Url, BufferSize, Buffer, ImageType);\r
d933e70a
JW
802 if (Status != EFI_NOT_FOUND) {\r
803 FreePool (Url);\r
804 return Status;\r
805 }\r
806 }\r
807\r
808 //\r
809 // Not found in cache, try to download it through HTTP.\r
810 //\r
811\r
812 //\r
7fd71047 813 // 1. Create a temp cache item for the requested URI if caller doesn't provide buffer.\r
d933e70a
JW
814 //\r
815 Cache = NULL;\r
7fd71047 816 if ((!HeaderOnly) && (*BufferSize == 0)) {\r
d933e70a
JW
817 Cache = AllocateZeroPool (sizeof (HTTP_BOOT_CACHE_CONTENT));\r
818 if (Cache == NULL) {\r
819 Status = EFI_OUT_OF_RESOURCES;\r
820 goto ERROR_1;\r
821 }\r
587d204c 822 Cache->ImageType = ImageTypeMax;\r
d933e70a
JW
823 InitializeListHead (&Cache->EntityDataList);\r
824 }\r
825\r
826 //\r
827 // 2. Send HTTP request message.\r
828 //\r
829\r
830 //\r
831 // 2.1 Build HTTP header for the request, 3 header is needed to download a boot file:\r
832 // Host\r
833 // Accept\r
834 // User-Agent\r
835 //\r
836 HttpIoHeader = HttpBootCreateHeader (3);\r
837 if (HttpIoHeader == NULL) {\r
838 Status = EFI_OUT_OF_RESOURCES;\r
839 goto ERROR_2;\r
840 }\r
841\r
842 //\r
843 // Add HTTP header field 1: Host\r
844 //\r
845 HostName = NULL;\r
846 Status = HttpUrlGetHostName (\r
847 Private->BootFileUri,\r
848 Private->BootFileUriParser,\r
849 &HostName\r
850 );\r
851 if (EFI_ERROR (Status)) {\r
852 goto ERROR_3;\r
853 }\r
854 Status = HttpBootSetHeader (\r
855 HttpIoHeader,\r
90f658c4 856 HTTP_HEADER_HOST,\r
d933e70a
JW
857 HostName\r
858 );\r
859 FreePool (HostName);\r
860 if (EFI_ERROR (Status)) {\r
861 goto ERROR_3;\r
862 }\r
863\r
864 //\r
865 // Add HTTP header field 2: Accept\r
866 //\r
867 Status = HttpBootSetHeader (\r
868 HttpIoHeader,\r
90f658c4 869 HTTP_HEADER_ACCEPT,\r
d933e70a
JW
870 "*/*"\r
871 );\r
872 if (EFI_ERROR (Status)) {\r
873 goto ERROR_3;\r
874 }\r
875\r
876 //\r
877 // Add HTTP header field 3: User-Agent\r
878 //\r
879 Status = HttpBootSetHeader (\r
880 HttpIoHeader,\r
90f658c4 881 HTTP_HEADER_USER_AGENT,\r
d933e70a
JW
882 HTTP_USER_AGENT_EFI_HTTP_BOOT\r
883 );\r
884 if (EFI_ERROR (Status)) {\r
885 goto ERROR_3;\r
886 }\r
887\r
888 //\r
889 // 2.2 Build the rest of HTTP request info.\r
890 //\r
891 RequestData = AllocatePool (sizeof (EFI_HTTP_REQUEST_DATA));\r
892 if (RequestData == NULL) {\r
893 Status = EFI_OUT_OF_RESOURCES;\r
894 goto ERROR_3;\r
895 }\r
896 RequestData->Method = HeaderOnly ? HttpMethodHead : HttpMethodGet;\r
897 RequestData->Url = Url;\r
d933e70a
JW
898\r
899 //\r
900 // 2.3 Record the request info in a temp cache item.\r
901 //\r
7fd71047 902 if (Cache != NULL) {\r
d933e70a
JW
903 Cache->RequestData = RequestData;\r
904 }\r
905\r
906 //\r
907 // 2.4 Send out the request to HTTP server.\r
908 //\r
909 HttpIo = &Private->HttpIo;\r
910 Status = HttpIoSendRequest (\r
911 HttpIo,\r
912 RequestData,\r
913 HttpIoHeader->HeaderCount,\r
914 HttpIoHeader->Headers,\r
915 0,\r
916 NULL\r
917 );\r
918 if (EFI_ERROR (Status)) {\r
919 goto ERROR_4;\r
920 }\r
921\r
922 //\r
923 // 3. Receive HTTP response message.\r
924 //\r
925\r
926 //\r
927 // 3.1 First step, use zero BodyLength to only receive the response headers.\r
928 //\r
ef422fc5 929 ResponseData = AllocateZeroPool (sizeof(HTTP_IO_RESPONSE_DATA));\r
d933e70a
JW
930 if (ResponseData == NULL) {\r
931 Status = EFI_OUT_OF_RESOURCES;\r
932 goto ERROR_4;\r
933 }\r
934 Status = HttpIoRecvResponse (\r
935 &Private->HttpIo,\r
936 TRUE,\r
937 ResponseData\r
938 );\r
072289f4
ZL
939 if (EFI_ERROR (Status) || EFI_ERROR (ResponseData->Status)) {\r
940 if (EFI_ERROR (ResponseData->Status)) {\r
941 StatusCode = HttpIo->RspToken.Message->Data.Response->StatusCode;\r
942 HttpBootPrintErrorMessage (StatusCode);\r
943 Status = ResponseData->Status;\r
944 }\r
d933e70a
JW
945 goto ERROR_5;\r
946 }\r
947\r
587d204c
FS
948 //\r
949 // Check the image type according to server's response.\r
950 //\r
951 Status = HttpBootCheckImageType (\r
952 Private->BootFileUri,\r
953 Private->BootFileUriParser,\r
954 ResponseData->HeaderCount,\r
955 ResponseData->Headers,\r
956 ImageType\r
957 );\r
958 if (EFI_ERROR (Status)) {\r
959 goto ERROR_5;\r
960 }\r
961\r
d933e70a
JW
962 //\r
963 // 3.2 Cache the response header.\r
964 //\r
7fd71047 965 if (Cache != NULL) {\r
d933e70a 966 Cache->ResponseData = ResponseData;\r
587d204c 967 Cache->ImageType = *ImageType;\r
d933e70a
JW
968 }\r
969 \r
970 //\r
971 // 3.3 Init a message-body parser from the header information.\r
972 //\r
973 Parser = NULL;\r
974 Context.NewBlock = FALSE;\r
975 Context.Block = NULL;\r
976 Context.CopyedSize = 0;\r
977 Context.Buffer = Buffer;\r
978 Context.BufferSize = *BufferSize;\r
979 Context.Cache = Cache;\r
980 Status = HttpInitMsgParser (\r
981 HeaderOnly? HttpMethodHead : HttpMethodGet,\r
982 ResponseData->Response.StatusCode,\r
983 ResponseData->HeaderCount,\r
984 ResponseData->Headers,\r
985 HttpBootGetBootFileCallback,\r
986 (VOID*) &Context,\r
987 &Parser\r
988 );\r
989 if (EFI_ERROR (Status)) {\r
990 goto ERROR_6;\r
991 }\r
992\r
993 //\r
994 // 3.4 Continue to receive and parse message-body if needed.\r
995 //\r
7fd71047 996 Block = NULL;\r
d933e70a 997 if (!HeaderOnly) {\r
7552c24e
FS
998 //\r
999 // 3.4.1, check whether we are in identity transfer-coding.\r
1000 //\r
1001 ContentLength = 0;\r
1002 Status = HttpGetEntityLength (Parser, &ContentLength);\r
1003 if (!EFI_ERROR (Status)) {\r
1004 IdentityMode = TRUE;\r
1005 } else {\r
1006 IdentityMode = FALSE;\r
1007 }\r
1008\r
1009 //\r
1010 // 3.4.2, start the message-body download, the identity and chunked transfer-coding\r
1011 // is handled in different path here.\r
1012 //\r
ef422fc5 1013 ZeroMem (&ResponseBody, sizeof (HTTP_IO_RESPONSE_DATA));\r
7552c24e 1014 if (IdentityMode) {\r
d933e70a 1015 //\r
7552c24e
FS
1016 // In identity transfer-coding there is no need to parse the message body,\r
1017 // just download the message body to the user provided buffer directly.\r
d933e70a 1018 //\r
7552c24e
FS
1019 ReceivedSize = 0;\r
1020 while (ReceivedSize < ContentLength) {\r
1021 ResponseBody.Body = (CHAR8*) Buffer + ReceivedSize;\r
1022 ResponseBody.BodyLength = *BufferSize - ReceivedSize;\r
1023 Status = HttpIoRecvResponse (\r
1024 &Private->HttpIo,\r
1025 FALSE,\r
1026 &ResponseBody\r
1027 );\r
7570696c
JW
1028 if (EFI_ERROR (Status) || EFI_ERROR (ResponseBody.Status)) {\r
1029 if (EFI_ERROR (ResponseBody.Status)) {\r
1030 Status = ResponseBody.Status;\r
1031 }\r
7fd71047
FS
1032 goto ERROR_6;\r
1033 }\r
7552c24e 1034 ReceivedSize += ResponseBody.BodyLength;\r
d933e70a 1035 }\r
7552c24e 1036 } else {\r
d933e70a 1037 //\r
7552c24e
FS
1038 // In "chunked" transfer-coding mode, so we need to parse the received\r
1039 // data to get the real entity content.\r
d933e70a 1040 //\r
7552c24e
FS
1041 Block = NULL;\r
1042 while (!HttpIsMessageComplete (Parser)) {\r
1043 //\r
1044 // Allocate a buffer in Block to hold the message-body.\r
1045 // If caller provides a buffer, this Block will be reused in every HttpIoRecvResponse().\r
1046 // Otherwise a buffer, the buffer in Block will be cached and we should allocate a new before\r
1047 // every HttpIoRecvResponse().\r
1048 //\r
1049 if (Block == NULL || Context.BufferSize == 0) {\r
1050 Block = AllocatePool (HTTP_BOOT_BLOCK_SIZE);\r
1051 if (Block == NULL) {\r
1052 Status = EFI_OUT_OF_RESOURCES;\r
1053 goto ERROR_6;\r
1054 }\r
1055 Context.NewBlock = TRUE;\r
1056 Context.Block = Block;\r
1057 } else {\r
1058 Context.NewBlock = FALSE;\r
1059 }\r
1060\r
1061 ResponseBody.Body = (CHAR8*) Block;\r
1062 ResponseBody.BodyLength = HTTP_BOOT_BLOCK_SIZE;\r
1063 Status = HttpIoRecvResponse (\r
1064 &Private->HttpIo,\r
1065 FALSE,\r
1066 &ResponseBody\r
1067 );\r
7570696c
JW
1068 if (EFI_ERROR (Status) || EFI_ERROR (ResponseBody.Status)) {\r
1069 if (EFI_ERROR (ResponseBody.Status)) {\r
1070 Status = ResponseBody.Status;\r
1071 }\r
7552c24e
FS
1072 goto ERROR_6;\r
1073 }\r
1074\r
1075 //\r
1076 // Parse the new received block of the message-body, the block will be saved in cache.\r
1077 //\r
1078 Status = HttpParseMessageBody (\r
1079 Parser,\r
1080 ResponseBody.BodyLength,\r
1081 ResponseBody.Body\r
1082 );\r
1083 if (EFI_ERROR (Status)) {\r
1084 goto ERROR_6;\r
1085 }\r
d933e70a
JW
1086 }\r
1087 }\r
1088 }\r
7552c24e 1089\r
d933e70a 1090 //\r
7552c24e 1091 // 3.5 Message-body receive & parse is completed, we should be able to get the file size now.\r
d933e70a
JW
1092 //\r
1093 Status = HttpGetEntityLength (Parser, &ContentLength);\r
1094 if (EFI_ERROR (Status)) {\r
1095 goto ERROR_6;\r
1096 }\r
1097\r
1098 if (*BufferSize < ContentLength) {\r
1099 Status = EFI_BUFFER_TOO_SMALL;\r
a93786ae
GL
1100 } else {\r
1101 Status = EFI_SUCCESS;\r
d933e70a
JW
1102 }\r
1103 *BufferSize = ContentLength;\r
1104\r
1105 //\r
1106 // 4. Save the cache item to driver's cache list and return.\r
1107 //\r
7fd71047 1108 if (Cache != NULL) {\r
d933e70a
JW
1109 Cache->EntityLength = ContentLength;\r
1110 InsertTailList (&Private->CacheList, &Cache->Link);\r
1111 }\r
1112\r
1113 if (Parser != NULL) {\r
1114 HttpFreeMsgParser (Parser);\r
1115 }\r
1116\r
a93786ae 1117 return Status;\r
d933e70a
JW
1118 \r
1119ERROR_6:\r
1120 if (Parser != NULL) {\r
1121 HttpFreeMsgParser (Parser);\r
1122 }\r
1123 if (Context.Block != NULL) {\r
1124 FreePool (Context.Block);\r
1125 }\r
1126 HttpBootFreeCache (Cache);\r
1127 \r
1128ERROR_5:\r
1129 if (ResponseData != NULL) {\r
1130 FreePool (ResponseData);\r
1131 }\r
1132ERROR_4:\r
1133 if (RequestData != NULL) {\r
1134 FreePool (RequestData);\r
1135 }\r
1136ERROR_3:\r
1137 HttpBootFreeHeader (HttpIoHeader);\r
1138ERROR_2:\r
1139 if (Cache != NULL) {\r
1140 FreePool (Cache);\r
1141 }\r
1142ERROR_1:\r
1143 if (Url != NULL) {\r
1144 FreePool (Url);\r
1145 }\r
1146\r
1147 return Status;\r
1148}\r
fa848a40 1149\r