29 if (NicHandle ==
NULL) {
31 if (NicHandle ==
NULL) {
56 if (NicHandle ==
NULL) {
58 if (NicHandle ==
NULL) {
83 for ( ; Length > 0; Length--) {
84 Remainder = Number % 10;
86 Buffer[Length - 1] = (UINT8)(
'0' + Remainder);
103 for (Index = 0; Index < 4; Index++) {
124 for (Index = 0; Index < 16; Index++) {
125 if (Ip->Addr[Index] != 0) {
134 if (((Ip->Addr[Index] & 0xf0) == 0) && (Ip->Addr[Index - 1] != 0)) {
158 switch (StatusCode) {
159 case HTTP_STATUS_300_MULTIPLE_CHOICES:
160 AsciiPrint (
"\n Redirection: 300 Multiple Choices");
163 case HTTP_STATUS_301_MOVED_PERMANENTLY:
164 AsciiPrint (
"\n Redirection: 301 Moved Permanently");
167 case HTTP_STATUS_302_FOUND:
171 case HTTP_STATUS_303_SEE_OTHER:
175 case HTTP_STATUS_304_NOT_MODIFIED:
176 AsciiPrint (
"\n Redirection: 304 Not Modified");
179 case HTTP_STATUS_305_USE_PROXY:
183 case HTTP_STATUS_307_TEMPORARY_REDIRECT:
184 AsciiPrint (
"\n Redirection: 307 Temporary Redirect");
187 case HTTP_STATUS_308_PERMANENT_REDIRECT:
188 AsciiPrint (
"\n Redirection: 308 Permanent Redirect");
191 case HTTP_STATUS_400_BAD_REQUEST:
192 AsciiPrint (
"\n Client Error: 400 Bad Request");
195 case HTTP_STATUS_401_UNAUTHORIZED:
196 AsciiPrint (
"\n Client Error: 401 Unauthorized");
199 case HTTP_STATUS_402_PAYMENT_REQUIRED:
200 AsciiPrint (
"\n Client Error: 402 Payment Required");
203 case HTTP_STATUS_403_FORBIDDEN:
204 AsciiPrint (
"\n Client Error: 403 Forbidden");
207 case HTTP_STATUS_404_NOT_FOUND:
208 AsciiPrint (
"\n Client Error: 404 Not Found");
211 case HTTP_STATUS_405_METHOD_NOT_ALLOWED:
212 AsciiPrint (
"\n Client Error: 405 Method Not Allowed");
215 case HTTP_STATUS_406_NOT_ACCEPTABLE:
216 AsciiPrint (
"\n Client Error: 406 Not Acceptable");
219 case HTTP_STATUS_407_PROXY_AUTHENTICATION_REQUIRED:
220 AsciiPrint (
"\n Client Error: 407 Proxy Authentication Required");
223 case HTTP_STATUS_408_REQUEST_TIME_OUT:
224 AsciiPrint (
"\n Client Error: 408 Request Timeout");
227 case HTTP_STATUS_409_CONFLICT:
231 case HTTP_STATUS_410_GONE:
235 case HTTP_STATUS_411_LENGTH_REQUIRED:
236 AsciiPrint (
"\n Client Error: 411 Length Required");
239 case HTTP_STATUS_412_PRECONDITION_FAILED:
240 AsciiPrint (
"\n Client Error: 412 Precondition Failed");
243 case HTTP_STATUS_413_REQUEST_ENTITY_TOO_LARGE:
244 AsciiPrint (
"\n Client Error: 413 Request Entity Too Large");
247 case HTTP_STATUS_414_REQUEST_URI_TOO_LARGE:
248 AsciiPrint (
"\n Client Error: 414 Request URI Too Long");
251 case HTTP_STATUS_415_UNSUPPORTED_MEDIA_TYPE:
252 AsciiPrint (
"\n Client Error: 415 Unsupported Media Type");
255 case HTTP_STATUS_416_REQUESTED_RANGE_NOT_SATISFIED:
256 AsciiPrint (
"\n Client Error: 416 Requested Range Not Satisfiable");
259 case HTTP_STATUS_417_EXPECTATION_FAILED:
260 AsciiPrint (
"\n Client Error: 417 Expectation Failed");
263 case HTTP_STATUS_500_INTERNAL_SERVER_ERROR:
264 AsciiPrint (
"\n Server Error: 500 Internal Server Error");
267 case HTTP_STATUS_501_NOT_IMPLEMENTED:
268 AsciiPrint (
"\n Server Error: 501 Not Implemented");
271 case HTTP_STATUS_502_BAD_GATEWAY:
272 AsciiPrint (
"\n Server Error: 502 Bad Gateway");
275 case HTTP_STATUS_503_SERVICE_UNAVAILABLE:
276 AsciiPrint (
"\n Server Error: 503 Service Unavailable");
279 case HTTP_STATUS_504_GATEWAY_TIME_OUT:
280 AsciiPrint (
"\n Server Error: 504 Gateway Timeout");
283 case HTTP_STATUS_505_HTTP_VERSION_NOT_SUPPORTED:
284 AsciiPrint (
"\n Server Error: 505 HTTP Version Not Supported");
305 *((BOOLEAN *)Context) =
TRUE;
333 UINTN DnsServerListCount;
337 DnsServerList =
NULL;
338 DnsServerListCount = 0;
346 Status =
gBS->HandleProtocol (Private->Controller, &gEfiIp6ConfigProtocolGuid, (VOID **)&Ip6Config);
347 if (!EFI_ERROR (Status)) {
353 if (Status == EFI_BUFFER_TOO_SMALL) {
355 if (DnsServerList ==
NULL) {
356 return EFI_OUT_OF_RESOURCES;
360 if (EFI_ERROR (Status)) {
362 DnsServerList =
NULL;
374 Private->Ip6Nic->ImageHandle,
375 &gEfiDns6ServiceBindingProtocolGuid,
378 if (EFI_ERROR (Status)) {
382 Status =
gBS->OpenProtocol (
384 &gEfiDns6ProtocolGuid,
386 Private->Ip6Nic->ImageHandle,
388 EFI_OPEN_PROTOCOL_BY_DRIVER
390 if (EFI_ERROR (Status)) {
401 Dns6ConfigData.
Protocol = EFI_IP_PROTO_UDP;
402 IP6_COPY_ADDRESS (&Dns6ConfigData.
StationIp, &Private->StationIp.v6);
403 Status = Dns6->Configure (
407 if (EFI_ERROR (Status)) {
411 Token.
Status = EFI_NOT_READY;
416 Status =
gBS->CreateEvent (
423 if (EFI_ERROR (Status)) {
430 Status = Dns6->HostNameToIp (Dns6, HostName, &Token);
431 if (EFI_ERROR (Status)) {
443 if (!EFI_ERROR (Status)) {
445 Status = EFI_DEVICE_ERROR;
450 Status = EFI_DEVICE_ERROR;
476 Dns6->Configure (Dns6,
NULL);
480 &gEfiDns6ProtocolGuid,
481 Private->Ip6Nic->ImageHandle,
486 if (Dns6Handle !=
NULL) {
489 Private->Ip6Nic->ImageHandle,
490 &gEfiDns6ServiceBindingProtocolGuid,
495 if (DnsServerList !=
NULL) {
525 for (Index = 0; Index <
AsciiStrLen (Uri); Index++) {
526 if (Uri[Index] ==
':') {
530 if ((Uri[Index] >=
'A') && (Uri[Index] <=
'Z')) {
531 Uri[Index] -= (CHAR8)(
'A' -
'a');
539 DEBUG ((DEBUG_ERROR,
"HttpBootCheckUriScheme: Invalid Uri.\n"));
540 return EFI_INVALID_PARAMETER;
547 DEBUG ((DEBUG_ERROR,
"HttpBootCheckUriScheme: HTTP is disabled.\n"));
548 return EFI_ACCESS_DENIED;
569 OUT CHAR8 **UriAddress
577 if (FilePath ==
NULL) {
578 return EFI_INVALID_PARAMETER;
586 TempDevicePath = FilePath;
597 if (UriStrLength == 0) {
606 return EFI_OUT_OF_RESOURCES;
644 OUT HTTP_BOOT_IMAGE_TYPE *ImageType
652 if ((Uri ==
NULL) || (UriParser ==
NULL) || (ImageType ==
NULL)) {
653 return EFI_INVALID_PARAMETER;
656 if ((HeaderCount != 0) && (Headers ==
NULL)) {
657 return EFI_INVALID_PARAMETER;
667 if (Header !=
NULL) {
668 if (
AsciiStriCmp (Header->FieldValue, HTTP_CONTENT_TYPE_APP_EFI) == 0) {
669 *ImageType = ImageTypeEfi;
671 }
else if (
AsciiStriCmp (Header->FieldValue, HTTP_CONTENT_TYPE_APP_ISO) == 0) {
672 *ImageType = ImageTypeVirtualCd;
674 }
else if (
AsciiStriCmp (Header->FieldValue, HTTP_CONTENT_TYPE_APP_IMG) == 0) {
675 *ImageType = ImageTypeVirtualDisk;
691 if (EFI_ERROR (Status)) {
697 *ImageType = ImageTypeEfi;
699 *ImageType = ImageTypeVirtualCd;
701 *ImageType = ImageTypeVirtualDisk;
703 *ImageType = ImageTypeMax;
708 return (*ImageType < ImageTypeMax) ?
EFI_SUCCESS : EFI_NOT_FOUND;
730 IN HTTP_BOOT_IMAGE_TYPE ImageType
738 ASSERT (Private !=
NULL);
739 ASSERT (Buffer !=
NULL);
740 ASSERT (BufferSize != 0);
743 if (EFI_ERROR (Status)) {
744 DEBUG ((DEBUG_ERROR,
"HTTP Boot: Couldn't find the RAM Disk protocol - %r\n", Status));
748 if (ImageType == ImageTypeVirtualCd) {
749 RamDiskType = &gEfiVirtualCdGuid;
750 }
else if (ImageType == ImageTypeVirtualDisk) {
751 RamDiskType = &gEfiVirtualDiskGuid;
753 return EFI_UNSUPPORTED;
756 Status = RamDisk->Register (
760 Private->UsingIpv6 ? Private->Ip6Nic->DevicePath : Private->Ip4Nic->DevicePath,
763 if (EFI_ERROR (Status)) {
764 DEBUG ((DEBUG_ERROR,
"HTTP Boot: Failed to register RAM Disk - %r\n", Status));
783 if ((StatusCode == HTTP_STATUS_301_MOVED_PERMANENTLY) ||
784 (StatusCode == HTTP_STATUS_302_FOUND) ||
785 (StatusCode == HTTP_STATUS_307_TEMPORARY_REDIRECT) ||
786 (StatusCode == HTTP_STATUS_308_PERMANENT_REDIRECT))
INTN EFIAPI AsciiStriCmp(IN CONST CHAR8 *FirstString, IN CONST CHAR8 *SecondString)
UINTN EFIAPI AsciiStrLen(IN CONST CHAR8 *String)
INTN EFIAPI AsciiStrnCmp(IN CONST CHAR8 *FirstString, IN CONST CHAR8 *SecondString, IN UINTN Length)
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
VOID *EFIAPI ZeroMem(OUT VOID *Buffer, IN UINTN Length)
#define MESSAGING_DEVICE_PATH
UINT8 EFIAPI DevicePathType(IN CONST VOID *Node)
UINTN EFIAPI DevicePathNodeLength(IN CONST VOID *Node)
UINT8 EFIAPI DevicePathSubType(IN CONST VOID *Node)
BOOLEAN EFIAPI IsDevicePathEnd(IN CONST VOID *Node)
EFI_DEVICE_PATH_PROTOCOL *EFIAPI NextDevicePathNode(IN CONST VOID *Node)
VOID EFIAPI FreePool(IN VOID *Buffer)
#define HTTP_HEADER_CONTENT_TYPE
EFI_HANDLE HttpBootGetNicByIp4Children(IN EFI_HANDLE ControllerHandle)
EFI_HANDLE HttpBootGetNicByIp6Children(IN EFI_HANDLE ControllerHandle)
VOID HttpBootShowIp6Addr(IN EFI_IPv6_ADDRESS *Ip)
VOID HttpBootUintnToAscDecWithFormat(IN UINTN Number, IN UINT8 *Buffer, IN INTN Length)
VOID EFIAPI HttpBootCommonNotify(IN EFI_EVENT Event, IN VOID *Context)
EFI_STATUS HttpBootCheckUriScheme(IN CHAR8 *Uri)
EFI_STATUS HttpBootRegisterRamDisk(IN HTTP_BOOT_PRIVATE_DATA *Private, IN UINTN BufferSize, IN VOID *Buffer, IN HTTP_BOOT_IMAGE_TYPE ImageType)
VOID HttpBootShowIp4Addr(IN EFI_IPv4_ADDRESS *Ip)
BOOLEAN HttpBootIsHttpRedirectStatusCode(IN EFI_HTTP_STATUS_CODE StatusCode)
EFI_STATUS HttpBootParseFilePath(IN EFI_DEVICE_PATH_PROTOCOL *FilePath, OUT CHAR8 **UriAddress)
EFI_STATUS HttpBootCheckImageType(IN CHAR8 *Uri, IN VOID *UriParser, IN UINTN HeaderCount, IN EFI_HTTP_HEADER *Headers, OUT HTTP_BOOT_IMAGE_TYPE *ImageType)
EFI_STATUS HttpBootDns(IN HTTP_BOOT_PRIVATE_DATA *Private, IN CHAR16 *HostName, OUT EFI_IPv6_ADDRESS *IpAddress)
VOID HttpBootPrintErrorMessage(EFI_HTTP_STATUS_CODE StatusCode)
EFI_HTTP_HEADER *EFIAPI HttpFindHeader(IN UINTN HeaderCount, IN EFI_HTTP_HEADER *Headers, IN CHAR8 *FieldName)
EFI_STATUS EFIAPI HttpUrlGetPath(IN CHAR8 *Url, IN VOID *UrlParser, OUT CHAR8 **Path)
@ Ip6ConfigDataTypeDnsServer
#define DEBUG(Expression)
EFI_STATUS EFIAPI NetLibCreateServiceChild(IN EFI_HANDLE Controller, IN EFI_HANDLE Image, IN EFI_GUID *ServiceBindingGuid, IN OUT EFI_HANDLE *ChildHandle)
EFI_STATUS EFIAPI NetLibDestroyServiceChild(IN EFI_HANDLE Controller, IN EFI_HANDLE Image, IN EFI_GUID *ServiceBindingGuid, IN EFI_HANDLE ChildHandle)
EFI_HANDLE EFIAPI NetLibGetNicHandle(IN EFI_HANDLE Controller, IN EFI_GUID *ProtocolGuid)
#define PcdGetBool(TokenName)
VOID *EFIAPI AllocatePool(IN UINTN AllocationSize)
EFI_GUID gEfiRamDiskProtocolGuid
VOID EFIAPI Exit(IN EFI_STATUS Status)
IPv6_ADDRESS EFI_IPv6_ADDRESS
UINTN EFIAPI AsciiPrint(IN CONST CHAR8 *Format,...)
EFI_IPv6_ADDRESS * IpList
DNS6_HOST_TO_ADDR_DATA * H2AData
union EFI_DNS6_COMPLETION_TOKEN::@574 RspData
EFI_IPv6_ADDRESS * DnsServerList
EFI_IPv6_ADDRESS StationIp