NetworkPkg: Apply uncrustify changes

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3737

Apply uncrustify changes to .c/.h files in the NetworkPkg package

Cc: Andrew Fish <afish@apple.com>
Cc: Leif Lindholm <leif@nuviainc.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Reviewed-by: Maciej Rabeda <maciej.rabeda@linux.intel.com>
This commit is contained in:
Michael Kubacki
2021-12-05 14:54:07 -08:00
committed by mergify[bot]
parent 2f88bd3a12
commit d1050b9dff
294 changed files with 29888 additions and 30440 deletions

View File

@@ -21,15 +21,15 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
**/
EFI_STATUS
HttpBootUpdateDevicePath (
IN HTTP_BOOT_PRIVATE_DATA *Private
IN HTTP_BOOT_PRIVATE_DATA *Private
)
{
EFI_DEV_PATH *Node;
EFI_DEVICE_PATH_PROTOCOL *TmpIpDevicePath;
EFI_DEVICE_PATH_PROTOCOL *TmpDnsDevicePath;
EFI_DEVICE_PATH_PROTOCOL *NewDevicePath;
UINTN Length;
EFI_STATUS Status;
EFI_DEV_PATH *Node;
EFI_DEVICE_PATH_PROTOCOL *TmpIpDevicePath;
EFI_DEVICE_PATH_PROTOCOL *TmpDnsDevicePath;
EFI_DEVICE_PATH_PROTOCOL *NewDevicePath;
UINTN Length;
EFI_STATUS Status;
TmpIpDevicePath = NULL;
TmpDnsDevicePath = NULL;
@@ -42,6 +42,7 @@ HttpBootUpdateDevicePath (
if (Node == NULL) {
return EFI_OUT_OF_RESOURCES;
}
Node->Ipv4.Header.Type = MESSAGING_DEVICE_PATH;
Node->Ipv4.Header.SubType = MSG_IPv4_DP;
SetDevicePathNodeLength (Node, sizeof (IPv4_DEVICE_PATH));
@@ -56,8 +57,9 @@ HttpBootUpdateDevicePath (
if (Node == NULL) {
return EFI_OUT_OF_RESOURCES;
}
Node->Ipv6.Header.Type = MESSAGING_DEVICE_PATH;
Node->Ipv6.Header.SubType = MSG_IPv6_DP;
Node->Ipv6.Header.Type = MESSAGING_DEVICE_PATH;
Node->Ipv6.Header.SubType = MSG_IPv6_DP;
SetDevicePathNodeLength (Node, sizeof (IPv6_DEVICE_PATH));
Node->Ipv6.PrefixLength = IP6_PREFIX_LENGTH;
Node->Ipv6.RemotePort = Private->Port;
@@ -68,7 +70,7 @@ HttpBootUpdateDevicePath (
CopyMem (&Node->Ipv6.GatewayIpAddress, &Private->GatewayIp.v6, sizeof (EFI_IPv6_ADDRESS));
}
TmpIpDevicePath = AppendDevicePathNode (Private->ParentDevicePath, (EFI_DEVICE_PATH_PROTOCOL*) Node);
TmpIpDevicePath = AppendDevicePathNode (Private->ParentDevicePath, (EFI_DEVICE_PATH_PROTOCOL *)Node);
FreePool (Node);
if (TmpIpDevicePath == NULL) {
return EFI_OUT_OF_RESOURCES;
@@ -79,18 +81,19 @@ HttpBootUpdateDevicePath (
//
if (Private->DnsServerIp != NULL) {
Length = sizeof (EFI_DEVICE_PATH_PROTOCOL) + sizeof (Node->Dns.IsIPv6) + Private->DnsServerCount * sizeof (EFI_IP_ADDRESS);
Node = AllocatePool (Length);
Node = AllocatePool (Length);
if (Node == NULL) {
FreePool (TmpIpDevicePath);
return EFI_OUT_OF_RESOURCES;
}
Node->DevPath.Type = MESSAGING_DEVICE_PATH;
Node->DevPath.SubType = MSG_DNS_DP;
SetDevicePathNodeLength (Node, Length);
Node->Dns.IsIPv6 = Private->UsingIpv6 ? 0x01 : 0x00;
CopyMem ((UINT8*) Node + sizeof (EFI_DEVICE_PATH_PROTOCOL) + sizeof (Node->Dns.IsIPv6), Private->DnsServerIp, Private->DnsServerCount * sizeof (EFI_IP_ADDRESS));
CopyMem ((UINT8 *)Node + sizeof (EFI_DEVICE_PATH_PROTOCOL) + sizeof (Node->Dns.IsIPv6), Private->DnsServerIp, Private->DnsServerCount * sizeof (EFI_IP_ADDRESS));
TmpDnsDevicePath = AppendDevicePathNode (TmpIpDevicePath, (EFI_DEVICE_PATH_PROTOCOL*) Node);
TmpDnsDevicePath = AppendDevicePathNode (TmpIpDevicePath, (EFI_DEVICE_PATH_PROTOCOL *)Node);
FreePool (Node);
FreePool (TmpIpDevicePath);
TmpIpDevicePath = NULL;
@@ -103,29 +106,33 @@ HttpBootUpdateDevicePath (
// Update the URI node with the boot file URI.
//
Length = sizeof (EFI_DEVICE_PATH_PROTOCOL) + AsciiStrSize (Private->BootFileUri);
Node = AllocatePool (Length);
Node = AllocatePool (Length);
if (Node == NULL) {
if (TmpIpDevicePath != NULL) {
FreePool (TmpIpDevicePath);
}
if (TmpDnsDevicePath != NULL) {
FreePool (TmpDnsDevicePath);
}
return EFI_OUT_OF_RESOURCES;
}
Node->DevPath.Type = MESSAGING_DEVICE_PATH;
Node->DevPath.SubType = MSG_URI_DP;
SetDevicePathNodeLength (Node, Length);
CopyMem ((UINT8*) Node + sizeof (EFI_DEVICE_PATH_PROTOCOL), Private->BootFileUri, AsciiStrSize (Private->BootFileUri));
CopyMem ((UINT8 *)Node + sizeof (EFI_DEVICE_PATH_PROTOCOL), Private->BootFileUri, AsciiStrSize (Private->BootFileUri));
if (TmpDnsDevicePath != NULL) {
NewDevicePath = AppendDevicePathNode (TmpDnsDevicePath, (EFI_DEVICE_PATH_PROTOCOL*) Node);
NewDevicePath = AppendDevicePathNode (TmpDnsDevicePath, (EFI_DEVICE_PATH_PROTOCOL *)Node);
FreePool (TmpDnsDevicePath);
} else {
ASSERT (TmpIpDevicePath != NULL);
NewDevicePath = AppendDevicePathNode (TmpIpDevicePath, (EFI_DEVICE_PATH_PROTOCOL*) Node);
NewDevicePath = AppendDevicePathNode (TmpIpDevicePath, (EFI_DEVICE_PATH_PROTOCOL *)Node);
FreePool (TmpIpDevicePath);
}
FreePool (Node);
if (NewDevicePath == NULL) {
return EFI_OUT_OF_RESOURCES;
@@ -160,6 +167,7 @@ HttpBootUpdateDevicePath (
if (EFI_ERROR (Status)) {
return Status;
}
FreePool (Private->Ip6Nic->DevicePath);
Private->Ip6Nic->DevicePath = NewDevicePath;
}
@@ -178,16 +186,16 @@ HttpBootUpdateDevicePath (
**/
EFI_STATUS
HttpBootDhcp4ExtractUriInfo (
IN HTTP_BOOT_PRIVATE_DATA *Private
IN HTTP_BOOT_PRIVATE_DATA *Private
)
{
HTTP_BOOT_DHCP4_PACKET_CACHE *SelectOffer;
HTTP_BOOT_DHCP4_PACKET_CACHE *HttpOffer;
UINT32 SelectIndex;
UINT32 ProxyIndex;
UINT32 DnsServerIndex;
EFI_DHCP4_PACKET_OPTION *Option;
EFI_STATUS Status;
HTTP_BOOT_DHCP4_PACKET_CACHE *SelectOffer;
HTTP_BOOT_DHCP4_PACKET_CACHE *HttpOffer;
UINT32 SelectIndex;
UINT32 ProxyIndex;
UINT32 DnsServerIndex;
EFI_DHCP4_PACKET_OPTION *Option;
EFI_STATUS Status;
ASSERT (Private != NULL);
ASSERT (Private->SelectIndex != 0);
@@ -209,21 +217,23 @@ HttpBootDhcp4ExtractUriInfo (
//
if ((SelectOffer->OfferType == HttpOfferTypeDhcpIpUri) ||
(SelectOffer->OfferType == HttpOfferTypeDhcpIpUriDns) ||
(SelectOffer->OfferType == HttpOfferTypeDhcpNameUriDns)) {
(SelectOffer->OfferType == HttpOfferTypeDhcpNameUriDns))
{
HttpOffer = SelectOffer;
} else {
ASSERT (Private->SelectProxyType != HttpOfferTypeMax);
ProxyIndex = Private->OfferIndex[Private->SelectProxyType][0];
HttpOffer = &Private->OfferBuffer[ProxyIndex].Dhcp4;
HttpOffer = &Private->OfferBuffer[ProxyIndex].Dhcp4;
}
Private->BootFileUriParser = HttpOffer->UriParser;
Private->BootFileUri = (CHAR8*) HttpOffer->OptList[HTTP_BOOT_DHCP4_TAG_INDEX_BOOTFILE]->Data;
Private->BootFileUri = (CHAR8 *)HttpOffer->OptList[HTTP_BOOT_DHCP4_TAG_INDEX_BOOTFILE]->Data;
} else {
//
// In Home environment the BootFileUri comes from the FilePath.
//
Private->BootFileUriParser = Private->FilePathUriParser;
Private->BootFileUri = Private->FilePathUri;
Private->BootFileUri = Private->FilePathUri;
}
//
@@ -237,12 +247,14 @@ HttpBootDhcp4ExtractUriInfo (
} else if (Status == EFI_ACCESS_DENIED) {
AsciiPrint ("\n Error: Access forbidden, only HTTPS connection is allowed.\n");
}
return Status;
}
if ((SelectOffer->OfferType == HttpOfferTypeDhcpNameUriDns) ||
(SelectOffer->OfferType == HttpOfferTypeDhcpDns) ||
(SelectOffer->OfferType == HttpOfferTypeDhcpIpUriDns)) {
(SelectOffer->OfferType == HttpOfferTypeDhcpIpUriDns))
{
Option = SelectOffer->OptList[HTTP_BOOT_DHCP4_TAG_INDEX_DNS_SERVER];
ASSERT (Option != NULL);
@@ -257,7 +269,7 @@ HttpBootDhcp4ExtractUriInfo (
}
for (DnsServerIndex = 0; DnsServerIndex < Private->DnsServerCount; DnsServerIndex++) {
CopyMem (&(Private->DnsServerIp[DnsServerIndex].v4), &(((EFI_IPv4_ADDRESS *) Option->Data)[DnsServerIndex]), sizeof (EFI_IPv4_ADDRESS));
CopyMem (&(Private->DnsServerIp[DnsServerIndex].v4), &(((EFI_IPv4_ADDRESS *)Option->Data)[DnsServerIndex]), sizeof (EFI_IPv4_ADDRESS));
}
//
@@ -283,7 +295,7 @@ HttpBootDhcp4ExtractUriInfo (
Private->BootFileUriParser,
&Private->Port
);
if (EFI_ERROR (Status) || Private->Port == 0) {
if (EFI_ERROR (Status) || (Private->Port == 0)) {
Private->Port = 80;
}
@@ -295,7 +307,7 @@ HttpBootDhcp4ExtractUriInfo (
// Update the device path to include the boot resource information.
//
Status = HttpBootUpdateDevicePath (Private);
if (EFI_ERROR (Status) && Private->DnsServerIp != NULL) {
if (EFI_ERROR (Status) && (Private->DnsServerIp != NULL)) {
FreePool (Private->DnsServerIp);
Private->DnsServerIp = NULL;
}
@@ -314,20 +326,20 @@ HttpBootDhcp4ExtractUriInfo (
**/
EFI_STATUS
HttpBootDhcp6ExtractUriInfo (
IN HTTP_BOOT_PRIVATE_DATA *Private
IN HTTP_BOOT_PRIVATE_DATA *Private
)
{
HTTP_BOOT_DHCP6_PACKET_CACHE *SelectOffer;
HTTP_BOOT_DHCP6_PACKET_CACHE *HttpOffer;
UINT32 SelectIndex;
UINT32 ProxyIndex;
UINT32 DnsServerIndex;
EFI_DHCP6_PACKET_OPTION *Option;
EFI_IPv6_ADDRESS IpAddr;
CHAR8 *HostName;
UINTN HostNameSize;
CHAR16 *HostNameStr;
EFI_STATUS Status;
HTTP_BOOT_DHCP6_PACKET_CACHE *SelectOffer;
HTTP_BOOT_DHCP6_PACKET_CACHE *HttpOffer;
UINT32 SelectIndex;
UINT32 ProxyIndex;
UINT32 DnsServerIndex;
EFI_DHCP6_PACKET_OPTION *Option;
EFI_IPv6_ADDRESS IpAddr;
CHAR8 *HostName;
UINTN HostNameSize;
CHAR16 *HostNameStr;
EFI_STATUS Status;
ASSERT (Private != NULL);
ASSERT (Private->SelectIndex != 0);
@@ -349,21 +361,23 @@ HttpBootDhcp6ExtractUriInfo (
//
if ((SelectOffer->OfferType == HttpOfferTypeDhcpIpUri) ||
(SelectOffer->OfferType == HttpOfferTypeDhcpIpUriDns) ||
(SelectOffer->OfferType == HttpOfferTypeDhcpNameUriDns)) {
(SelectOffer->OfferType == HttpOfferTypeDhcpNameUriDns))
{
HttpOffer = SelectOffer;
} else {
ASSERT (Private->SelectProxyType != HttpOfferTypeMax);
ProxyIndex = Private->OfferIndex[Private->SelectProxyType][0];
HttpOffer = &Private->OfferBuffer[ProxyIndex].Dhcp6;
HttpOffer = &Private->OfferBuffer[ProxyIndex].Dhcp6;
}
Private->BootFileUriParser = HttpOffer->UriParser;
Private->BootFileUri = (CHAR8*) HttpOffer->OptList[HTTP_BOOT_DHCP6_IDX_BOOT_FILE_URL]->Data;
Private->BootFileUri = (CHAR8 *)HttpOffer->OptList[HTTP_BOOT_DHCP6_IDX_BOOT_FILE_URL]->Data;
} else {
//
// In Home environment the BootFileUri comes from the FilePath.
//
Private->BootFileUriParser = Private->FilePathUriParser;
Private->BootFileUri = Private->FilePathUri;
Private->BootFileUri = Private->FilePathUri;
}
//
@@ -377,6 +391,7 @@ HttpBootDhcp6ExtractUriInfo (
} else if (Status == EFI_ACCESS_DENIED) {
AsciiPrint ("\n Error: Access forbidden, only HTTPS connection is allowed.\n");
}
return Status;
}
@@ -398,7 +413,8 @@ HttpBootDhcp6ExtractUriInfo (
if ((SelectOffer->OfferType == HttpOfferTypeDhcpNameUriDns) ||
(SelectOffer->OfferType == HttpOfferTypeDhcpDns) ||
(SelectOffer->OfferType == HttpOfferTypeDhcpIpUriDns)) {
(SelectOffer->OfferType == HttpOfferTypeDhcpIpUriDns))
{
Option = SelectOffer->OptList[HTTP_BOOT_DHCP6_IDX_DNS_SERVER];
ASSERT (Option != NULL);
@@ -413,7 +429,7 @@ HttpBootDhcp6ExtractUriInfo (
}
for (DnsServerIndex = 0; DnsServerIndex < Private->DnsServerCount; DnsServerIndex++) {
CopyMem (&(Private->DnsServerIp[DnsServerIndex].v6), &(((EFI_IPv6_ADDRESS *) Option->Data)[DnsServerIndex]), sizeof (EFI_IPv6_ADDRESS));
CopyMem (&(Private->DnsServerIp[DnsServerIndex].v6), &(((EFI_IPv6_ADDRESS *)Option->Data)[DnsServerIndex]), sizeof (EFI_IPv6_ADDRESS));
}
//
@@ -453,7 +469,7 @@ HttpBootDhcp6ExtractUriInfo (
}
HostNameSize = AsciiStrSize (HostName);
HostNameStr = AllocateZeroPool (HostNameSize * sizeof (CHAR16));
HostNameStr = AllocateZeroPool (HostNameSize * sizeof (CHAR16));
if (HostNameStr == NULL) {
Status = EFI_OUT_OF_RESOURCES;
goto Error;
@@ -483,7 +499,7 @@ HttpBootDhcp6ExtractUriInfo (
Private->BootFileUriParser,
&Private->Port
);
if (EFI_ERROR (Status) || Private->Port == 0) {
if (EFI_ERROR (Status) || (Private->Port == 0)) {
Private->Port = 80;
}
@@ -510,7 +526,6 @@ Error:
return Status;
}
/**
Discover all the boot information for boot file.
@@ -522,10 +537,10 @@ Error:
**/
EFI_STATUS
HttpBootDiscoverBootInfo (
IN OUT HTTP_BOOT_PRIVATE_DATA *Private
IN OUT HTTP_BOOT_PRIVATE_DATA *Private
)
{
EFI_STATUS Status;
EFI_STATUS Status;
//
// Start D.O.R.A/S.A.R.R exchange to acquire station ip address and
@@ -558,24 +573,26 @@ HttpBootDiscoverBootInfo (
EFI_STATUS
EFIAPI
HttpBootHttpIoCallback (
IN HTTP_IO_CALLBACK_EVENT EventType,
IN EFI_HTTP_MESSAGE *Message,
IN VOID *Context
IN HTTP_IO_CALLBACK_EVENT EventType,
IN EFI_HTTP_MESSAGE *Message,
IN VOID *Context
)
{
HTTP_BOOT_PRIVATE_DATA *Private;
EFI_STATUS Status;
Private = (HTTP_BOOT_PRIVATE_DATA *) Context;
HTTP_BOOT_PRIVATE_DATA *Private;
EFI_STATUS Status;
Private = (HTTP_BOOT_PRIVATE_DATA *)Context;
if (Private->HttpBootCallback != NULL) {
Status = Private->HttpBootCallback->Callback (
Private->HttpBootCallback,
EventType == HttpIoRequest ? HttpBootHttpRequest : HttpBootHttpResponse,
EventType == HttpIoRequest ? FALSE : TRUE,
sizeof (EFI_HTTP_MESSAGE),
(VOID *) Message
);
Private->HttpBootCallback,
EventType == HttpIoRequest ? HttpBootHttpRequest : HttpBootHttpResponse,
EventType == HttpIoRequest ? FALSE : TRUE,
sizeof (EFI_HTTP_MESSAGE),
(VOID *)Message
);
return Status;
}
return EFI_SUCCESS;
}
@@ -590,13 +607,13 @@ HttpBootHttpIoCallback (
**/
EFI_STATUS
HttpBootCreateHttpIo (
IN HTTP_BOOT_PRIVATE_DATA *Private
IN HTTP_BOOT_PRIVATE_DATA *Private
)
{
HTTP_IO_CONFIG_DATA ConfigData;
EFI_STATUS Status;
EFI_HANDLE ImageHandle;
UINT32 TimeoutValue;
HTTP_IO_CONFIG_DATA ConfigData;
EFI_STATUS Status;
EFI_HANDLE ImageHandle;
UINT32 TimeoutValue;
ASSERT (Private != NULL);
@@ -625,7 +642,7 @@ HttpBootCreateHttpIo (
Private->UsingIpv6 ? IP_VERSION_6 : IP_VERSION_4,
&ConfigData,
HttpBootHttpIoCallback,
(VOID *) Private,
(VOID *)Private,
&Private->HttpIo
);
if (EFI_ERROR (Status)) {
@@ -644,13 +661,13 @@ HttpBootCreateHttpIo (
**/
VOID
HttpBootFreeCache (
IN HTTP_BOOT_CACHE_CONTENT *Cache
IN HTTP_BOOT_CACHE_CONTENT *Cache
)
{
UINTN Index;
LIST_ENTRY *Entry;
LIST_ENTRY *NextEntry;
HTTP_BOOT_ENTITY_DATA *EntityData;
UINTN Index;
LIST_ENTRY *Entry;
LIST_ENTRY *NextEntry;
HTTP_BOOT_ENTITY_DATA *EntityData;
if (Cache != NULL) {
//
@@ -660,6 +677,7 @@ HttpBootFreeCache (
if (Cache->RequestData->Url != NULL) {
FreePool (Cache->RequestData->Url);
}
FreePool (Cache->RequestData);
}
@@ -672,6 +690,7 @@ HttpBootFreeCache (
FreePool (Cache->ResponseData->Headers[Index].FieldName);
FreePool (Cache->ResponseData->Headers[Index].FieldValue);
}
FreePool (Cache->ResponseData->Headers);
}
}
@@ -684,6 +703,7 @@ HttpBootFreeCache (
if (EntityData->Block != NULL) {
FreePool (EntityData->Block);
}
RemoveEntryList (&EntityData->Link);
FreePool (EntityData);
}
@@ -700,12 +720,12 @@ HttpBootFreeCache (
**/
VOID
HttpBootFreeCacheList (
IN HTTP_BOOT_PRIVATE_DATA *Private
IN HTTP_BOOT_PRIVATE_DATA *Private
)
{
LIST_ENTRY *Entry;
LIST_ENTRY *NextEntry;
HTTP_BOOT_CACHE_CONTENT *Cache;
LIST_ENTRY *Entry;
LIST_ENTRY *NextEntry;
HTTP_BOOT_CACHE_CONTENT *Cache;
NET_LIST_FOR_EACH_SAFE (Entry, NextEntry, &Private->CacheList) {
Cache = NET_LIST_USER_STRUCT (Entry, HTTP_BOOT_CACHE_CONTENT, Link);
@@ -734,20 +754,20 @@ HttpBootFreeCacheList (
**/
EFI_STATUS
HttpBootGetFileFromCache (
IN HTTP_BOOT_PRIVATE_DATA *Private,
IN CHAR16 *Uri,
IN OUT UINTN *BufferSize,
OUT UINT8 *Buffer,
OUT HTTP_BOOT_IMAGE_TYPE *ImageType
IN HTTP_BOOT_PRIVATE_DATA *Private,
IN CHAR16 *Uri,
IN OUT UINTN *BufferSize,
OUT UINT8 *Buffer,
OUT HTTP_BOOT_IMAGE_TYPE *ImageType
)
{
LIST_ENTRY *Entry;
LIST_ENTRY *Entry2;
HTTP_BOOT_CACHE_CONTENT *Cache;
HTTP_BOOT_ENTITY_DATA *EntityData;
UINTN CopyedSize;
LIST_ENTRY *Entry;
LIST_ENTRY *Entry2;
HTTP_BOOT_CACHE_CONTENT *Cache;
HTTP_BOOT_ENTITY_DATA *EntityData;
UINTN CopyedSize;
if (Uri == NULL || BufferSize == NULL || Buffer == NULL || ImageType == NULL) {
if ((Uri == NULL) || (BufferSize == NULL) || (Buffer == NULL) || (ImageType == NULL)) {
return EFI_INVALID_PARAMETER;
}
@@ -758,11 +778,12 @@ HttpBootGetFileFromCache (
//
if ((Cache->RequestData != NULL) &&
(Cache->RequestData->Url != NULL) &&
(StrCmp (Uri, Cache->RequestData->Url) == 0)) {
(StrCmp (Uri, Cache->RequestData->Url) == 0))
{
//
// Hit in cache, record image type.
//
*ImageType = Cache->ImageType;
*ImageType = Cache->ImageType;
//
// Check buffer size.
@@ -813,16 +834,16 @@ HttpBootGetFileFromCache (
EFI_STATUS
EFIAPI
HttpBootGetBootFileCallback (
IN HTTP_BODY_PARSE_EVENT EventType,
IN CHAR8 *Data,
IN UINTN Length,
IN VOID *Context
IN HTTP_BODY_PARSE_EVENT EventType,
IN CHAR8 *Data,
IN UINTN Length,
IN VOID *Context
)
{
HTTP_BOOT_CALLBACK_DATA *CallbackData;
HTTP_BOOT_ENTITY_DATA *NewEntityData;
EFI_STATUS Status;
EFI_HTTP_BOOT_CALLBACK_PROTOCOL *HttpBootCallback;
HTTP_BOOT_CALLBACK_DATA *CallbackData;
HTTP_BOOT_ENTITY_DATA *NewEntityData;
EFI_STATUS Status;
EFI_HTTP_BOOT_CALLBACK_PROTOCOL *HttpBootCallback;
//
// We only care about the entity data.
@@ -831,20 +852,21 @@ HttpBootGetBootFileCallback (
return EFI_SUCCESS;
}
CallbackData = (HTTP_BOOT_CALLBACK_DATA *) Context;
CallbackData = (HTTP_BOOT_CALLBACK_DATA *)Context;
HttpBootCallback = CallbackData->Private->HttpBootCallback;
if (HttpBootCallback != NULL) {
Status = HttpBootCallback->Callback (
HttpBootCallback,
HttpBootHttpEntityBody,
TRUE,
(UINT32)Length,
Data
);
HttpBootCallback,
HttpBootHttpEntityBody,
TRUE,
(UINT32)Length,
Data
);
if (EFI_ERROR (Status)) {
return Status;
}
}
//
// Copy data if caller has provided a buffer.
//
@@ -865,14 +887,17 @@ HttpBootGetBootFileCallback (
if (NewEntityData == NULL) {
return EFI_OUT_OF_RESOURCES;
}
if (CallbackData->NewBlock) {
NewEntityData->Block = CallbackData->Block;
CallbackData->Block = NULL;
CallbackData->Block = NULL;
}
NewEntityData->DataLength = Length;
NewEntityData->DataStart = (UINT8*) Data;
NewEntityData->DataStart = (UINT8 *)Data;
InsertTailList (&CallbackData->Cache->EntityDataList, &NewEntityData->Link);
}
return EFI_SUCCESS;
}
@@ -902,39 +927,39 @@ HttpBootGetBootFileCallback (
**/
EFI_STATUS
HttpBootGetBootFile (
IN HTTP_BOOT_PRIVATE_DATA *Private,
IN BOOLEAN HeaderOnly,
IN OUT UINTN *BufferSize,
OUT UINT8 *Buffer,
OUT HTTP_BOOT_IMAGE_TYPE *ImageType
IN HTTP_BOOT_PRIVATE_DATA *Private,
IN BOOLEAN HeaderOnly,
IN OUT UINTN *BufferSize,
OUT UINT8 *Buffer,
OUT HTTP_BOOT_IMAGE_TYPE *ImageType
)
{
EFI_STATUS Status;
EFI_HTTP_STATUS_CODE StatusCode;
CHAR8 *HostName;
EFI_HTTP_REQUEST_DATA *RequestData;
HTTP_IO_RESPONSE_DATA *ResponseData;
HTTP_IO_RESPONSE_DATA ResponseBody;
HTTP_IO *HttpIo;
HTTP_IO_HEADER *HttpIoHeader;
VOID *Parser;
HTTP_BOOT_CALLBACK_DATA Context;
UINTN ContentLength;
HTTP_BOOT_CACHE_CONTENT *Cache;
UINT8 *Block;
UINTN UrlSize;
CHAR16 *Url;
BOOLEAN IdentityMode;
UINTN ReceivedSize;
EFI_STATUS Status;
EFI_HTTP_STATUS_CODE StatusCode;
CHAR8 *HostName;
EFI_HTTP_REQUEST_DATA *RequestData;
HTTP_IO_RESPONSE_DATA *ResponseData;
HTTP_IO_RESPONSE_DATA ResponseBody;
HTTP_IO *HttpIo;
HTTP_IO_HEADER *HttpIoHeader;
VOID *Parser;
HTTP_BOOT_CALLBACK_DATA Context;
UINTN ContentLength;
HTTP_BOOT_CACHE_CONTENT *Cache;
UINT8 *Block;
UINTN UrlSize;
CHAR16 *Url;
BOOLEAN IdentityMode;
UINTN ReceivedSize;
ASSERT (Private != NULL);
ASSERT (Private->HttpCreated);
if (BufferSize == NULL || ImageType == NULL) {
if ((BufferSize == NULL) || (ImageType == NULL)) {
return EFI_INVALID_PARAMETER;
}
if (*BufferSize != 0 && Buffer == NULL) {
if ((*BufferSize != 0) && (Buffer == NULL)) {
return EFI_INVALID_PARAMETER;
}
@@ -942,12 +967,13 @@ HttpBootGetBootFile (
// First, check whether we already cached the requested Uri.
//
UrlSize = AsciiStrSize (Private->BootFileUri);
Url = AllocatePool (UrlSize * sizeof (CHAR16));
Url = AllocatePool (UrlSize * sizeof (CHAR16));
if (Url == NULL) {
return EFI_OUT_OF_RESOURCES;
}
AsciiStrToUnicodeStrS (Private->BootFileUri, Url, UrlSize);
if (!HeaderOnly && Buffer != NULL) {
if (!HeaderOnly && (Buffer != NULL)) {
Status = HttpBootGetFileFromCache (Private, Url, BufferSize, Buffer, ImageType);
if (Status != EFI_NOT_FOUND) {
FreePool (Url);
@@ -969,6 +995,7 @@ HttpBootGetBootFile (
Status = EFI_OUT_OF_RESOURCES;
goto ERROR_1;
}
Cache->ImageType = ImageTypeMax;
InitializeListHead (&Cache->EntityDataList);
}
@@ -993,14 +1020,15 @@ HttpBootGetBootFile (
// Add HTTP header field 1: Host
//
HostName = NULL;
Status = HttpUrlGetHostName (
Private->BootFileUri,
Private->BootFileUriParser,
&HostName
);
Status = HttpUrlGetHostName (
Private->BootFileUri,
Private->BootFileUriParser,
&HostName
);
if (EFI_ERROR (Status)) {
goto ERROR_3;
}
Status = HttpIoSetHeader (
HttpIoHeader,
HTTP_HEADER_HOST,
@@ -1043,8 +1071,9 @@ HttpBootGetBootFile (
Status = EFI_OUT_OF_RESOURCES;
goto ERROR_3;
}
RequestData->Method = HeaderOnly ? HttpMethodHead : HttpMethodGet;
RequestData->Url = Url;
RequestData->Url = Url;
//
// 2.3 Record the request info in a temp cache item.
@@ -1064,7 +1093,7 @@ HttpBootGetBootFile (
HttpIoHeader->Headers,
0,
NULL
);
);
if (EFI_ERROR (Status)) {
goto ERROR_4;
}
@@ -1076,11 +1105,12 @@ HttpBootGetBootFile (
//
// 3.1 First step, use zero BodyLength to only receive the response headers.
//
ResponseData = AllocateZeroPool (sizeof(HTTP_IO_RESPONSE_DATA));
ResponseData = AllocateZeroPool (sizeof (HTTP_IO_RESPONSE_DATA));
if (ResponseData == NULL) {
Status = EFI_OUT_OF_RESOURCES;
goto ERROR_4;
}
Status = HttpIoRecvResponse (
&Private->HttpIo,
TRUE,
@@ -1092,6 +1122,7 @@ HttpBootGetBootFile (
HttpBootPrintErrorMessage (StatusCode);
Status = ResponseData->Status;
}
goto ERROR_5;
}
@@ -1114,13 +1145,13 @@ HttpBootGetBootFile (
//
if (Cache != NULL) {
Cache->ResponseData = ResponseData;
Cache->ImageType = *ImageType;
Cache->ImageType = *ImageType;
}
//
// 3.3 Init a message-body parser from the header information.
//
Parser = NULL;
Parser = NULL;
Context.NewBlock = FALSE;
Context.Block = NULL;
Context.CopyedSize = 0;
@@ -1128,15 +1159,15 @@ HttpBootGetBootFile (
Context.BufferSize = *BufferSize;
Context.Cache = Cache;
Context.Private = Private;
Status = HttpInitMsgParser (
HeaderOnly ? HttpMethodHead : HttpMethodGet,
ResponseData->Response.StatusCode,
ResponseData->HeaderCount,
ResponseData->Headers,
HttpBootGetBootFileCallback,
(VOID*) &Context,
&Parser
);
Status = HttpInitMsgParser (
HeaderOnly ? HttpMethodHead : HttpMethodGet,
ResponseData->Response.StatusCode,
ResponseData->HeaderCount,
ResponseData->Headers,
HttpBootGetBootFileCallback,
(VOID *)&Context,
&Parser
);
if (EFI_ERROR (Status)) {
goto ERROR_6;
}
@@ -1150,7 +1181,7 @@ HttpBootGetBootFile (
// 3.4.1, check whether we are in identity transfer-coding.
//
ContentLength = 0;
Status = HttpGetEntityLength (Parser, &ContentLength);
Status = HttpGetEntityLength (Parser, &ContentLength);
if (!EFI_ERROR (Status)) {
IdentityMode = TRUE;
} else {
@@ -1169,28 +1200,30 @@ HttpBootGetBootFile (
//
ReceivedSize = 0;
while (ReceivedSize < ContentLength) {
ResponseBody.Body = (CHAR8*) Buffer + ReceivedSize;
ResponseBody.Body = (CHAR8 *)Buffer + ReceivedSize;
ResponseBody.BodyLength = *BufferSize - ReceivedSize;
Status = HttpIoRecvResponse (
&Private->HttpIo,
FALSE,
&ResponseBody
);
Status = HttpIoRecvResponse (
&Private->HttpIo,
FALSE,
&ResponseBody
);
if (EFI_ERROR (Status) || EFI_ERROR (ResponseBody.Status)) {
if (EFI_ERROR (ResponseBody.Status)) {
Status = ResponseBody.Status;
}
goto ERROR_6;
}
ReceivedSize += ResponseBody.BodyLength;
if (Private->HttpBootCallback != NULL) {
Status = Private->HttpBootCallback->Callback (
Private->HttpBootCallback,
HttpBootHttpEntityBody,
TRUE,
(UINT32)ResponseBody.BodyLength,
ResponseBody.Body
);
Private->HttpBootCallback,
HttpBootHttpEntityBody,
TRUE,
(UINT32)ResponseBody.BodyLength,
ResponseBody.Body
);
if (EFI_ERROR (Status)) {
goto ERROR_6;
}
@@ -1209,29 +1242,31 @@ HttpBootGetBootFile (
// Otherwise a buffer, the buffer in Block will be cached and we should allocate a new before
// every HttpIoRecvResponse().
//
if (Block == NULL || Context.BufferSize == 0) {
if ((Block == NULL) || (Context.BufferSize == 0)) {
Block = AllocatePool (HTTP_BOOT_BLOCK_SIZE);
if (Block == NULL) {
Status = EFI_OUT_OF_RESOURCES;
goto ERROR_6;
}
Context.NewBlock = TRUE;
Context.Block = Block;
Context.Block = Block;
} else {
Context.NewBlock = FALSE;
}
ResponseBody.Body = (CHAR8*) Block;
ResponseBody.Body = (CHAR8 *)Block;
ResponseBody.BodyLength = HTTP_BOOT_BLOCK_SIZE;
Status = HttpIoRecvResponse (
&Private->HttpIo,
FALSE,
&ResponseBody
);
Status = HttpIoRecvResponse (
&Private->HttpIo,
FALSE,
&ResponseBody
);
if (EFI_ERROR (Status) || EFI_ERROR (ResponseBody.Status)) {
if (EFI_ERROR (ResponseBody.Status)) {
Status = ResponseBody.Status;
}
goto ERROR_6;
}
@@ -1263,6 +1298,7 @@ HttpBootGetBootFile (
} else {
Status = EFI_SUCCESS;
}
*BufferSize = ContentLength;
//
@@ -1283,25 +1319,30 @@ ERROR_6:
if (Parser != NULL) {
HttpFreeMsgParser (Parser);
}
if (Context.Block != NULL) {
FreePool (Context.Block);
}
HttpBootFreeCache (Cache);
ERROR_5:
if (ResponseData != NULL) {
FreePool (ResponseData);
}
ERROR_4:
if (RequestData != NULL) {
FreePool (RequestData);
}
ERROR_3:
HttpIoFreeHeader (HttpIoHeader);
ERROR_2:
if (Cache != NULL) {
FreePool (Cache);
}
ERROR_1:
if (Url != NULL) {
FreePool (Url);

View File

@@ -10,29 +10,29 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#ifndef __EFI_HTTP_BOOT_HTTP_H__
#define __EFI_HTTP_BOOT_HTTP_H__
#define HTTP_BOOT_BLOCK_SIZE 1500
#define HTTP_USER_AGENT_EFI_HTTP_BOOT "UefiHttpBoot/1.0"
#define HTTP_BOOT_BLOCK_SIZE 1500
#define HTTP_USER_AGENT_EFI_HTTP_BOOT "UefiHttpBoot/1.0"
//
// Record the data length and start address of a data block.
//
typedef struct {
LIST_ENTRY Link; // Link to the EntityDataList in HTTP_BOOT_CACHE_CONTENT
UINT8 *Block; // If NULL, the data is in previous data block.
UINT8 *DataStart; // Point to somewhere in the Block
UINTN DataLength;
LIST_ENTRY Link; // Link to the EntityDataList in HTTP_BOOT_CACHE_CONTENT
UINT8 *Block; // If NULL, the data is in previous data block.
UINT8 *DataStart; // Point to somewhere in the Block
UINTN DataLength;
} HTTP_BOOT_ENTITY_DATA;
//
// Structure for a cache item
//
typedef struct {
LIST_ENTRY Link; // Link to the CacheList in driver's private data.
EFI_HTTP_REQUEST_DATA *RequestData;
HTTP_IO_RESPONSE_DATA *ResponseData; // Not include any message-body data.
HTTP_BOOT_IMAGE_TYPE ImageType;
UINTN EntityLength;
LIST_ENTRY EntityDataList; // Entity data (message-body)
LIST_ENTRY Link; // Link to the CacheList in driver's private data.
EFI_HTTP_REQUEST_DATA *RequestData;
HTTP_IO_RESPONSE_DATA *ResponseData; // Not include any message-body data.
HTTP_BOOT_IMAGE_TYPE ImageType;
UINTN EntityLength;
LIST_ENTRY EntityDataList; // Entity data (message-body)
} HTTP_BOOT_CACHE_CONTENT;
//
@@ -68,7 +68,7 @@ typedef struct {
**/
EFI_STATUS
HttpBootDiscoverBootInfo (
IN OUT HTTP_BOOT_PRIVATE_DATA *Private
IN OUT HTTP_BOOT_PRIVATE_DATA *Private
);
/**
@@ -82,7 +82,7 @@ HttpBootDiscoverBootInfo (
**/
EFI_STATUS
HttpBootCreateHttpIo (
IN HTTP_BOOT_PRIVATE_DATA *Private
IN HTTP_BOOT_PRIVATE_DATA *Private
);
/**
@@ -111,11 +111,11 @@ HttpBootCreateHttpIo (
**/
EFI_STATUS
HttpBootGetBootFile (
IN HTTP_BOOT_PRIVATE_DATA *Private,
IN BOOLEAN HeaderOnly,
IN OUT UINTN *BufferSize,
OUT UINT8 *Buffer,
OUT HTTP_BOOT_IMAGE_TYPE *ImageType
IN HTTP_BOOT_PRIVATE_DATA *Private,
IN BOOLEAN HeaderOnly,
IN OUT UINTN *BufferSize,
OUT UINT8 *Buffer,
OUT HTTP_BOOT_IMAGE_TYPE *ImageType
);
/**
@@ -126,7 +126,7 @@ HttpBootGetBootFile (
**/
VOID
HttpBootFreeCacheList (
IN HTTP_BOOT_PRIVATE_DATA *Private
IN HTTP_BOOT_PRIVATE_DATA *Private
);
#endif

View File

@@ -13,7 +13,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
///
GLOBAL_REMOVE_IF_UNREFERENCED
EFI_COMPONENT_NAME_PROTOCOL gHttpBootDxeComponentName = {
(EFI_COMPONENT_NAME_GET_DRIVER_NAME) HttpBootDxeComponentNameGetDriverName,
(EFI_COMPONENT_NAME_GET_DRIVER_NAME)HttpBootDxeComponentNameGetDriverName,
(EFI_COMPONENT_NAME_GET_CONTROLLER_NAME)HttpBootDxeComponentNameGetControllerName,
"eng"
};
@@ -32,18 +32,18 @@ EFI_COMPONENT_NAME2_PROTOCOL gHttpBootDxeComponentName2 = {
/// Table of driver names
///
GLOBAL_REMOVE_IF_UNREFERENCED
EFI_UNICODE_STRING_TABLE mHttpBootDxeDriverNameTable[] = {
EFI_UNICODE_STRING_TABLE mHttpBootDxeDriverNameTable[] = {
{ "eng;en", (CHAR16 *)L"UEFI HTTP Boot Driver" },
{ NULL, NULL }
{ NULL, NULL }
};
///
/// Table of controller names
///
GLOBAL_REMOVE_IF_UNREFERENCED
EFI_UNICODE_STRING_TABLE mHttpBootDxeControllerNameTable[] = {
EFI_UNICODE_STRING_TABLE mHttpBootDxeControllerNameTable[] = {
{ "eng;en", (CHAR16 *)L"UEFI Http Boot Controller" },
{ NULL, NULL }
{ NULL, NULL }
};
/**
@@ -81,7 +81,7 @@ HttpBootDxeComponentNameGetDriverName (
This->SupportedLanguages,
mHttpBootDxeDriverNameTable,
DriverName,
(BOOLEAN) (This != &gHttpBootDxeComponentName2)
(BOOLEAN)(This != &gHttpBootDxeComponentName2)
);
}
@@ -135,17 +135,17 @@ HttpBootDxeComponentNameGetControllerName (
OUT CHAR16 **ControllerName
)
{
EFI_STATUS Status;
EFI_HANDLE NicHandle;
UINT32 *Id;
EFI_STATUS Status;
EFI_HANDLE NicHandle;
UINT32 *Id;
if (ControllerHandle == NULL || ChildHandle != NULL) {
if ((ControllerHandle == NULL) || (ChildHandle != NULL)) {
return EFI_UNSUPPORTED;
}
NicHandle = HttpBootGetNicByIp4Children (ControllerHandle);
if (NicHandle == NULL) {
NicHandle = HttpBootGetNicByIp6Children(ControllerHandle);
NicHandle = HttpBootGetNicByIp6Children (ControllerHandle);
if (NicHandle == NULL) {
return EFI_UNSUPPORTED;
}
@@ -157,7 +157,7 @@ HttpBootDxeComponentNameGetControllerName (
Status = gBS->OpenProtocol (
NicHandle,
&gEfiCallerIdGuid,
(VOID **) &Id,
(VOID **)&Id,
NULL,
NULL,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
@@ -173,5 +173,4 @@ HttpBootDxeComponentNameGetControllerName (
ControllerName,
(BOOLEAN)(This != &gHttpBootDxeComponentName2)
);
}

View File

@@ -9,7 +9,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include "HttpBootDxe.h"
#include <Library/UefiBootManagerLib.h>
CHAR16 mHttpBootConfigStorageName[] = L"HTTP_BOOT_CONFIG_IFR_NVDATA";
CHAR16 mHttpBootConfigStorageName[] = L"HTTP_BOOT_CONFIG_IFR_NVDATA";
/**
Add new boot option for HTTP boot.
@@ -25,20 +25,20 @@ CHAR16 mHttpBootConfigStorageName[] = L"HTTP_BOOT_CONFIG_IFR_NVDATA";
**/
EFI_STATUS
HttpBootAddBootOption (
IN HTTP_BOOT_PRIVATE_DATA *Private,
IN BOOLEAN UsingIpv6,
IN CHAR16 *Description,
IN CHAR16 *Uri
IN HTTP_BOOT_PRIVATE_DATA *Private,
IN BOOLEAN UsingIpv6,
IN CHAR16 *Description,
IN CHAR16 *Uri
)
{
EFI_DEV_PATH *Node;
EFI_DEVICE_PATH_PROTOCOL *TmpDevicePath;
EFI_DEVICE_PATH_PROTOCOL *NewDevicePath;
UINTN Length;
CHAR8 AsciiUri[URI_STR_MAX_SIZE];
EFI_STATUS Status;
UINTN Index;
EFI_BOOT_MANAGER_LOAD_OPTION NewOption;
EFI_DEV_PATH *Node;
EFI_DEVICE_PATH_PROTOCOL *TmpDevicePath;
EFI_DEVICE_PATH_PROTOCOL *NewDevicePath;
UINTN Length;
CHAR8 AsciiUri[URI_STR_MAX_SIZE];
EFI_STATUS Status;
UINTN Index;
EFI_BOOT_MANAGER_LOAD_OPTION NewOption;
NewDevicePath = NULL;
Node = NULL;
@@ -55,7 +55,8 @@ HttpBootAddBootOption (
if (Uri[Index] == L':') {
break;
}
if (Uri[Index] >= L'A' && Uri[Index] <= L'Z') {
if ((Uri[Index] >= L'A') && (Uri[Index] <= L'Z')) {
Uri[Index] -= (CHAR16)(L'A' - L'a');
}
}
@@ -77,6 +78,7 @@ HttpBootAddBootOption (
Status = EFI_OUT_OF_RESOURCES;
goto ON_EXIT;
}
Node->Ipv4.Header.Type = MESSAGING_DEVICE_PATH;
Node->Ipv4.Header.SubType = MSG_IPv4_DP;
SetDevicePathNodeLength (Node, sizeof (IPv4_DEVICE_PATH));
@@ -86,31 +88,35 @@ HttpBootAddBootOption (
Status = EFI_OUT_OF_RESOURCES;
goto ON_EXIT;
}
Node->Ipv6.Header.Type = MESSAGING_DEVICE_PATH;
Node->Ipv6.Header.SubType = MSG_IPv6_DP;
Node->Ipv6.Header.Type = MESSAGING_DEVICE_PATH;
Node->Ipv6.Header.SubType = MSG_IPv6_DP;
SetDevicePathNodeLength (Node, sizeof (IPv6_DEVICE_PATH));
}
TmpDevicePath = AppendDevicePathNode (Private->ParentDevicePath, (EFI_DEVICE_PATH_PROTOCOL*) Node);
TmpDevicePath = AppendDevicePathNode (Private->ParentDevicePath, (EFI_DEVICE_PATH_PROTOCOL *)Node);
FreePool (Node);
if (TmpDevicePath == NULL) {
return EFI_OUT_OF_RESOURCES;
}
//
// Update the URI node with the input boot file URI.
//
UnicodeStrToAsciiStrS (Uri, AsciiUri, sizeof (AsciiUri));
Length = sizeof (EFI_DEVICE_PATH_PROTOCOL) + AsciiStrSize (AsciiUri);
Node = AllocatePool (Length);
Node = AllocatePool (Length);
if (Node == NULL) {
Status = EFI_OUT_OF_RESOURCES;
FreePool (TmpDevicePath);
goto ON_EXIT;
}
Node->DevPath.Type = MESSAGING_DEVICE_PATH;
Node->DevPath.SubType = MSG_URI_DP;
SetDevicePathNodeLength (Node, Length);
CopyMem ((UINT8*) Node + sizeof (EFI_DEVICE_PATH_PROTOCOL), AsciiUri, AsciiStrSize (AsciiUri));
NewDevicePath = AppendDevicePathNode (TmpDevicePath, (EFI_DEVICE_PATH_PROTOCOL*) Node);
CopyMem ((UINT8 *)Node + sizeof (EFI_DEVICE_PATH_PROTOCOL), AsciiUri, AsciiStrSize (AsciiUri));
NewDevicePath = AppendDevicePathNode (TmpDevicePath, (EFI_DEVICE_PATH_PROTOCOL *)Node);
FreePool (Node);
FreePool (TmpDevicePath);
if (NewDevicePath == NULL) {
@@ -122,20 +128,20 @@ HttpBootAddBootOption (
// Add a new load option.
//
Status = EfiBootManagerInitializeLoadOption (
&NewOption,
LoadOptionNumberUnassigned,
LoadOptionTypeBoot,
LOAD_OPTION_ACTIVE,
Description,
NewDevicePath,
NULL,
0
);
&NewOption,
LoadOptionNumberUnassigned,
LoadOptionTypeBoot,
LOAD_OPTION_ACTIVE,
Description,
NewDevicePath,
NULL,
0
);
if (EFI_ERROR (Status)) {
goto ON_EXIT;
}
Status = EfiBootManagerAddLoadOptionVariable (&NewOption, (UINTN) -1);
Status = EfiBootManagerAddLoadOptionVariable (&NewOption, (UINTN)-1);
EfiBootManagerFreeLoadOption (&NewOption);
ON_EXIT:
@@ -221,21 +227,21 @@ ON_EXIT:
EFI_STATUS
EFIAPI
HttpBootFormExtractConfig (
IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
IN CONST EFI_STRING Request,
OUT EFI_STRING *Progress,
OUT EFI_STRING *Results
IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
IN CONST EFI_STRING Request,
OUT EFI_STRING *Progress,
OUT EFI_STRING *Results
)
{
EFI_STATUS Status;
UINTN BufferSize;
HTTP_BOOT_FORM_CALLBACK_INFO *CallbackInfo;
EFI_STRING ConfigRequestHdr;
EFI_STRING ConfigRequest;
BOOLEAN AllocatedRequest;
UINTN Size;
EFI_STATUS Status;
UINTN BufferSize;
HTTP_BOOT_FORM_CALLBACK_INFO *CallbackInfo;
EFI_STRING ConfigRequestHdr;
EFI_STRING ConfigRequest;
BOOLEAN AllocatedRequest;
UINTN Size;
if (Progress == NULL || Results == NULL) {
if ((Progress == NULL) || (Results == NULL)) {
return EFI_INVALID_PARAMETER;
}
@@ -265,11 +271,12 @@ HttpBootFormExtractConfig (
// followed by "&OFFSET=0&WIDTH=WWWWWWWWWWWWWWWW" followed by a Null-terminator
//
ConfigRequestHdr = HiiConstructConfigHdr (&gHttpBootConfigGuid, mHttpBootConfigStorageName, CallbackInfo->ChildHandle);
Size = (StrLen (ConfigRequestHdr) + 32 + 1) * sizeof (CHAR16);
ConfigRequest = AllocateZeroPool (Size);
Size = (StrLen (ConfigRequestHdr) + 32 + 1) * sizeof (CHAR16);
ConfigRequest = AllocateZeroPool (Size);
if (ConfigRequest == NULL) {
return EFI_OUT_OF_RESOURCES;
}
AllocatedRequest = TRUE;
UnicodeSPrint (ConfigRequest, Size, L"%s&OFFSET=0&WIDTH=%016LX", ConfigRequestHdr, (UINT64)BufferSize);
FreePool (ConfigRequestHdr);
@@ -278,7 +285,7 @@ HttpBootFormExtractConfig (
Status = gHiiConfigRouting->BlockToConfig (
gHiiConfigRouting,
ConfigRequest,
(UINT8 *) &CallbackInfo->HttpBootNvData,
(UINT8 *)&CallbackInfo->HttpBootNvData,
BufferSize,
Results,
Progress
@@ -291,6 +298,7 @@ HttpBootFormExtractConfig (
FreePool (ConfigRequest);
ConfigRequest = NULL;
}
//
// Set Progress string to the original request string.
//
@@ -346,19 +354,20 @@ HttpBootFormExtractConfig (
EFI_STATUS
EFIAPI
HttpBootFormRouteConfig (
IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
IN CONST EFI_STRING Configuration,
OUT EFI_STRING *Progress
IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
IN CONST EFI_STRING Configuration,
OUT EFI_STRING *Progress
)
{
EFI_STATUS Status;
UINTN BufferSize;
HTTP_BOOT_FORM_CALLBACK_INFO *CallbackInfo;
HTTP_BOOT_PRIVATE_DATA *Private;
EFI_STATUS Status;
UINTN BufferSize;
HTTP_BOOT_FORM_CALLBACK_INFO *CallbackInfo;
HTTP_BOOT_PRIVATE_DATA *Private;
if (Progress == NULL) {
return EFI_INVALID_PARAMETER;
}
*Progress = Configuration;
if (Configuration == NULL) {
@@ -380,12 +389,12 @@ HttpBootFormRouteConfig (
ZeroMem (&CallbackInfo->HttpBootNvData, BufferSize);
Status = gHiiConfigRouting->ConfigToBlock (
gHiiConfigRouting,
Configuration,
(UINT8 *) &CallbackInfo->HttpBootNvData,
&BufferSize,
Progress
);
gHiiConfigRouting,
Configuration,
(UINT8 *)&CallbackInfo->HttpBootNvData,
&BufferSize,
Progress
);
if (EFI_ERROR (Status)) {
return Status;
}
@@ -431,27 +440,27 @@ HttpBootFormRouteConfig (
EFI_STATUS
EFIAPI
HttpBootFormCallback (
IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
IN EFI_BROWSER_ACTION Action,
IN EFI_QUESTION_ID QuestionId,
IN UINT8 Type,
IN OUT EFI_IFR_TYPE_VALUE *Value,
OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest
IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
IN EFI_BROWSER_ACTION Action,
IN EFI_QUESTION_ID QuestionId,
IN UINT8 Type,
IN OUT EFI_IFR_TYPE_VALUE *Value,
OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest
)
{
EFI_INPUT_KEY Key;
CHAR16 *Uri;
UINTN UriLen;
CHAR8 *AsciiUri;
HTTP_BOOT_FORM_CALLBACK_INFO *CallbackInfo;
EFI_STATUS Status;
EFI_INPUT_KEY Key;
CHAR16 *Uri;
UINTN UriLen;
CHAR8 *AsciiUri;
HTTP_BOOT_FORM_CALLBACK_INFO *CallbackInfo;
EFI_STATUS Status;
Uri = NULL;
UriLen = 0;
AsciiUri = NULL;
Status = EFI_SUCCESS;
if (This == NULL || Value == NULL) {
if ((This == NULL) || (Value == NULL)) {
return EFI_INVALID_PARAMETER;
}
@@ -462,68 +471,66 @@ HttpBootFormCallback (
}
switch (QuestionId) {
case KEY_INITIATOR_URI:
//
// Get user input URI string
//
Uri = HiiGetString (CallbackInfo->RegisteredHandle, Value->string, NULL);
if(Uri == NULL) {
return EFI_INVALID_PARAMETER;
}
case KEY_INITIATOR_URI:
//
// Get user input URI string
//
Uri = HiiGetString (CallbackInfo->RegisteredHandle, Value->string, NULL);
if (Uri == NULL) {
return EFI_INVALID_PARAMETER;
}
//
// The URI should be either an empty string (for corporate environment) ,or http(s) for home environment.
// Pop up a message box for the unsupported URI.
//
if (StrLen (Uri) != 0) {
UriLen = StrLen (Uri) + 1;
AsciiUri = AllocateZeroPool (UriLen);
if (AsciiUri == NULL) {
//
// The URI should be either an empty string (for corporate environment) ,or http(s) for home environment.
// Pop up a message box for the unsupported URI.
//
if (StrLen (Uri) != 0) {
UriLen = StrLen (Uri) + 1;
AsciiUri = AllocateZeroPool (UriLen);
if (AsciiUri == NULL) {
FreePool (Uri);
return EFI_OUT_OF_RESOURCES;
}
UnicodeStrToAsciiStrS (Uri, AsciiUri, UriLen);
Status = HttpBootCheckUriScheme (AsciiUri);
if (Status == EFI_INVALID_PARAMETER) {
DEBUG ((DEBUG_ERROR, "HttpBootFormCallback: %r.\n", Status));
CreatePopUp (
EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
&Key,
L"ERROR: Unsupported URI!",
L"Only supports HTTP and HTTPS",
NULL
);
} else if (Status == EFI_ACCESS_DENIED) {
DEBUG ((DEBUG_ERROR, "HttpBootFormCallback: %r.\n", Status));
CreatePopUp (
EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
&Key,
L"ERROR: Unsupported URI!",
L"HTTP is disabled",
NULL
);
}
}
if (Uri != NULL) {
FreePool (Uri);
return EFI_OUT_OF_RESOURCES;
}
UnicodeStrToAsciiStrS (Uri, AsciiUri, UriLen);
Status = HttpBootCheckUriScheme (AsciiUri);
if (Status == EFI_INVALID_PARAMETER) {
DEBUG ((DEBUG_ERROR, "HttpBootFormCallback: %r.\n", Status));
CreatePopUp (
EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
&Key,
L"ERROR: Unsupported URI!",
L"Only supports HTTP and HTTPS",
NULL
);
} else if (Status == EFI_ACCESS_DENIED) {
DEBUG ((DEBUG_ERROR, "HttpBootFormCallback: %r.\n", Status));
CreatePopUp (
EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
&Key,
L"ERROR: Unsupported URI!",
L"HTTP is disabled",
NULL
);
if (AsciiUri != NULL) {
FreePool (AsciiUri);
}
}
if (Uri != NULL) {
FreePool (Uri);
}
break;
if (AsciiUri != NULL) {
FreePool (AsciiUri);
}
break;
default:
break;
default:
break;
}
return Status;
@@ -540,15 +547,15 @@ HttpBootFormCallback (
**/
EFI_STATUS
HttpBootConfigFormInit (
IN HTTP_BOOT_PRIVATE_DATA *Private
IN HTTP_BOOT_PRIVATE_DATA *Private
)
{
EFI_STATUS Status;
HTTP_BOOT_FORM_CALLBACK_INFO *CallbackInfo;
VENDOR_DEVICE_PATH VendorDeviceNode;
CHAR16 *MacString;
CHAR16 *OldMenuString;
CHAR16 MenuString[128];
EFI_STATUS Status;
HTTP_BOOT_FORM_CALLBACK_INFO *CallbackInfo;
VENDOR_DEVICE_PATH VendorDeviceNode;
CHAR16 *MacString;
CHAR16 *OldMenuString;
CHAR16 MenuString[128];
CallbackInfo = &Private->CallbackInfo;
@@ -570,7 +577,7 @@ HttpBootConfigFormInit (
SetDevicePathNodeLength (&VendorDeviceNode.Header, sizeof (VENDOR_DEVICE_PATH));
CallbackInfo->HiiVendorDevicePath = AppendDevicePathNode (
Private->ParentDevicePath,
(EFI_DEVICE_PATH_PROTOCOL *) &VendorDeviceNode
(EFI_DEVICE_PATH_PROTOCOL *)&VendorDeviceNode
);
if (CallbackInfo->HiiVendorDevicePath == NULL) {
Status = EFI_OUT_OF_RESOURCES;
@@ -655,12 +662,12 @@ Error:
**/
EFI_STATUS
HttpBootConfigFormUnload (
IN HTTP_BOOT_PRIVATE_DATA *Private
IN HTTP_BOOT_PRIVATE_DATA *Private
)
{
HTTP_BOOT_FORM_CALLBACK_INFO *CallbackInfo;
HTTP_BOOT_FORM_CALLBACK_INFO *CallbackInfo;
if (Private->Ip4Nic != NULL || Private->Ip6Nic != NULL) {
if ((Private->Ip4Nic != NULL) || (Private->Ip6Nic != NULL)) {
//
// Only unload the configuration form when both IP4 and IP6 stack are stopped.
//

View File

@@ -10,13 +10,12 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#ifndef _HTTP_BOOT_CONFIG_H_
#define _HTTP_BOOT_CONFIG_H_
#include "HttpBootConfigNVDataStruc.h"
typedef struct _HTTP_BOOT_FORM_CALLBACK_INFO HTTP_BOOT_FORM_CALLBACK_INFO;
typedef struct _HTTP_BOOT_FORM_CALLBACK_INFO HTTP_BOOT_FORM_CALLBACK_INFO;
extern UINT8 HttpBootDxeStrings[];
extern UINT8 HttpBootConfigVfrBin[];
extern UINT8 HttpBootDxeStrings[];
extern UINT8 HttpBootConfigVfrBin[];
#pragma pack()
@@ -31,13 +30,13 @@ extern UINT8 HttpBootConfigVfrBin[];
)
struct _HTTP_BOOT_FORM_CALLBACK_INFO {
UINT32 Signature;
BOOLEAN Initialized;
EFI_HANDLE ChildHandle;
EFI_DEVICE_PATH_PROTOCOL *HiiVendorDevicePath;
EFI_HII_HANDLE RegisteredHandle;
EFI_HII_CONFIG_ACCESS_PROTOCOL ConfigAccess;
HTTP_BOOT_CONFIG_IFR_NVDATA HttpBootNvData;
UINT32 Signature;
BOOLEAN Initialized;
EFI_HANDLE ChildHandle;
EFI_DEVICE_PATH_PROTOCOL *HiiVendorDevicePath;
EFI_HII_HANDLE RegisteredHandle;
EFI_HII_CONFIG_ACCESS_PROTOCOL ConfigAccess;
HTTP_BOOT_CONFIG_IFR_NVDATA HttpBootNvData;
};
/**
@@ -51,7 +50,7 @@ struct _HTTP_BOOT_FORM_CALLBACK_INFO {
**/
EFI_STATUS
HttpBootConfigFormInit (
IN HTTP_BOOT_PRIVATE_DATA *Private
IN HTTP_BOOT_PRIVATE_DATA *Private
);
/**
@@ -67,7 +66,7 @@ HttpBootConfigFormInit (
**/
EFI_STATUS
HttpBootConfigFormUnload (
IN HTTP_BOOT_PRIVATE_DATA *Private
IN HTTP_BOOT_PRIVATE_DATA *Private
);
#endif

View File

@@ -11,25 +11,25 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <Guid/HttpBootConfigHii.h>
#define HTTP_BOOT_IP_VERSION_4 0
#define HTTP_BOOT_IP_VERSION_6 1
#define HTTP_BOOT_IP_VERSION_4 0
#define HTTP_BOOT_IP_VERSION_6 1
//
// Macros used for an IPv4 or an IPv6 address.
//
#define URI_STR_MIN_SIZE 0
#define URI_STR_MAX_SIZE 255
#define URI_STR_MIN_SIZE 0
#define URI_STR_MAX_SIZE 255
#define DESCRIPTION_STR_MIN_SIZE 6
#define DESCRIPTION_STR_MAX_SIZE 75
#define DESCRIPTION_STR_MIN_SIZE 6
#define DESCRIPTION_STR_MAX_SIZE 75
#define CONFIGURATION_VARSTORE_ID 0x1234
#define CONFIGURATION_VARSTORE_ID 0x1234
#define FORMID_MAIN_FORM 1
#define FORMID_MAIN_FORM 1
#define KEY_INITIATOR_URI 0x101
#define KEY_INITIATOR_URI 0x101
#define HTTP_BOOT_DEFAULT_DESCRIPTION_STR L"UEFI HTTP"
#define HTTP_BOOT_DEFAULT_DESCRIPTION_STR L"UEFI HTTP"
#pragma pack(1)
typedef struct _HTTP_BOOT_CONFIG_IFR_NVDATA {
@@ -40,5 +40,4 @@ typedef struct _HTTP_BOOT_CONFIG_IFR_NVDATA {
} HTTP_BOOT_CONFIG_IFR_NVDATA;
#pragma pack()
#endif

View File

@@ -11,7 +11,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
//
// This is a map from the interested DHCP4 option tags' index to the tag value.
//
UINT8 mInterestedDhcp4Tags[HTTP_BOOT_DHCP4_TAG_INDEX_MAX] = {
UINT8 mInterestedDhcp4Tags[HTTP_BOOT_DHCP4_TAG_INDEX_MAX] = {
DHCP4_TAG_BOOTFILE_LEN,
DHCP4_TAG_OVERLOAD,
DHCP4_TAG_MSG_TYPE,
@@ -24,7 +24,7 @@ UINT8 mInterestedDhcp4Tags[HTTP_BOOT_DHCP4_TAG_INDEX_MAX] = {
//
// There are 4 times retries with the value of 4, 8, 16 and 32, refers to UEFI 2.5 spec.
//
UINT32 mHttpDhcpTimeout[4] = {4, 8, 16, 32};
UINT32 mHttpDhcpTimeout[4] = { 4, 8, 16, 32 };
/**
Build the options buffer for the DHCPv4 request packet.
@@ -38,9 +38,9 @@ UINT32 mHttpDhcpTimeout[4] = {4, 8, 16, 32};
**/
UINT32
HttpBootBuildDhcp4Options (
IN HTTP_BOOT_PRIVATE_DATA *Private,
OUT EFI_DHCP4_PACKET_OPTION **OptList,
IN UINT8 *Buffer
IN HTTP_BOOT_PRIVATE_DATA *Private,
OUT EFI_DHCP4_PACKET_OPTION **OptList,
IN UINT8 *Buffer
)
{
HTTP_BOOT_DHCP4_OPTION_ENTRY OptEnt;
@@ -48,14 +48,14 @@ HttpBootBuildDhcp4Options (
UINT32 Index;
Index = 0;
OptList[0] = (EFI_DHCP4_PACKET_OPTION *) Buffer;
OptList[0] = (EFI_DHCP4_PACKET_OPTION *)Buffer;
//
// Append parameter request list option.
//
OptList[Index]->OpCode = DHCP4_TAG_PARA_LIST;
OptList[Index]->Length = 27;
OptEnt.Para = (HTTP_BOOT_DHCP4_OPTION_PARA *) OptList[Index]->Data;
OptEnt.Para = (HTTP_BOOT_DHCP4_OPTION_PARA *)OptList[Index]->Data;
OptEnt.Para->ParaList[0] = DHCP4_TAG_NETMASK;
OptEnt.Para->ParaList[1] = DHCP4_TAG_TIME_OFFSET;
OptEnt.Para->ParaList[2] = DHCP4_TAG_ROUTER;
@@ -83,30 +83,31 @@ HttpBootBuildDhcp4Options (
OptEnt.Para->ParaList[25] = DHCP4_TAG_BOOTFILE;
OptEnt.Para->ParaList[26] = DHCP4_TAG_UUID;
Index++;
OptList[Index] = GET_NEXT_DHCP_OPTION (OptList[Index - 1]);
OptList[Index] = GET_NEXT_DHCP_OPTION (OptList[Index - 1]);
//
// Append UUID/Guid-based client identifier option
//
OptList[Index]->OpCode = DHCP4_TAG_UUID;
OptList[Index]->Length = (UINT8) sizeof (HTTP_BOOT_DHCP4_OPTION_UUID);
OptEnt.Uuid = (HTTP_BOOT_DHCP4_OPTION_UUID *) OptList[Index]->Data;
OptEnt.Uuid->Type = 0;
if (EFI_ERROR (NetLibGetSystemGuid ((EFI_GUID *) OptEnt.Uuid->Guid))) {
OptList[Index]->OpCode = DHCP4_TAG_UUID;
OptList[Index]->Length = (UINT8)sizeof (HTTP_BOOT_DHCP4_OPTION_UUID);
OptEnt.Uuid = (HTTP_BOOT_DHCP4_OPTION_UUID *)OptList[Index]->Data;
OptEnt.Uuid->Type = 0;
if (EFI_ERROR (NetLibGetSystemGuid ((EFI_GUID *)OptEnt.Uuid->Guid))) {
//
// Zero the Guid to indicate NOT programmable if failed to get system Guid.
//
ZeroMem (OptEnt.Uuid->Guid, sizeof (EFI_GUID));
}
Index++;
OptList[Index] = GET_NEXT_DHCP_OPTION (OptList[Index - 1]);
OptList[Index] = GET_NEXT_DHCP_OPTION (OptList[Index - 1]);
//
// Append client network device interface option
//
OptList[Index]->OpCode = DHCP4_TAG_UNDI;
OptList[Index]->Length = (UINT8) sizeof (HTTP_BOOT_DHCP4_OPTION_UNDI);
OptEnt.Undi = (HTTP_BOOT_DHCP4_OPTION_UNDI *) OptList[Index]->Data;
OptList[Index]->OpCode = DHCP4_TAG_UNDI;
OptList[Index]->Length = (UINT8)sizeof (HTTP_BOOT_DHCP4_OPTION_UNDI);
OptEnt.Undi = (HTTP_BOOT_DHCP4_OPTION_UNDI *)OptList[Index]->Data;
if (Private->Nii != NULL) {
OptEnt.Undi->Type = Private->Nii->Type;
@@ -124,20 +125,20 @@ HttpBootBuildDhcp4Options (
//
// Append client system architecture option
//
OptList[Index]->OpCode = DHCP4_TAG_ARCH;
OptList[Index]->Length = (UINT8) sizeof (HTTP_BOOT_DHCP4_OPTION_ARCH);
OptEnt.Arch = (HTTP_BOOT_DHCP4_OPTION_ARCH *) OptList[Index]->Data;
Value = HTONS (EFI_HTTP_BOOT_CLIENT_SYSTEM_ARCHITECTURE);
OptList[Index]->OpCode = DHCP4_TAG_ARCH;
OptList[Index]->Length = (UINT8)sizeof (HTTP_BOOT_DHCP4_OPTION_ARCH);
OptEnt.Arch = (HTTP_BOOT_DHCP4_OPTION_ARCH *)OptList[Index]->Data;
Value = HTONS (EFI_HTTP_BOOT_CLIENT_SYSTEM_ARCHITECTURE);
CopyMem (&OptEnt.Arch->Type, &Value, sizeof (UINT16));
Index++;
OptList[Index] = GET_NEXT_DHCP_OPTION (OptList[Index - 1]);
OptList[Index] = GET_NEXT_DHCP_OPTION (OptList[Index - 1]);
//
// Append vendor class identify option
//
OptList[Index]->OpCode = DHCP4_TAG_VENDOR_CLASS_ID;
OptList[Index]->Length = (UINT8) sizeof (HTTP_BOOT_DHCP4_OPTION_CLID);
OptEnt.Clid = (HTTP_BOOT_DHCP4_OPTION_CLID *) OptList[Index]->Data;
OptList[Index]->OpCode = DHCP4_TAG_VENDOR_CLASS_ID;
OptList[Index]->Length = (UINT8)sizeof (HTTP_BOOT_DHCP4_OPTION_CLID);
OptEnt.Clid = (HTTP_BOOT_DHCP4_OPTION_CLID *)OptList[Index]->Data;
CopyMem (
OptEnt.Clid,
DEFAULT_CLASS_ID_DATA,
@@ -173,19 +174,18 @@ HttpBootBuildDhcp4Options (
**/
EFI_DHCP4_PACKET_OPTION *
HttpBootParseDhcp4Options (
IN UINT8 *Buffer,
IN UINT32 Length,
IN UINT8 OptTag
IN UINT8 *Buffer,
IN UINT32 Length,
IN UINT8 OptTag
)
{
EFI_DHCP4_PACKET_OPTION *Option;
UINT32 Offset;
EFI_DHCP4_PACKET_OPTION *Option;
UINT32 Offset;
Option = (EFI_DHCP4_PACKET_OPTION *) Buffer;
Offset = 0;
Option = (EFI_DHCP4_PACKET_OPTION *)Buffer;
Offset = 0;
while (Offset < Length && Option->OpCode != DHCP4_TAG_EOP) {
if (Option->OpCode == OptTag) {
//
// Found the required option.
@@ -202,7 +202,7 @@ HttpBootParseDhcp4Options (
Offset += Option->Length + 2;
}
Option = (EFI_DHCP4_PACKET_OPTION *) (Buffer + Offset);
Option = (EFI_DHCP4_PACKET_OPTION *)(Buffer + Offset);
}
return NULL;
@@ -220,8 +220,8 @@ HttpBootParseDhcp4Options (
**/
EFI_STATUS
HttpBootCacheDhcp4Packet (
IN EFI_DHCP4_PACKET *Dst,
IN EFI_DHCP4_PACKET *Src
IN EFI_DHCP4_PACKET *Dst,
IN EFI_DHCP4_PACKET *Src
)
{
if (Dst->Size < Src->Length) {
@@ -245,27 +245,27 @@ HttpBootCacheDhcp4Packet (
**/
EFI_STATUS
HttpBootParseDhcp4Packet (
IN HTTP_BOOT_DHCP4_PACKET_CACHE *Cache4
IN HTTP_BOOT_DHCP4_PACKET_CACHE *Cache4
)
{
EFI_DHCP4_PACKET *Offer;
EFI_DHCP4_PACKET_OPTION **Options;
UINTN Index;
EFI_DHCP4_PACKET_OPTION *Option;
BOOLEAN IsProxyOffer;
BOOLEAN IsHttpOffer;
BOOLEAN IsDnsOffer;
BOOLEAN IpExpressedUri;
UINT8 *Ptr8;
EFI_STATUS Status;
HTTP_BOOT_OFFER_TYPE OfferType;
EFI_IPv4_ADDRESS IpAddr;
BOOLEAN FileFieldOverloaded;
EFI_DHCP4_PACKET *Offer;
EFI_DHCP4_PACKET_OPTION **Options;
UINTN Index;
EFI_DHCP4_PACKET_OPTION *Option;
BOOLEAN IsProxyOffer;
BOOLEAN IsHttpOffer;
BOOLEAN IsDnsOffer;
BOOLEAN IpExpressedUri;
UINT8 *Ptr8;
EFI_STATUS Status;
HTTP_BOOT_OFFER_TYPE OfferType;
EFI_IPv4_ADDRESS IpAddr;
BOOLEAN FileFieldOverloaded;
IsDnsOffer = FALSE;
IpExpressedUri = FALSE;
IsProxyOffer = FALSE;
IsHttpOffer = FALSE;
IsDnsOffer = FALSE;
IpExpressedUri = FALSE;
IsProxyOffer = FALSE;
IsHttpOffer = FALSE;
FileFieldOverloaded = FALSE;
ZeroMem (Cache4->OptList, sizeof (Cache4->OptList));
@@ -284,6 +284,7 @@ HttpBootParseDhcp4Packet (
mInterestedDhcp4Tags[Index]
);
}
//
// Second, Check if bootfilename and serverhostname is overloaded to carry DHCP options refers to rfc-2132.
// If yes, try to parse options from the BootFileName field, then ServerName field.
@@ -295,18 +296,19 @@ HttpBootParseDhcp4Packet (
for (Index = 0; Index < HTTP_BOOT_DHCP4_TAG_INDEX_MAX; Index++) {
if (Options[Index] == NULL) {
Options[Index] = HttpBootParseDhcp4Options (
(UINT8 *) Offer->Dhcp4.Header.BootFileName,
(UINT8 *)Offer->Dhcp4.Header.BootFileName,
sizeof (Offer->Dhcp4.Header.BootFileName),
mInterestedDhcp4Tags[Index]
);
}
}
}
if ((Option->Data[0] & HTTP_BOOT_DHCP4_OVERLOAD_SERVER_NAME) != 0) {
for (Index = 0; Index < HTTP_BOOT_DHCP4_TAG_INDEX_MAX; Index++) {
if (Options[Index] == NULL) {
Options[Index] = HttpBootParseDhcp4Options (
(UINT8 *) Offer->Dhcp4.Header.ServerName,
(UINT8 *)Offer->Dhcp4.Header.ServerName,
sizeof (Offer->Dhcp4.Header.ServerName),
mInterestedDhcp4Tags[Index]
);
@@ -327,7 +329,8 @@ HttpBootParseDhcp4Packet (
//
Option = Options[HTTP_BOOT_DHCP4_TAG_INDEX_CLASS_ID];
if ((Option != NULL) && (Option->Length >= 10) &&
(CompareMem (Option->Data, DEFAULT_CLASS_ID_DATA, 10) == 0)) {
(CompareMem (Option->Data, DEFAULT_CLASS_ID_DATA, 10) == 0))
{
IsHttpOffer = TRUE;
}
@@ -350,25 +353,25 @@ HttpBootParseDhcp4Packet (
// RFC 2132, Section 9.5 does not strictly state Bootfile name (option 67) is null
// terminated string. So force to append null terminated character at the end of string.
//
Ptr8 = (UINT8*)&Options[HTTP_BOOT_DHCP4_TAG_INDEX_BOOTFILE]->Data[0];
Ptr8 = (UINT8 *)&Options[HTTP_BOOT_DHCP4_TAG_INDEX_BOOTFILE]->Data[0];
Ptr8 += Options[HTTP_BOOT_DHCP4_TAG_INDEX_BOOTFILE]->Length;
if (*(Ptr8 - 1) != '\0') {
*Ptr8 = '\0';
}
} else if (!FileFieldOverloaded && Offer->Dhcp4.Header.BootFileName[0] != 0) {
} else if (!FileFieldOverloaded && (Offer->Dhcp4.Header.BootFileName[0] != 0)) {
//
// If the bootfile is not present and bootfilename is present in DHCPv4 packet, just parse it.
// Do not count dhcp option header here, or else will destroy the serverhostname.
//
Options[HTTP_BOOT_DHCP4_TAG_INDEX_BOOTFILE] = (EFI_DHCP4_PACKET_OPTION *)
(&Offer->Dhcp4.Header.BootFileName[0] -
OFFSET_OF (EFI_DHCP4_PACKET_OPTION, Data[0]));
(&Offer->Dhcp4.Header.BootFileName[0] -
OFFSET_OF (EFI_DHCP4_PACKET_OPTION, Data[0]));
}
//
// Http offer must have a boot URI.
//
if (IsHttpOffer && Options[HTTP_BOOT_DHCP4_TAG_INDEX_BOOTFILE] == NULL) {
if (IsHttpOffer && (Options[HTTP_BOOT_DHCP4_TAG_INDEX_BOOTFILE] == NULL)) {
return EFI_DEVICE_ERROR;
}
@@ -377,8 +380,8 @@ HttpBootParseDhcp4Packet (
//
if (IsHttpOffer) {
Status = HttpParseUrl (
(CHAR8*) Options[HTTP_BOOT_DHCP4_TAG_INDEX_BOOTFILE]->Data,
(UINT32) AsciiStrLen ((CHAR8*) Options[HTTP_BOOT_DHCP4_TAG_INDEX_BOOTFILE]->Data),
(CHAR8 *)Options[HTTP_BOOT_DHCP4_TAG_INDEX_BOOTFILE]->Data,
(UINT32)AsciiStrLen ((CHAR8 *)Options[HTTP_BOOT_DHCP4_TAG_INDEX_BOOTFILE]->Data),
FALSE,
&Cache4->UriParser
);
@@ -387,7 +390,7 @@ HttpBootParseDhcp4Packet (
}
Status = HttpUrlGetIp4 (
(CHAR8*) Options[HTTP_BOOT_DHCP4_TAG_INDEX_BOOTFILE]->Data,
(CHAR8 *)Options[HTTP_BOOT_DHCP4_TAG_INDEX_BOOTFILE]->Data,
Cache4->UriParser,
&IpAddr
);
@@ -411,7 +414,6 @@ HttpBootParseDhcp4Packet (
OfferType = HttpOfferTypeProxyNameUri;
}
}
} else {
if (!IsProxyOffer) {
OfferType = IsDnsOffer ? HttpOfferTypeDhcpDns : HttpOfferTypeDhcpOnly;
@@ -419,6 +421,7 @@ HttpBootParseDhcp4Packet (
if (Cache4->UriParser != NULL) {
FreePool (Cache4->UriParser);
}
return EFI_DEVICE_ERROR;
}
}
@@ -490,7 +493,7 @@ HttpBootSelectDhcpOffer (
IN HTTP_BOOT_PRIVATE_DATA *Private
)
{
Private->SelectIndex = 0;
Private->SelectIndex = 0;
Private->SelectProxyType = HttpOfferTypeMax;
if (Private->FilePathUri != NULL) {
@@ -500,26 +503,16 @@ HttpBootSelectDhcpOffer (
// The offer with DNS server address takes priority here.
//
if (Private->OfferCount[HttpOfferTypeDhcpDns] > 0) {
Private->SelectIndex = Private->OfferIndex[HttpOfferTypeDhcpDns][0] + 1;
} else if (Private->OfferCount[HttpOfferTypeDhcpIpUriDns] > 0) {
Private->SelectIndex = Private->OfferIndex[HttpOfferTypeDhcpIpUriDns][0] + 1;
} else if (Private->OfferCount[HttpOfferTypeDhcpNameUriDns] > 0) {
Private->SelectIndex = Private->OfferIndex[HttpOfferTypeDhcpNameUriDns][0] + 1;
} else if (Private->OfferCount[HttpOfferTypeDhcpOnly] > 0) {
} else if (Private->OfferCount[HttpOfferTypeDhcpOnly] > 0) {
Private->SelectIndex = Private->OfferIndex[HttpOfferTypeDhcpOnly][0] + 1;
} else if (Private->OfferCount[HttpOfferTypeDhcpIpUri] > 0) {
} else if (Private->OfferCount[HttpOfferTypeDhcpIpUri] > 0) {
Private->SelectIndex = Private->OfferIndex[HttpOfferTypeDhcpIpUri][0] + 1;
}
} else {
//
// We are in corporate environment.
@@ -532,45 +525,35 @@ HttpBootSelectDhcpOffer (
// Priority6: HttpOfferTypeDhcpDns + HttpOfferTypeDhcpNameUri
//
if (Private->OfferCount[HttpOfferTypeDhcpIpUri] > 0) {
Private->SelectIndex = Private->OfferIndex[HttpOfferTypeDhcpIpUri][0] + 1;
} else if (Private->OfferCount[HttpOfferTypeDhcpIpUriDns] > 0) {
Private->SelectIndex = Private->OfferIndex[HttpOfferTypeDhcpIpUriDns][0] + 1;
}else if (Private->OfferCount[HttpOfferTypeDhcpNameUriDns] > 0) {
} else if (Private->OfferCount[HttpOfferTypeDhcpNameUriDns] > 0) {
Private->SelectIndex = Private->OfferIndex[HttpOfferTypeDhcpNameUriDns][0] + 1;
} else if (Private->OfferCount[HttpOfferTypeDhcpOnly] > 0 &&
Private->OfferCount[HttpOfferTypeProxyIpUri] > 0) {
} else if ((Private->OfferCount[HttpOfferTypeDhcpOnly] > 0) &&
(Private->OfferCount[HttpOfferTypeProxyIpUri] > 0))
{
Private->SelectIndex = Private->OfferIndex[HttpOfferTypeDhcpOnly][0] + 1;
Private->SelectProxyType = HttpOfferTypeProxyIpUri;
} else if (Private->OfferCount[HttpOfferTypeDhcpDns] > 0 &&
Private->OfferCount[HttpOfferTypeProxyIpUri] > 0) {
} else if ((Private->OfferCount[HttpOfferTypeDhcpDns] > 0) &&
(Private->OfferCount[HttpOfferTypeProxyIpUri] > 0))
{
Private->SelectIndex = Private->OfferIndex[HttpOfferTypeDhcpDns][0] + 1;
Private->SelectProxyType = HttpOfferTypeProxyIpUri;
} else if (Private->OfferCount[HttpOfferTypeDhcpDns] > 0 &&
Private->OfferCount[HttpOfferTypeProxyNameUri] > 0) {
} else if ((Private->OfferCount[HttpOfferTypeDhcpDns] > 0) &&
(Private->OfferCount[HttpOfferTypeProxyNameUri] > 0))
{
Private->SelectIndex = Private->OfferIndex[HttpOfferTypeDhcpDns][0] + 1;
Private->SelectProxyType = HttpOfferTypeProxyNameUri;
} else if (Private->OfferCount[HttpOfferTypeDhcpDns] > 0 &&
Private->OfferCount[HttpOfferTypeDhcpNameUri] > 0) {
} else if ((Private->OfferCount[HttpOfferTypeDhcpDns] > 0) &&
(Private->OfferCount[HttpOfferTypeDhcpNameUri] > 0))
{
Private->SelectIndex = Private->OfferIndex[HttpOfferTypeDhcpDns][0] + 1;
Private->SelectProxyType = HttpOfferTypeDhcpNameUri;
}
}
}
/**
EFI_DHCP4_CALLBACK is provided by the consumer of the EFI DHCPv4 Protocol driver
to intercept events that occurred in the configuration process.
@@ -594,29 +577,30 @@ HttpBootSelectDhcpOffer (
EFI_STATUS
EFIAPI
HttpBootDhcp4CallBack (
IN EFI_DHCP4_PROTOCOL *This,
IN VOID *Context,
IN EFI_DHCP4_STATE CurrentState,
IN EFI_DHCP4_EVENT Dhcp4Event,
IN EFI_DHCP4_PACKET *Packet OPTIONAL,
OUT EFI_DHCP4_PACKET **NewPacket OPTIONAL
IN EFI_DHCP4_PROTOCOL *This,
IN VOID *Context,
IN EFI_DHCP4_STATE CurrentState,
IN EFI_DHCP4_EVENT Dhcp4Event,
IN EFI_DHCP4_PACKET *Packet OPTIONAL,
OUT EFI_DHCP4_PACKET **NewPacket OPTIONAL
)
{
HTTP_BOOT_PRIVATE_DATA *Private;
EFI_DHCP4_PACKET_OPTION *MaxMsgSize;
UINT16 Value;
EFI_STATUS Status;
BOOLEAN Received;
HTTP_BOOT_PRIVATE_DATA *Private;
EFI_DHCP4_PACKET_OPTION *MaxMsgSize;
UINT16 Value;
EFI_STATUS Status;
BOOLEAN Received;
if ((Dhcp4Event != Dhcp4SendDiscover) &&
(Dhcp4Event != Dhcp4RcvdOffer) &&
(Dhcp4Event != Dhcp4SendRequest) &&
(Dhcp4Event != Dhcp4RcvdAck) &&
(Dhcp4Event != Dhcp4SelectOffer)) {
(Dhcp4Event != Dhcp4SelectOffer))
{
return EFI_SUCCESS;
}
Private = (HTTP_BOOT_PRIVATE_DATA *) Context;
Private = (HTTP_BOOT_PRIVATE_DATA *)Context;
//
// Override the Maximum DHCP Message Size.
@@ -634,15 +618,15 @@ HttpBootDhcp4CallBack (
//
// Callback to user if any packets sent or received.
//
if (Private->HttpBootCallback != NULL && Dhcp4Event != Dhcp4SelectOffer) {
Received = (BOOLEAN) (Dhcp4Event == Dhcp4RcvdOffer || Dhcp4Event == Dhcp4RcvdAck);
Status = Private->HttpBootCallback->Callback (
Private->HttpBootCallback,
HttpBootDhcp4,
Received,
Packet->Length,
&Packet->Dhcp4
);
if ((Private->HttpBootCallback != NULL) && (Dhcp4Event != Dhcp4SelectOffer)) {
Received = (BOOLEAN)(Dhcp4Event == Dhcp4RcvdOffer || Dhcp4Event == Dhcp4RcvdAck);
Status = Private->HttpBootCallback->Callback (
Private->HttpBootCallback,
HttpBootDhcp4,
Received,
Packet->Length,
&Packet->Dhcp4
);
if (EFI_ERROR (Status)) {
return EFI_ABORTED;
}
@@ -650,40 +634,43 @@ HttpBootDhcp4CallBack (
Status = EFI_SUCCESS;
switch (Dhcp4Event) {
case Dhcp4RcvdOffer:
Status = EFI_NOT_READY;
if (Packet->Length > HTTP_BOOT_DHCP4_PACKET_MAX_SIZE) {
//
// Ignore the incoming packets which exceed the maximum length.
//
case Dhcp4RcvdOffer:
Status = EFI_NOT_READY;
if (Packet->Length > HTTP_BOOT_DHCP4_PACKET_MAX_SIZE) {
//
// Ignore the incoming packets which exceed the maximum length.
//
break;
}
if (Private->OfferNum < HTTP_BOOT_OFFER_MAX_NUM) {
//
// Cache the DHCPv4 offers to OfferBuffer[] for select later, and record
// the OfferIndex and OfferCount.
// If error happens, just ignore this packet and continue to wait more offer.
//
HttpBootCacheDhcp4Offer (Private, Packet);
}
break;
}
if (Private->OfferNum < HTTP_BOOT_OFFER_MAX_NUM) {
case Dhcp4SelectOffer:
//
// Cache the DHCPv4 offers to OfferBuffer[] for select later, and record
// the OfferIndex and OfferCount.
// If error happens, just ignore this packet and continue to wait more offer.
// Select offer according to the priority in UEFI spec, and record the SelectIndex
// and SelectProxyType.
//
HttpBootCacheDhcp4Offer (Private, Packet);
}
break;
HttpBootSelectDhcpOffer (Private);
case Dhcp4SelectOffer:
//
// Select offer according to the priority in UEFI spec, and record the SelectIndex
// and SelectProxyType.
//
HttpBootSelectDhcpOffer (Private);
if (Private->SelectIndex == 0) {
Status = EFI_ABORTED;
} else {
*NewPacket = &Private->OfferBuffer[Private->SelectIndex - 1].Dhcp4.Packet.Offer;
}
if (Private->SelectIndex == 0) {
Status = EFI_ABORTED;
} else {
*NewPacket = &Private->OfferBuffer[Private->SelectIndex - 1].Dhcp4.Packet.Offer;
}
break;
break;
default:
break;
default:
break;
}
return Status;
@@ -700,11 +687,11 @@ HttpBootDhcp4CallBack (
**/
EFI_STATUS
HttpBootRegisterIp4Gateway (
IN HTTP_BOOT_PRIVATE_DATA *Private
IN HTTP_BOOT_PRIVATE_DATA *Private
)
{
EFI_STATUS Status;
EFI_IP4_CONFIG2_PROTOCOL *Ip4Config2;
EFI_STATUS Status;
EFI_IP4_CONFIG2_PROTOCOL *Ip4Config2;
ASSERT (!Private->UsingIpv6);
@@ -742,12 +729,12 @@ HttpBootRegisterIp4Gateway (
**/
EFI_STATUS
HttpBootRegisterIp4Dns (
IN HTTP_BOOT_PRIVATE_DATA *Private,
IN UINTN DataLength,
IN VOID *DnsServerData
IN HTTP_BOOT_PRIVATE_DATA *Private,
IN UINTN DataLength,
IN VOID *DnsServerData
)
{
EFI_IP4_CONFIG2_PROTOCOL *Ip4Config2;
EFI_IP4_CONFIG2_PROTOCOL *Ip4Config2;
ASSERT (!Private->UsingIpv6);
@@ -761,7 +748,6 @@ HttpBootRegisterIp4Dns (
);
}
/**
This function will switch the IP4 configuration policy to Static.
@@ -773,35 +759,35 @@ HttpBootRegisterIp4Dns (
**/
EFI_STATUS
HttpBootSetIp4Policy (
IN HTTP_BOOT_PRIVATE_DATA *Private
IN HTTP_BOOT_PRIVATE_DATA *Private
)
{
EFI_IP4_CONFIG2_POLICY Policy;
EFI_STATUS Status;
EFI_IP4_CONFIG2_PROTOCOL *Ip4Config2;
UINTN DataSize;
EFI_IP4_CONFIG2_POLICY Policy;
EFI_STATUS Status;
EFI_IP4_CONFIG2_PROTOCOL *Ip4Config2;
UINTN DataSize;
Ip4Config2 = Private->Ip4Config2;
DataSize = sizeof (EFI_IP4_CONFIG2_POLICY);
Status = Ip4Config2->GetData (
Ip4Config2,
Ip4Config2DataTypePolicy,
&DataSize,
&Policy
);
Status = Ip4Config2->GetData (
Ip4Config2,
Ip4Config2DataTypePolicy,
&DataSize,
&Policy
);
if (EFI_ERROR (Status)) {
return Status;
}
if (Policy != Ip4Config2PolicyStatic) {
Policy = Ip4Config2PolicyStatic;
Status= Ip4Config2->SetData (
Ip4Config2,
Ip4Config2DataTypePolicy,
sizeof (EFI_IP4_CONFIG2_POLICY),
&Policy
);
Status = Ip4Config2->SetData (
Ip4Config2,
Ip4Config2DataTypePolicy,
sizeof (EFI_IP4_CONFIG2_POLICY),
&Policy
);
if (EFI_ERROR (Status)) {
return Status;
}
@@ -821,16 +807,16 @@ HttpBootSetIp4Policy (
**/
EFI_STATUS
HttpBootDhcp4Dora (
IN HTTP_BOOT_PRIVATE_DATA *Private
IN HTTP_BOOT_PRIVATE_DATA *Private
)
{
EFI_DHCP4_PROTOCOL *Dhcp4;
UINT32 OptCount;
EFI_DHCP4_PACKET_OPTION *OptList[HTTP_BOOT_DHCP4_OPTION_MAX_NUM];
UINT8 Buffer[HTTP_BOOT_DHCP4_OPTION_MAX_SIZE];
EFI_DHCP4_CONFIG_DATA Config;
EFI_STATUS Status;
EFI_DHCP4_MODE_DATA Mode;
EFI_DHCP4_PROTOCOL *Dhcp4;
UINT32 OptCount;
EFI_DHCP4_PACKET_OPTION *OptList[HTTP_BOOT_DHCP4_OPTION_MAX_NUM];
UINT8 Buffer[HTTP_BOOT_DHCP4_OPTION_MAX_SIZE];
EFI_DHCP4_CONFIG_DATA Config;
EFI_STATUS Status;
EFI_DHCP4_MODE_DATA Mode;
Dhcp4 = Private->Dhcp4;
ASSERT (Dhcp4 != NULL);
@@ -846,7 +832,7 @@ HttpBootDhcp4Dora (
OptCount = HttpBootBuildDhcp4Options (Private, OptList, Buffer);
ASSERT (OptCount > 0);
ZeroMem (&Config, sizeof(Config));
ZeroMem (&Config, sizeof (Config));
Config.OptionCount = OptCount;
Config.OptionList = OptList;
Config.Dhcp4Callback = HttpBootDhcp4CallBack;

View File

@@ -10,17 +10,17 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#ifndef __EFI_UEFI_HTTP_BOOT_DHCP4_H__
#define __EFI_UEFI_HTTP_BOOT_DHCP4_H__
#define HTTP_BOOT_DHCP4_OPTION_MAX_NUM 16
#define HTTP_BOOT_DHCP4_OPTION_MAX_SIZE 312
#define HTTP_BOOT_DHCP4_PACKET_MAX_SIZE 1472
#define HTTP_BOOT_DHCP4_OPTION_MAX_NUM 16
#define HTTP_BOOT_DHCP4_OPTION_MAX_SIZE 312
#define HTTP_BOOT_DHCP4_PACKET_MAX_SIZE 1472
#define HTTP_BOOT_DHCP4_OPCODE_REQUEST 1
#define HTTP_BOOT_DHCP4_OPCODE_REPLY 2
#define HTTP_BOOT_DHCP4_MSG_TYPE_REQUEST 3
#define HTTP_BOOT_DHCP4_MAGIC 0x63538263 // network byte order
#define HTTP_BOOT_DHCP4_OPCODE_REQUEST 1
#define HTTP_BOOT_DHCP4_OPCODE_REPLY 2
#define HTTP_BOOT_DHCP4_MSG_TYPE_REQUEST 3
#define HTTP_BOOT_DHCP4_MAGIC 0x63538263 // network byte order
#define HTTP_BOOT_DHCP4_OVERLOAD_FILE 1
#define HTTP_BOOT_DHCP4_OVERLOAD_SERVER_NAME 2
#define HTTP_BOOT_DHCP4_OVERLOAD_FILE 1
#define HTTP_BOOT_DHCP4_OVERLOAD_SERVER_NAME 2
///
/// HTTP Tag definition that identifies the processor
@@ -29,17 +29,17 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
/// http://www.ietf.org/assignments/dhcpv6-parameters/dhcpv6-parameters.xml
///
#if defined (MDE_CPU_IA32)
#define EFI_HTTP_BOOT_CLIENT_SYSTEM_ARCHITECTURE HTTP_CLIENT_ARCH_IA32
#define EFI_HTTP_BOOT_CLIENT_SYSTEM_ARCHITECTURE HTTP_CLIENT_ARCH_IA32
#elif defined (MDE_CPU_X64)
#define EFI_HTTP_BOOT_CLIENT_SYSTEM_ARCHITECTURE HTTP_CLIENT_ARCH_X64
#define EFI_HTTP_BOOT_CLIENT_SYSTEM_ARCHITECTURE HTTP_CLIENT_ARCH_X64
#elif defined (MDE_CPU_ARM)
#define EFI_HTTP_BOOT_CLIENT_SYSTEM_ARCHITECTURE HTTP_CLIENT_ARCH_ARM
#define EFI_HTTP_BOOT_CLIENT_SYSTEM_ARCHITECTURE HTTP_CLIENT_ARCH_ARM
#elif defined (MDE_CPU_AARCH64)
#define EFI_HTTP_BOOT_CLIENT_SYSTEM_ARCHITECTURE HTTP_CLIENT_ARCH_AARCH64
#define EFI_HTTP_BOOT_CLIENT_SYSTEM_ARCHITECTURE HTTP_CLIENT_ARCH_AARCH64
#elif defined (MDE_CPU_RISCV64)
#define EFI_HTTP_BOOT_CLIENT_SYSTEM_ARCHITECTURE HTTP_CLIENT_ARCH_RISCV64
#define EFI_HTTP_BOOT_CLIENT_SYSTEM_ARCHITECTURE HTTP_CLIENT_ARCH_RISCV64
#elif defined (MDE_CPU_EBC)
#define EFI_HTTP_BOOT_CLIENT_SYSTEM_ARCHITECTURE HTTP_CLIENT_ARCH_EBC
#define EFI_HTTP_BOOT_CLIENT_SYSTEM_ARCHITECTURE HTTP_CLIENT_ARCH_EBC
#endif
/// DHCP offer types among HTTP boot.
@@ -88,75 +88,75 @@ typedef enum {
HttpOfferTypeMax
} HTTP_BOOT_OFFER_TYPE;
#define HTTP_BOOT_DHCP_RETRIES 4
#define HTTP_BOOT_OFFER_MAX_NUM 16
#define HTTP_BOOT_DHCP_RETRIES 4
#define HTTP_BOOT_OFFER_MAX_NUM 16
// The array index of the DHCP4 option tag interested
//
#define HTTP_BOOT_DHCP4_TAG_INDEX_BOOTFILE_LEN 0
#define HTTP_BOOT_DHCP4_TAG_INDEX_OVERLOAD 1
#define HTTP_BOOT_DHCP4_TAG_INDEX_MSG_TYPE 2
#define HTTP_BOOT_DHCP4_TAG_INDEX_SERVER_ID 3
#define HTTP_BOOT_DHCP4_TAG_INDEX_CLASS_ID 4
#define HTTP_BOOT_DHCP4_TAG_INDEX_BOOTFILE 5
#define HTTP_BOOT_DHCP4_TAG_INDEX_DNS_SERVER 6
#define HTTP_BOOT_DHCP4_TAG_INDEX_MAX 7
#define HTTP_BOOT_DHCP4_TAG_INDEX_BOOTFILE_LEN 0
#define HTTP_BOOT_DHCP4_TAG_INDEX_OVERLOAD 1
#define HTTP_BOOT_DHCP4_TAG_INDEX_MSG_TYPE 2
#define HTTP_BOOT_DHCP4_TAG_INDEX_SERVER_ID 3
#define HTTP_BOOT_DHCP4_TAG_INDEX_CLASS_ID 4
#define HTTP_BOOT_DHCP4_TAG_INDEX_BOOTFILE 5
#define HTTP_BOOT_DHCP4_TAG_INDEX_DNS_SERVER 6
#define HTTP_BOOT_DHCP4_TAG_INDEX_MAX 7
#pragma pack(1)
typedef struct {
UINT8 ParaList[135];
UINT8 ParaList[135];
} HTTP_BOOT_DHCP4_OPTION_PARA;
typedef struct {
UINT16 Size;
UINT16 Size;
} HTTP_BOOT_DHCP4_OPTION_MAX_MESG_SIZE;
typedef struct {
UINT8 Type;
UINT8 MajorVer;
UINT8 MinorVer;
UINT8 Type;
UINT8 MajorVer;
UINT8 MinorVer;
} HTTP_BOOT_DHCP4_OPTION_UNDI;
typedef struct {
UINT8 Type;
UINT8 Type;
} HTTP_BOOT_DHCP4_OPTION_MESG;
typedef struct {
UINT16 Type;
UINT16 Type;
} HTTP_BOOT_DHCP4_OPTION_ARCH;
typedef struct {
UINT8 ClassIdentifier[11];
UINT8 ArchitecturePrefix[5];
UINT8 ArchitectureType[5];
UINT8 Lit3[1];
UINT8 InterfaceName[4];
UINT8 Lit4[1];
UINT8 UndiMajor[3];
UINT8 UndiMinor[3];
UINT8 ClassIdentifier[11];
UINT8 ArchitecturePrefix[5];
UINT8 ArchitectureType[5];
UINT8 Lit3[1];
UINT8 InterfaceName[4];
UINT8 Lit4[1];
UINT8 UndiMajor[3];
UINT8 UndiMinor[3];
} HTTP_BOOT_DHCP4_OPTION_CLID;
typedef struct {
UINT8 Type;
UINT8 Guid[16];
UINT8 Type;
UINT8 Guid[16];
} HTTP_BOOT_DHCP4_OPTION_UUID;
typedef struct {
UINT16 Type;
UINT16 Layer;
UINT16 Type;
UINT16 Layer;
} HTTP_BOOT_OPTION_BOOT_ITEM;
#pragma pack()
typedef union {
HTTP_BOOT_DHCP4_OPTION_PARA *Para;
HTTP_BOOT_DHCP4_OPTION_UNDI *Undi;
HTTP_BOOT_DHCP4_OPTION_ARCH *Arch;
HTTP_BOOT_DHCP4_OPTION_CLID *Clid;
HTTP_BOOT_DHCP4_OPTION_UUID *Uuid;
HTTP_BOOT_DHCP4_OPTION_MESG *Mesg;
HTTP_BOOT_DHCP4_OPTION_MAX_MESG_SIZE *MaxMesgSize;
HTTP_BOOT_DHCP4_OPTION_PARA *Para;
HTTP_BOOT_DHCP4_OPTION_UNDI *Undi;
HTTP_BOOT_DHCP4_OPTION_ARCH *Arch;
HTTP_BOOT_DHCP4_OPTION_CLID *Clid;
HTTP_BOOT_DHCP4_OPTION_UUID *Uuid;
HTTP_BOOT_DHCP4_OPTION_MESG *Mesg;
HTTP_BOOT_DHCP4_OPTION_MAX_MESG_SIZE *MaxMesgSize;
} HTTP_BOOT_DHCP4_OPTION_ENTRY;
#define GET_NEXT_DHCP_OPTION(Opt) \
@@ -166,44 +166,44 @@ typedef union {
#define GET_OPTION_BUFFER_LEN(Pkt) \
((Pkt)->Length - sizeof (EFI_DHCP4_HEADER) - 4)
#define DEFAULT_CLASS_ID_DATA "HTTPClient:Arch:xxxxx:UNDI:003000"
#define DEFAULT_UNDI_TYPE 1
#define DEFAULT_UNDI_MAJOR 3
#define DEFAULT_UNDI_MINOR 0
#define DEFAULT_CLASS_ID_DATA "HTTPClient:Arch:xxxxx:UNDI:003000"
#define DEFAULT_UNDI_TYPE 1
#define DEFAULT_UNDI_MAJOR 3
#define DEFAULT_UNDI_MINOR 0
typedef struct {
UINT32 Reserved;
UINT32 Reserved;
} HTTP_BOOT_VENDOR_OPTION;
#define HTTP_CACHED_DHCP4_PACKET_MAX_SIZE (OFFSET_OF (EFI_DHCP4_PACKET, Dhcp4) + HTTP_BOOT_DHCP4_PACKET_MAX_SIZE)
typedef union {
EFI_DHCP4_PACKET Offer;
EFI_DHCP4_PACKET Ack;
UINT8 Buffer[HTTP_CACHED_DHCP4_PACKET_MAX_SIZE];
EFI_DHCP4_PACKET Offer;
EFI_DHCP4_PACKET Ack;
UINT8 Buffer[HTTP_CACHED_DHCP4_PACKET_MAX_SIZE];
} HTTP_BOOT_DHCP4_PACKET;
typedef struct {
//
// URI component
//
CHAR8 *Scheme;
CHAR8 *Authority;
CHAR8 *Path;
CHAR8 *Query;
CHAR8 *Fragment; /// TODO: may not required in HTTP URL
CHAR8 *Scheme;
CHAR8 *Authority;
CHAR8 *Path;
CHAR8 *Query;
CHAR8 *Fragment; /// TODO: may not required in HTTP URL
CHAR8 *RegName; /// Point to somewhere in Authority
BOOLEAN AddrIsOk;
EFI_IP_ADDRESS Address;
UINT16 Port;
CHAR8 *RegName; /// Point to somewhere in Authority
BOOLEAN AddrIsOk;
EFI_IP_ADDRESS Address;
UINT16 Port;
} HTTP_BOOT_URI_CONTENT;
typedef struct {
HTTP_BOOT_DHCP4_PACKET Packet;
HTTP_BOOT_OFFER_TYPE OfferType;
VOID *UriParser;
EFI_DHCP4_PACKET_OPTION *OptList[HTTP_BOOT_DHCP4_TAG_INDEX_MAX];
HTTP_BOOT_DHCP4_PACKET Packet;
HTTP_BOOT_OFFER_TYPE OfferType;
VOID *UriParser;
EFI_DHCP4_PACKET_OPTION *OptList[HTTP_BOOT_DHCP4_TAG_INDEX_MAX];
} HTTP_BOOT_DHCP4_PACKET_CACHE;
/**
@@ -228,7 +228,7 @@ HttpBootSelectDhcpOffer (
**/
EFI_STATUS
HttpBootDhcp4Dora (
IN HTTP_BOOT_PRIVATE_DATA *Private
IN HTTP_BOOT_PRIVATE_DATA *Private
);
/**
@@ -245,9 +245,9 @@ HttpBootDhcp4Dora (
**/
EFI_STATUS
HttpBootRegisterIp4Dns (
IN HTTP_BOOT_PRIVATE_DATA *Private,
IN UINTN DataLength,
IN VOID *DnsServerData
IN HTTP_BOOT_PRIVATE_DATA *Private,
IN UINTN DataLength,
IN VOID *DnsServerData
);
#endif

View File

@@ -20,70 +20,70 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
**/
UINT32
HttpBootBuildDhcp6Options (
IN HTTP_BOOT_PRIVATE_DATA *Private,
OUT EFI_DHCP6_PACKET_OPTION **OptList,
IN UINT8 *Buffer
IN HTTP_BOOT_PRIVATE_DATA *Private,
OUT EFI_DHCP6_PACKET_OPTION **OptList,
IN UINT8 *Buffer
)
{
HTTP_BOOT_DHCP6_OPTION_ENTRY OptEnt;
UINT16 Value;
UINT32 Index;
HTTP_BOOT_DHCP6_OPTION_ENTRY OptEnt;
UINT16 Value;
UINT32 Index;
Index = 0;
OptList[0] = (EFI_DHCP6_PACKET_OPTION *) Buffer;
OptList[0] = (EFI_DHCP6_PACKET_OPTION *)Buffer;
//
// Append client option request option
//
OptList[Index]->OpCode = HTONS (DHCP6_OPT_ORO);
OptList[Index]->OpLen = HTONS (8);
OptEnt.Oro = (HTTP_BOOT_DHCP6_OPTION_ORO *) OptList[Index]->Data;
OptEnt.Oro->OpCode[0] = HTONS(DHCP6_OPT_BOOT_FILE_URL);
OptEnt.Oro->OpCode[1] = HTONS(DHCP6_OPT_BOOT_FILE_PARAM);
OptEnt.Oro->OpCode[2] = HTONS(DHCP6_OPT_DNS_SERVERS);
OptEnt.Oro->OpCode[3] = HTONS(DHCP6_OPT_VENDOR_CLASS);
OptList[Index]->OpCode = HTONS (DHCP6_OPT_ORO);
OptList[Index]->OpLen = HTONS (8);
OptEnt.Oro = (HTTP_BOOT_DHCP6_OPTION_ORO *)OptList[Index]->Data;
OptEnt.Oro->OpCode[0] = HTONS (DHCP6_OPT_BOOT_FILE_URL);
OptEnt.Oro->OpCode[1] = HTONS (DHCP6_OPT_BOOT_FILE_PARAM);
OptEnt.Oro->OpCode[2] = HTONS (DHCP6_OPT_DNS_SERVERS);
OptEnt.Oro->OpCode[3] = HTONS (DHCP6_OPT_VENDOR_CLASS);
Index++;
OptList[Index] = GET_NEXT_DHCP6_OPTION (OptList[Index - 1]);
OptList[Index] = GET_NEXT_DHCP6_OPTION (OptList[Index - 1]);
//
// Append client network device interface option
//
OptList[Index]->OpCode = HTONS (DHCP6_OPT_UNDI);
OptList[Index]->OpLen = HTONS ((UINT16)3);
OptEnt.Undi = (HTTP_BOOT_DHCP6_OPTION_UNDI *) OptList[Index]->Data;
OptList[Index]->OpCode = HTONS (DHCP6_OPT_UNDI);
OptList[Index]->OpLen = HTONS ((UINT16)3);
OptEnt.Undi = (HTTP_BOOT_DHCP6_OPTION_UNDI *)OptList[Index]->Data;
if (Private->Nii != NULL) {
OptEnt.Undi->Type = Private->Nii->Type;
OptEnt.Undi->MajorVer = Private->Nii->MajorVer;
OptEnt.Undi->MinorVer = Private->Nii->MinorVer;
OptEnt.Undi->Type = Private->Nii->Type;
OptEnt.Undi->MajorVer = Private->Nii->MajorVer;
OptEnt.Undi->MinorVer = Private->Nii->MinorVer;
} else {
OptEnt.Undi->Type = DEFAULT_UNDI_TYPE;
OptEnt.Undi->MajorVer = DEFAULT_UNDI_MAJOR;
OptEnt.Undi->MinorVer = DEFAULT_UNDI_MINOR;
OptEnt.Undi->Type = DEFAULT_UNDI_TYPE;
OptEnt.Undi->MajorVer = DEFAULT_UNDI_MAJOR;
OptEnt.Undi->MinorVer = DEFAULT_UNDI_MINOR;
}
Index++;
OptList[Index] = GET_NEXT_DHCP6_OPTION (OptList[Index - 1]);
OptList[Index] = GET_NEXT_DHCP6_OPTION (OptList[Index - 1]);
//
// Append client system architecture option
//
OptList[Index]->OpCode = HTONS (DHCP6_OPT_ARCH);
OptList[Index]->OpLen = HTONS ((UINT16) sizeof (HTTP_BOOT_DHCP6_OPTION_ARCH));
OptEnt.Arch = (HTTP_BOOT_DHCP6_OPTION_ARCH *) OptList[Index]->Data;
Value = HTONS (EFI_HTTP_BOOT_CLIENT_SYSTEM_ARCHITECTURE);
OptList[Index]->OpCode = HTONS (DHCP6_OPT_ARCH);
OptList[Index]->OpLen = HTONS ((UINT16)sizeof (HTTP_BOOT_DHCP6_OPTION_ARCH));
OptEnt.Arch = (HTTP_BOOT_DHCP6_OPTION_ARCH *)OptList[Index]->Data;
Value = HTONS (EFI_HTTP_BOOT_CLIENT_SYSTEM_ARCHITECTURE);
CopyMem (&OptEnt.Arch->Type, &Value, sizeof (UINT16));
Index++;
OptList[Index] = GET_NEXT_DHCP6_OPTION (OptList[Index - 1]);
OptList[Index] = GET_NEXT_DHCP6_OPTION (OptList[Index - 1]);
//
// Append vendor class identify option.
//
OptList[Index]->OpCode = HTONS (DHCP6_OPT_VENDOR_CLASS);
OptList[Index]->OpLen = HTONS ((UINT16) sizeof (HTTP_BOOT_DHCP6_OPTION_VENDOR_CLASS));
OptEnt.VendorClass = (HTTP_BOOT_DHCP6_OPTION_VENDOR_CLASS *) OptList[Index]->Data;
OptList[Index]->OpLen = HTONS ((UINT16)sizeof (HTTP_BOOT_DHCP6_OPTION_VENDOR_CLASS));
OptEnt.VendorClass = (HTTP_BOOT_DHCP6_OPTION_VENDOR_CLASS *)OptList[Index]->Data;
OptEnt.VendorClass->Vendor = HTONL (HTTP_BOOT_DHCP6_ENTERPRISE_NUM);
OptEnt.VendorClass->ClassLen = HTONS ((UINT16) sizeof (HTTP_BOOT_CLASS_ID));
OptEnt.VendorClass->ClassLen = HTONS ((UINT16)sizeof (HTTP_BOOT_CLASS_ID));
CopyMem (
&OptEnt.VendorClass->ClassId,
DEFAULT_CLASS_ID_DATA,
@@ -131,33 +131,30 @@ HttpBootBuildDhcp6Options (
**/
EFI_DHCP6_PACKET_OPTION *
HttpBootParseDhcp6Options (
IN UINT8 *Buffer,
IN UINT32 Length,
IN UINT16 OptTag
IN UINT8 *Buffer,
IN UINT32 Length,
IN UINT16 OptTag
)
{
EFI_DHCP6_PACKET_OPTION *Option;
UINT32 Offset;
EFI_DHCP6_PACKET_OPTION *Option;
UINT32 Offset;
Option = (EFI_DHCP6_PACKET_OPTION *) Buffer;
Offset = 0;
Option = (EFI_DHCP6_PACKET_OPTION *)Buffer;
Offset = 0;
//
// OpLen and OpCode here are both stored in network order.
//
while (Offset < Length) {
if (NTOHS (Option->OpCode) == OptTag) {
return Option;
}
Offset += (NTOHS(Option->OpLen) + 4);
Option = (EFI_DHCP6_PACKET_OPTION *) (Buffer + Offset);
Offset += (NTOHS (Option->OpLen) + 4);
Option = (EFI_DHCP6_PACKET_OPTION *)(Buffer + Offset);
}
return NULL;
}
/**
@@ -171,40 +168,39 @@ HttpBootParseDhcp6Options (
**/
EFI_STATUS
HttpBootParseDhcp6Packet (
IN HTTP_BOOT_DHCP6_PACKET_CACHE *Cache6
IN HTTP_BOOT_DHCP6_PACKET_CACHE *Cache6
)
{
EFI_DHCP6_PACKET *Offer;
EFI_DHCP6_PACKET_OPTION **Options;
EFI_DHCP6_PACKET_OPTION *Option;
HTTP_BOOT_OFFER_TYPE OfferType;
EFI_IPv6_ADDRESS IpAddr;
BOOLEAN IsProxyOffer;
BOOLEAN IsHttpOffer;
BOOLEAN IsDnsOffer;
BOOLEAN IpExpressedUri;
EFI_STATUS Status;
UINT32 Offset;
UINT32 Length;
EFI_DHCP6_PACKET *Offer;
EFI_DHCP6_PACKET_OPTION **Options;
EFI_DHCP6_PACKET_OPTION *Option;
HTTP_BOOT_OFFER_TYPE OfferType;
EFI_IPv6_ADDRESS IpAddr;
BOOLEAN IsProxyOffer;
BOOLEAN IsHttpOffer;
BOOLEAN IsDnsOffer;
BOOLEAN IpExpressedUri;
EFI_STATUS Status;
UINT32 Offset;
UINT32 Length;
IsDnsOffer = FALSE;
IpExpressedUri = FALSE;
IsProxyOffer = TRUE;
IsHttpOffer = FALSE;
Offer = &Cache6->Packet.Offer;
Options = Cache6->OptList;
Offer = &Cache6->Packet.Offer;
Options = Cache6->OptList;
ZeroMem (Cache6->OptList, sizeof (Cache6->OptList));
Option = (EFI_DHCP6_PACKET_OPTION *) (Offer->Dhcp6.Option);
Offset = 0;
Length = GET_DHCP6_OPTION_SIZE (Offer);
Option = (EFI_DHCP6_PACKET_OPTION *)(Offer->Dhcp6.Option);
Offset = 0;
Length = GET_DHCP6_OPTION_SIZE (Offer);
//
// OpLen and OpCode here are both stored in network order, since they are from original packet.
//
while (Offset < Length) {
if (NTOHS (Option->OpCode) == DHCP6_OPT_IA_NA) {
Options[HTTP_BOOT_DHCP6_IDX_IA_NA] = Option;
} else if (NTOHS (Option->OpCode) == DHCP6_OPT_BOOT_FILE_URL) {
@@ -221,8 +217,9 @@ HttpBootParseDhcp6Packet (
}
Offset += (NTOHS (Option->OpLen) + 4);
Option = (EFI_DHCP6_PACKET_OPTION *) (Offer->Dhcp6.Option + Offset);
Option = (EFI_DHCP6_PACKET_OPTION *)(Offer->Dhcp6.Option + Offset);
}
//
// The offer with assigned client address is NOT a proxy offer.
// An ia_na option, embedded with valid ia_addr option and a status_code of success.
@@ -234,7 +231,7 @@ HttpBootParseDhcp6Packet (
NTOHS (Option->OpLen),
DHCP6_OPT_STATUS_CODE
);
if ((Option != NULL && Option->Data[0] == 0) || (Option == NULL)) {
if (((Option != NULL) && (Option->Data[0] == 0)) || (Option == NULL)) {
IsProxyOffer = FALSE;
}
}
@@ -244,10 +241,11 @@ HttpBootParseDhcp6Packet (
//
Option = Options[HTTP_BOOT_DHCP6_IDX_VENDOR_CLASS];
if (Option != NULL &&
NTOHS(Option->OpLen) >= 16 &&
CompareMem ((Option->Data + 6), DEFAULT_CLASS_ID_DATA, 10) == 0) {
IsHttpOffer = TRUE;
if ((Option != NULL) &&
(NTOHS (Option->OpLen) >= 16) &&
(CompareMem ((Option->Data + 6), DEFAULT_CLASS_ID_DATA, 10) == 0))
{
IsHttpOffer = TRUE;
}
//
@@ -261,7 +259,7 @@ HttpBootParseDhcp6Packet (
//
// Http offer must have a boot URI.
//
if (IsHttpOffer && Options[HTTP_BOOT_DHCP6_IDX_BOOT_FILE_URL] == NULL) {
if (IsHttpOffer && (Options[HTTP_BOOT_DHCP6_IDX_BOOT_FILE_URL] == NULL)) {
return EFI_DEVICE_ERROR;
}
@@ -270,8 +268,8 @@ HttpBootParseDhcp6Packet (
//
if (IsHttpOffer) {
Status = HttpParseUrl (
(CHAR8*) Options[HTTP_BOOT_DHCP6_IDX_BOOT_FILE_URL]->Data,
(UINT32) AsciiStrLen ((CHAR8*) Options[HTTP_BOOT_DHCP6_IDX_BOOT_FILE_URL]->Data),
(CHAR8 *)Options[HTTP_BOOT_DHCP6_IDX_BOOT_FILE_URL]->Data,
(UINT32)AsciiStrLen ((CHAR8 *)Options[HTTP_BOOT_DHCP6_IDX_BOOT_FILE_URL]->Data),
FALSE,
&Cache6->UriParser
);
@@ -280,7 +278,7 @@ HttpBootParseDhcp6Packet (
}
Status = HttpUrlGetIp6 (
(CHAR8*) Options[HTTP_BOOT_DHCP6_IDX_BOOT_FILE_URL]->Data,
(CHAR8 *)Options[HTTP_BOOT_DHCP6_IDX_BOOT_FILE_URL]->Data,
Cache6->UriParser,
&IpAddr
);
@@ -304,7 +302,6 @@ HttpBootParseDhcp6Packet (
OfferType = HttpOfferTypeProxyNameUri;
}
}
} else {
if (!IsProxyOffer) {
OfferType = IsDnsOffer ? HttpOfferTypeDhcpDns : HttpOfferTypeDhcpOnly;
@@ -329,8 +326,8 @@ HttpBootParseDhcp6Packet (
**/
EFI_STATUS
HttpBootCacheDhcp6Packet (
IN EFI_DHCP6_PACKET *Dst,
IN EFI_DHCP6_PACKET *Src
IN EFI_DHCP6_PACKET *Dst,
IN EFI_DHCP6_PACKET *Src
)
{
if (Dst->Size < Src->Length) {
@@ -359,10 +356,10 @@ HttpBootCacheDhcp6Offer (
IN EFI_DHCP6_PACKET *RcvdOffer
)
{
HTTP_BOOT_DHCP6_PACKET_CACHE *Cache6;
EFI_DHCP6_PACKET *Offer;
HTTP_BOOT_OFFER_TYPE OfferType;
EFI_STATUS Status;
HTTP_BOOT_DHCP6_PACKET_CACHE *Cache6;
EFI_DHCP6_PACKET *Offer;
HTTP_BOOT_OFFER_TYPE OfferType;
EFI_STATUS Status;
Cache6 = &Private->OfferBuffer[Private->OfferNum].Dhcp6;
Offer = &Cache6->Packet.Offer;
@@ -370,7 +367,7 @@ HttpBootCacheDhcp6Offer (
//
// Cache the content of DHCPv6 packet firstly.
//
Status = HttpBootCacheDhcp6Packet(Offer, RcvdOffer);
Status = HttpBootCacheDhcp6Packet (Offer, RcvdOffer);
if (EFI_ERROR (Status)) {
return Status;
}
@@ -417,86 +414,91 @@ HttpBootCacheDhcp6Offer (
EFI_STATUS
EFIAPI
HttpBootDhcp6CallBack (
IN EFI_DHCP6_PROTOCOL *This,
IN VOID *Context,
IN EFI_DHCP6_STATE CurrentState,
IN EFI_DHCP6_EVENT Dhcp6Event,
IN EFI_DHCP6_PACKET *Packet,
OUT EFI_DHCP6_PACKET **NewPacket OPTIONAL
IN EFI_DHCP6_PROTOCOL *This,
IN VOID *Context,
IN EFI_DHCP6_STATE CurrentState,
IN EFI_DHCP6_EVENT Dhcp6Event,
IN EFI_DHCP6_PACKET *Packet,
OUT EFI_DHCP6_PACKET **NewPacket OPTIONAL
)
{
HTTP_BOOT_PRIVATE_DATA *Private;
EFI_DHCP6_PACKET *SelectAd;
EFI_STATUS Status;
BOOLEAN Received;
HTTP_BOOT_PRIVATE_DATA *Private;
EFI_DHCP6_PACKET *SelectAd;
EFI_STATUS Status;
BOOLEAN Received;
if ((Dhcp6Event != Dhcp6SendSolicit) &&
(Dhcp6Event != Dhcp6RcvdAdvertise) &&
(Dhcp6Event != Dhcp6SendRequest) &&
(Dhcp6Event != Dhcp6RcvdReply) &&
(Dhcp6Event != Dhcp6SelectAdvertise)) {
(Dhcp6Event != Dhcp6RcvdAdvertise) &&
(Dhcp6Event != Dhcp6SendRequest) &&
(Dhcp6Event != Dhcp6RcvdReply) &&
(Dhcp6Event != Dhcp6SelectAdvertise))
{
return EFI_SUCCESS;
}
ASSERT (Packet != NULL);
Private = (HTTP_BOOT_PRIVATE_DATA *) Context;
Status = EFI_SUCCESS;
if (Private->HttpBootCallback != NULL && Dhcp6Event != Dhcp6SelectAdvertise) {
Received = (BOOLEAN) (Dhcp6Event == Dhcp6RcvdAdvertise || Dhcp6Event == Dhcp6RcvdReply);
Status = Private->HttpBootCallback->Callback (
Private->HttpBootCallback,
HttpBootDhcp6,
Received,
Packet->Length,
&Packet->Dhcp6
);
Private = (HTTP_BOOT_PRIVATE_DATA *)Context;
Status = EFI_SUCCESS;
if ((Private->HttpBootCallback != NULL) && (Dhcp6Event != Dhcp6SelectAdvertise)) {
Received = (BOOLEAN)(Dhcp6Event == Dhcp6RcvdAdvertise || Dhcp6Event == Dhcp6RcvdReply);
Status = Private->HttpBootCallback->Callback (
Private->HttpBootCallback,
HttpBootDhcp6,
Received,
Packet->Length,
&Packet->Dhcp6
);
if (EFI_ERROR (Status)) {
return EFI_ABORTED;
}
}
switch (Dhcp6Event) {
case Dhcp6RcvdAdvertise:
Status = EFI_NOT_READY;
if (Packet->Length > HTTP_BOOT_DHCP6_PACKET_MAX_SIZE) {
//
// Ignore the incoming packets which exceed the maximum length.
//
break;
}
if (Private->OfferNum < HTTP_BOOT_OFFER_MAX_NUM) {
//
// Cache the dhcp offers to OfferBuffer[] for select later, and record
// the OfferIndex and OfferCount.
// If error happens, just ignore this packet and continue to wait more offer.
//
HttpBootCacheDhcp6Offer (Private, Packet);
}
break;
case Dhcp6SelectAdvertise:
//
// Select offer by the default policy or by order, and record the SelectIndex
// and SelectProxyType.
//
HttpBootSelectDhcpOffer (Private);
if (Private->SelectIndex == 0) {
Status = EFI_ABORTED;
} else {
ASSERT (NewPacket != NULL);
SelectAd = &Private->OfferBuffer[Private->SelectIndex - 1].Dhcp6.Packet.Offer;
*NewPacket = AllocateZeroPool (SelectAd->Size);
if (*NewPacket == NULL) {
return EFI_OUT_OF_RESOURCES;
case Dhcp6RcvdAdvertise:
Status = EFI_NOT_READY;
if (Packet->Length > HTTP_BOOT_DHCP6_PACKET_MAX_SIZE) {
//
// Ignore the incoming packets which exceed the maximum length.
//
break;
}
CopyMem (*NewPacket, SelectAd, SelectAd->Size);
}
break;
default:
break;
if (Private->OfferNum < HTTP_BOOT_OFFER_MAX_NUM) {
//
// Cache the dhcp offers to OfferBuffer[] for select later, and record
// the OfferIndex and OfferCount.
// If error happens, just ignore this packet and continue to wait more offer.
//
HttpBootCacheDhcp6Offer (Private, Packet);
}
break;
case Dhcp6SelectAdvertise:
//
// Select offer by the default policy or by order, and record the SelectIndex
// and SelectProxyType.
//
HttpBootSelectDhcpOffer (Private);
if (Private->SelectIndex == 0) {
Status = EFI_ABORTED;
} else {
ASSERT (NewPacket != NULL);
SelectAd = &Private->OfferBuffer[Private->SelectIndex - 1].Dhcp6.Packet.Offer;
*NewPacket = AllocateZeroPool (SelectAd->Size);
if (*NewPacket == NULL) {
return EFI_OUT_OF_RESOURCES;
}
CopyMem (*NewPacket, SelectAd, SelectAd->Size);
}
break;
default:
break;
}
return Status;
@@ -519,18 +521,18 @@ HttpBootDhcp6CallBack (
**/
EFI_STATUS
HttpBootCheckRouteTable (
IN HTTP_BOOT_PRIVATE_DATA *Private,
IN UINTN TimeOutInSecond,
OUT EFI_IPv6_ADDRESS *GatewayAddr
IN HTTP_BOOT_PRIVATE_DATA *Private,
IN UINTN TimeOutInSecond,
OUT EFI_IPv6_ADDRESS *GatewayAddr
)
{
EFI_STATUS Status;
EFI_IP6_PROTOCOL *Ip6;
EFI_IP6_MODE_DATA Ip6ModeData;
UINTN Index;
EFI_EVENT TimeOutEvt;
UINTN RetryCount;
BOOLEAN GatewayIsFound;
EFI_STATUS Status;
EFI_IP6_PROTOCOL *Ip6;
EFI_IP6_MODE_DATA Ip6ModeData;
UINTN Index;
EFI_EVENT TimeOutEvt;
UINTN RetryCount;
BOOLEAN GatewayIsFound;
ASSERT (GatewayAddr != NULL);
ASSERT (Private != NULL);
@@ -562,23 +564,28 @@ HttpBootCheckRouteTable (
if (Ip6ModeData.AddressList != NULL) {
FreePool (Ip6ModeData.AddressList);
}
if (Ip6ModeData.GroupTable != NULL) {
FreePool (Ip6ModeData.GroupTable);
}
if (Ip6ModeData.RouteTable != NULL) {
FreePool (Ip6ModeData.RouteTable);
}
if (Ip6ModeData.NeighborCache != NULL) {
FreePool (Ip6ModeData.NeighborCache);
}
if (Ip6ModeData.PrefixTable != NULL) {
FreePool (Ip6ModeData.PrefixTable);
}
if (Ip6ModeData.IcmpTypeList != NULL) {
FreePool (Ip6ModeData.IcmpTypeList);
}
if (GatewayIsFound || RetryCount == TimeOutInSecond) {
if (GatewayIsFound || (RetryCount == TimeOutInSecond)) {
break;
}
@@ -604,6 +611,7 @@ HttpBootCheckRouteTable (
if (EFI_ERROR (Status)) {
goto ON_EXIT;
}
while (EFI_ERROR (gBS->CheckEvent (TimeOutEvt))) {
Ip6->Poll (Ip6);
}
@@ -634,16 +642,16 @@ ON_EXIT:
**/
EFI_STATUS
HttpBootSetIp6Policy (
IN HTTP_BOOT_PRIVATE_DATA *Private
IN HTTP_BOOT_PRIVATE_DATA *Private
)
{
EFI_IP6_CONFIG_POLICY Policy;
EFI_IP6_CONFIG_PROTOCOL *Ip6Config;
EFI_STATUS Status;
UINTN DataSize;
EFI_IP6_CONFIG_POLICY Policy;
EFI_IP6_CONFIG_PROTOCOL *Ip6Config;
EFI_STATUS Status;
UINTN DataSize;
Ip6Config = Private->Ip6Config;
DataSize = sizeof (EFI_IP6_CONFIG_POLICY);
Ip6Config = Private->Ip6Config;
DataSize = sizeof (EFI_IP6_CONFIG_POLICY);
//
// Get and store the current policy of IP6 driver.
@@ -663,13 +671,14 @@ HttpBootSetIp6Policy (
Status = Ip6Config->SetData (
Ip6Config,
Ip6ConfigDataTypePolicy,
sizeof(EFI_IP6_CONFIG_POLICY),
sizeof (EFI_IP6_CONFIG_POLICY),
&Policy
);
if (EFI_ERROR (Status)) {
return Status;
}
}
return EFI_SUCCESS;
}
@@ -687,12 +696,12 @@ HttpBootSetIp6Policy (
**/
EFI_STATUS
HttpBootSetIp6Dns (
IN HTTP_BOOT_PRIVATE_DATA *Private,
IN UINTN DataLength,
IN VOID *DnsServerData
IN HTTP_BOOT_PRIVATE_DATA *Private,
IN UINTN DataLength,
IN VOID *DnsServerData
)
{
EFI_IP6_CONFIG_PROTOCOL *Ip6Config;
EFI_IP6_CONFIG_PROTOCOL *Ip6Config;
ASSERT (Private->UsingIpv6);
@@ -717,11 +726,11 @@ HttpBootSetIp6Dns (
**/
EFI_STATUS
HttpBootSetIp6Gateway (
IN HTTP_BOOT_PRIVATE_DATA *Private
IN HTTP_BOOT_PRIVATE_DATA *Private
)
{
EFI_IP6_CONFIG_PROTOCOL *Ip6Config;
EFI_STATUS Status;
EFI_IP6_CONFIG_PROTOCOL *Ip6Config;
EFI_STATUS Status;
ASSERT (Private->UsingIpv6);
Ip6Config = Private->Ip6Config;
@@ -736,7 +745,7 @@ HttpBootSetIp6Gateway (
sizeof (EFI_IPv6_ADDRESS),
&Private->GatewayIp.v6
);
if (EFI_ERROR(Status)) {
if (EFI_ERROR (Status)) {
return Status;
}
}
@@ -755,21 +764,21 @@ HttpBootSetIp6Gateway (
**/
EFI_STATUS
HttpBootSetIp6Address (
IN HTTP_BOOT_PRIVATE_DATA *Private
)
IN HTTP_BOOT_PRIVATE_DATA *Private
)
{
EFI_STATUS Status;
EFI_IP6_PROTOCOL *Ip6;
EFI_IP6_CONFIG_PROTOCOL *Ip6Cfg;
EFI_IP6_CONFIG_POLICY Policy;
EFI_IP6_CONFIG_MANUAL_ADDRESS CfgAddr;
EFI_IPv6_ADDRESS *Ip6Addr;
EFI_IPv6_ADDRESS GatewayAddr;
EFI_IP6_CONFIG_DATA Ip6CfgData;
EFI_EVENT MappedEvt;
UINTN DataSize;
BOOLEAN IsAddressOk;
UINTN Index;
EFI_STATUS Status;
EFI_IP6_PROTOCOL *Ip6;
EFI_IP6_CONFIG_PROTOCOL *Ip6Cfg;
EFI_IP6_CONFIG_POLICY Policy;
EFI_IP6_CONFIG_MANUAL_ADDRESS CfgAddr;
EFI_IPv6_ADDRESS *Ip6Addr;
EFI_IPv6_ADDRESS GatewayAddr;
EFI_IP6_CONFIG_DATA Ip6CfgData;
EFI_EVENT MappedEvt;
UINTN DataSize;
BOOLEAN IsAddressOk;
UINTN Index;
ASSERT (Private->UsingIpv6);
@@ -783,11 +792,11 @@ HttpBootSetIp6Address (
CopyMem (&CfgAddr, &Private->StationIp.v6, sizeof (EFI_IPv6_ADDRESS));
ZeroMem (&Ip6CfgData, sizeof (EFI_IP6_CONFIG_DATA));
Ip6CfgData.AcceptIcmpErrors = TRUE;
Ip6CfgData.DefaultProtocol = IP6_ICMP;
Ip6CfgData.HopLimit = HTTP_BOOT_DEFAULT_HOPLIMIT;
Ip6CfgData.ReceiveTimeout = HTTP_BOOT_DEFAULT_LIFETIME;
Ip6CfgData.TransmitTimeout = HTTP_BOOT_DEFAULT_LIFETIME;
Ip6CfgData.AcceptIcmpErrors = TRUE;
Ip6CfgData.DefaultProtocol = IP6_ICMP;
Ip6CfgData.HopLimit = HTTP_BOOT_DEFAULT_HOPLIMIT;
Ip6CfgData.ReceiveTimeout = HTTP_BOOT_DEFAULT_LIFETIME;
Ip6CfgData.TransmitTimeout = HTTP_BOOT_DEFAULT_LIFETIME;
Status = Ip6->Configure (Ip6, &Ip6CfgData);
if (EFI_ERROR (Status)) {
@@ -811,7 +820,7 @@ HttpBootSetIp6Address (
Status = Ip6Cfg->SetData (
Ip6Cfg,
Ip6ConfigDataTypePolicy,
sizeof(EFI_IP6_CONFIG_POLICY),
sizeof (EFI_IP6_CONFIG_POLICY),
&Policy
);
if (EFI_ERROR (Status)) {
@@ -840,7 +849,7 @@ HttpBootSetIp6Address (
Ip6ConfigDataTypeManualAddress,
MappedEvt
);
if (EFI_ERROR(Status)) {
if (EFI_ERROR (Status)) {
goto ON_EXIT;
}
@@ -850,7 +859,7 @@ HttpBootSetIp6Address (
sizeof (EFI_IP6_CONFIG_MANUAL_ADDRESS),
&CfgAddr
);
if (EFI_ERROR (Status) && Status != EFI_NOT_READY) {
if (EFI_ERROR (Status) && (Status != EFI_NOT_READY)) {
goto ON_EXIT;
} else if (Status == EFI_NOT_READY) {
//
@@ -859,17 +868,18 @@ HttpBootSetIp6Address (
while (!IsAddressOk) {
Ip6->Poll (Ip6);
}
//
// Check whether the Ip6 Address setting is successed.
//
DataSize = 0;
Status = Ip6Cfg->GetData (
Ip6Cfg,
Ip6ConfigDataTypeManualAddress,
&DataSize,
NULL
);
if (Status != EFI_BUFFER_TOO_SMALL || DataSize == 0) {
Status = Ip6Cfg->GetData (
Ip6Cfg,
Ip6ConfigDataTypeManualAddress,
&DataSize,
NULL
);
if ((Status != EFI_BUFFER_TOO_SMALL) || (DataSize == 0)) {
Status = EFI_DEVICE_ERROR;
goto ON_EXIT;
}
@@ -878,22 +888,24 @@ HttpBootSetIp6Address (
if (Ip6Addr == NULL) {
return EFI_OUT_OF_RESOURCES;
}
Status = Ip6Cfg->GetData (
Ip6Cfg,
Ip6ConfigDataTypeManualAddress,
&DataSize,
(VOID *) Ip6Addr
(VOID *)Ip6Addr
);
if (EFI_ERROR (Status)) {
Status = EFI_DEVICE_ERROR;
goto ON_EXIT;
}
for (Index = 0; Index < DataSize / sizeof (EFI_IPv6_ADDRESS); Index ++) {
for (Index = 0; Index < DataSize / sizeof (EFI_IPv6_ADDRESS); Index++) {
if (CompareMem (Ip6Addr + Index, &CfgAddr, sizeof (EFI_IPv6_ADDRESS)) == 0) {
break;
}
}
if (Index == DataSize / sizeof (EFI_IPv6_ADDRESS)) {
Status = EFI_ABORTED;
goto ON_EXIT;
@@ -928,17 +940,17 @@ ON_EXIT:
**/
EFI_STATUS
HttpBootDhcp6Sarr (
IN HTTP_BOOT_PRIVATE_DATA *Private
IN HTTP_BOOT_PRIVATE_DATA *Private
)
{
EFI_DHCP6_PROTOCOL *Dhcp6;
EFI_DHCP6_CONFIG_DATA Config;
EFI_DHCP6_MODE_DATA Mode;
EFI_DHCP6_RETRANSMISSION *Retransmit;
EFI_DHCP6_PACKET_OPTION *OptList[HTTP_BOOT_DHCP6_OPTION_MAX_NUM];
UINT32 OptCount;
UINT8 Buffer[HTTP_BOOT_DHCP6_OPTION_MAX_SIZE];
EFI_STATUS Status;
EFI_DHCP6_PROTOCOL *Dhcp6;
EFI_DHCP6_CONFIG_DATA Config;
EFI_DHCP6_MODE_DATA Mode;
EFI_DHCP6_RETRANSMISSION *Retransmit;
EFI_DHCP6_PACKET_OPTION *OptList[HTTP_BOOT_DHCP6_OPTION_MAX_NUM];
UINT32 OptCount;
UINT8 Buffer[HTTP_BOOT_DHCP6_OPTION_MAX_SIZE];
EFI_STATUS Status;
Dhcp6 = Private->Dhcp6;
ASSERT (Dhcp6 != NULL);
@@ -947,7 +959,7 @@ HttpBootDhcp6Sarr (
// Build options list for the request packet.
//
OptCount = HttpBootBuildDhcp6Options (Private, OptList, Buffer);
ASSERT (OptCount >0);
ASSERT (OptCount > 0);
Retransmit = AllocateZeroPool (sizeof (EFI_DHCP6_RETRANSMISSION));
if (Retransmit == NULL) {
@@ -980,11 +992,12 @@ HttpBootDhcp6Sarr (
if (EFI_ERROR (Status)) {
goto ON_EXIT;
}
//
// Initialize the record fields for DHCPv6 offer in private data.
//
Private->OfferNum = 0;
Private->SelectIndex = 0;
Private->OfferNum = 0;
Private->SelectIndex = 0;
ZeroMem (Private->OfferCount, sizeof (Private->OfferCount));
ZeroMem (Private->OfferIndex, sizeof (Private->OfferIndex));
@@ -1021,12 +1034,11 @@ ON_EXIT:
if (Mode.ClientId != NULL) {
FreePool (Mode.ClientId);
}
if (Mode.Ia != NULL) {
FreePool (Mode.Ia);
}
}
return Status;
}

View File

@@ -6,82 +6,81 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
**/
#ifndef __EFI_HTTP_BOOT_DHCP6_H__
#define __EFI_HTTP_BOOT_DHCP6_H__
#define HTTP_BOOT_OFFER_MAX_NUM 16
#define HTTP_BOOT_DHCP6_OPTION_MAX_NUM 16
#define HTTP_BOOT_DHCP6_OPTION_MAX_SIZE 312
#define HTTP_BOOT_DHCP6_PACKET_MAX_SIZE 1472
#define HTTP_BOOT_IP6_ROUTE_TABLE_TIMEOUT 10
#define HTTP_BOOT_DEFAULT_HOPLIMIT 64
#define HTTP_BOOT_DEFAULT_LIFETIME 50000
#define HTTP_BOOT_OFFER_MAX_NUM 16
#define HTTP_BOOT_DHCP6_OPTION_MAX_NUM 16
#define HTTP_BOOT_DHCP6_OPTION_MAX_SIZE 312
#define HTTP_BOOT_DHCP6_PACKET_MAX_SIZE 1472
#define HTTP_BOOT_IP6_ROUTE_TABLE_TIMEOUT 10
#define HTTP_BOOT_DEFAULT_HOPLIMIT 64
#define HTTP_BOOT_DEFAULT_LIFETIME 50000
#define HTTP_BOOT_DHCP6_ENTERPRISE_NUM 343 // TODO: IANA TBD: temporarily using Intel's
#define HTTP_BOOT_DHCP6_MAX_BOOT_FILE_SIZE 65535 // It's a limitation of bit length, 65535*512 bytes.
#define HTTP_BOOT_DHCP6_ENTERPRISE_NUM 343 // TODO: IANA TBD: temporarily using Intel's
#define HTTP_BOOT_DHCP6_MAX_BOOT_FILE_SIZE 65535 // It's a limitation of bit length, 65535*512 bytes.
#define HTTP_BOOT_DHCP6_IDX_IA_NA 0
#define HTTP_BOOT_DHCP6_IDX_BOOT_FILE_URL 1
#define HTTP_BOOT_DHCP6_IDX_BOOT_FILE_PARAM 2
#define HTTP_BOOT_DHCP6_IDX_VENDOR_CLASS 3
#define HTTP_BOOT_DHCP6_IDX_DNS_SERVER 4
#define HTTP_BOOT_DHCP6_IDX_MAX 5
#define HTTP_BOOT_DHCP6_IDX_IA_NA 0
#define HTTP_BOOT_DHCP6_IDX_BOOT_FILE_URL 1
#define HTTP_BOOT_DHCP6_IDX_BOOT_FILE_PARAM 2
#define HTTP_BOOT_DHCP6_IDX_VENDOR_CLASS 3
#define HTTP_BOOT_DHCP6_IDX_DNS_SERVER 4
#define HTTP_BOOT_DHCP6_IDX_MAX 5
#pragma pack(1)
typedef struct {
UINT16 OpCode[256];
UINT16 OpCode[256];
} HTTP_BOOT_DHCP6_OPTION_ORO;
typedef struct {
UINT8 Type;
UINT8 MajorVer;
UINT8 MinorVer;
UINT8 Type;
UINT8 MajorVer;
UINT8 MinorVer;
} HTTP_BOOT_DHCP6_OPTION_UNDI;
typedef struct {
UINT16 Type;
UINT16 Type;
} HTTP_BOOT_DHCP6_OPTION_ARCH;
typedef struct {
UINT8 ClassIdentifier[11];
UINT8 ArchitecturePrefix[5];
UINT8 ArchitectureType[5];
UINT8 Lit3[1];
UINT8 InterfaceName[4];
UINT8 Lit4[1];
UINT8 UndiMajor[3];
UINT8 UndiMinor[3];
UINT8 ClassIdentifier[11];
UINT8 ArchitecturePrefix[5];
UINT8 ArchitectureType[5];
UINT8 Lit3[1];
UINT8 InterfaceName[4];
UINT8 Lit4[1];
UINT8 UndiMajor[3];
UINT8 UndiMinor[3];
} HTTP_BOOT_CLASS_ID;
typedef struct {
UINT32 Vendor;
UINT16 ClassLen;
HTTP_BOOT_CLASS_ID ClassId;
UINT32 Vendor;
UINT16 ClassLen;
HTTP_BOOT_CLASS_ID ClassId;
} HTTP_BOOT_DHCP6_OPTION_VENDOR_CLASS;
#pragma pack()
typedef union {
HTTP_BOOT_DHCP6_OPTION_ORO *Oro;
HTTP_BOOT_DHCP6_OPTION_UNDI *Undi;
HTTP_BOOT_DHCP6_OPTION_ARCH *Arch;
HTTP_BOOT_DHCP6_OPTION_VENDOR_CLASS *VendorClass;
HTTP_BOOT_DHCP6_OPTION_ORO *Oro;
HTTP_BOOT_DHCP6_OPTION_UNDI *Undi;
HTTP_BOOT_DHCP6_OPTION_ARCH *Arch;
HTTP_BOOT_DHCP6_OPTION_VENDOR_CLASS *VendorClass;
} HTTP_BOOT_DHCP6_OPTION_ENTRY;
#define HTTP_CACHED_DHCP6_PACKET_MAX_SIZE (OFFSET_OF (EFI_DHCP6_PACKET, Dhcp6) + HTTP_BOOT_DHCP6_PACKET_MAX_SIZE)
typedef union {
EFI_DHCP6_PACKET Offer;
EFI_DHCP6_PACKET Ack;
UINT8 Buffer[HTTP_CACHED_DHCP6_PACKET_MAX_SIZE];
EFI_DHCP6_PACKET Offer;
EFI_DHCP6_PACKET Ack;
UINT8 Buffer[HTTP_CACHED_DHCP6_PACKET_MAX_SIZE];
} HTTP_BOOT_DHCP6_PACKET;
typedef struct {
HTTP_BOOT_DHCP6_PACKET Packet;
HTTP_BOOT_OFFER_TYPE OfferType;
EFI_DHCP6_PACKET_OPTION *OptList[HTTP_BOOT_DHCP6_IDX_MAX];
VOID *UriParser;
HTTP_BOOT_DHCP6_PACKET Packet;
HTTP_BOOT_OFFER_TYPE OfferType;
EFI_DHCP6_PACKET_OPTION *OptList[HTTP_BOOT_DHCP6_IDX_MAX];
VOID *UriParser;
} HTTP_BOOT_DHCP6_PACKET_CACHE;
#define GET_NEXT_DHCP6_OPTION(Opt) \
@@ -102,7 +101,7 @@ typedef struct {
**/
EFI_STATUS
HttpBootDhcp6Sarr (
IN HTTP_BOOT_PRIVATE_DATA *Private
IN HTTP_BOOT_PRIVATE_DATA *Private
);
/**
@@ -116,7 +115,7 @@ HttpBootDhcp6Sarr (
**/
EFI_STATUS
HttpBootSetIp6Policy (
IN HTTP_BOOT_PRIVATE_DATA *Private
IN HTTP_BOOT_PRIVATE_DATA *Private
);
/**
@@ -133,9 +132,9 @@ HttpBootSetIp6Policy (
**/
EFI_STATUS
HttpBootSetIp6Dns (
IN HTTP_BOOT_PRIVATE_DATA *Private,
IN UINTN DataLength,
IN VOID *DnsServerData
IN HTTP_BOOT_PRIVATE_DATA *Private,
IN UINTN DataLength,
IN VOID *DnsServerData
);
/**
@@ -149,7 +148,7 @@ HttpBootSetIp6Dns (
**/
EFI_STATUS
HttpBootSetIp6Gateway (
IN HTTP_BOOT_PRIVATE_DATA *Private
IN HTTP_BOOT_PRIVATE_DATA *Private
);
/**
@@ -163,7 +162,7 @@ HttpBootSetIp6Gateway (
**/
EFI_STATUS
HttpBootSetIp6Address (
IN HTTP_BOOT_PRIVATE_DATA *Private
IN HTTP_BOOT_PRIVATE_DATA *Private
);
#endif

View File

@@ -11,7 +11,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
///
/// Driver Binding Protocol instance
///
EFI_DRIVER_BINDING_PROTOCOL gHttpBootIp4DxeDriverBinding = {
EFI_DRIVER_BINDING_PROTOCOL gHttpBootIp4DxeDriverBinding = {
HttpBootIp4DxeDriverBindingSupported,
HttpBootIp4DxeDriverBindingStart,
HttpBootIp4DxeDriverBindingStop,
@@ -20,7 +20,7 @@ EFI_DRIVER_BINDING_PROTOCOL gHttpBootIp4DxeDriverBinding = {
NULL
};
EFI_DRIVER_BINDING_PROTOCOL gHttpBootIp6DxeDriverBinding = {
EFI_DRIVER_BINDING_PROTOCOL gHttpBootIp6DxeDriverBinding = {
HttpBootIp6DxeDriverBindingSupported,
HttpBootIp6DxeDriverBindingStart,
HttpBootIp6DxeDriverBindingStop,
@@ -29,8 +29,6 @@ EFI_DRIVER_BINDING_PROTOCOL gHttpBootIp6DxeDriverBinding = {
NULL
};
/**
Check whether UNDI protocol supports IPv6.
@@ -43,19 +41,19 @@ EFI_DRIVER_BINDING_PROTOCOL gHttpBootIp6DxeDriverBinding = {
**/
EFI_STATUS
HttpBootCheckIpv6Support (
IN HTTP_BOOT_PRIVATE_DATA *Private,
OUT BOOLEAN *Ipv6Support
IN HTTP_BOOT_PRIVATE_DATA *Private,
OUT BOOLEAN *Ipv6Support
)
{
EFI_HANDLE Handle;
EFI_ADAPTER_INFORMATION_PROTOCOL *Aip;
EFI_STATUS Status;
EFI_GUID *InfoTypesBuffer;
UINTN InfoTypeBufferCount;
UINTN TypeIndex;
BOOLEAN Supported;
VOID *InfoBlock;
UINTN InfoBlockSize;
EFI_HANDLE Handle;
EFI_ADAPTER_INFORMATION_PROTOCOL *Aip;
EFI_STATUS Status;
EFI_GUID *InfoTypesBuffer;
UINTN InfoTypeBufferCount;
UINTN TypeIndex;
BOOLEAN Supported;
VOID *InfoBlock;
UINTN InfoBlockSize;
ASSERT (Private != NULL && Ipv6Support != NULL);
@@ -79,16 +77,16 @@ HttpBootCheckIpv6Support (
Status = gBS->HandleProtocol (
Handle,
&gEfiAdapterInformationProtocolGuid,
(VOID *) &Aip
(VOID *)&Aip
);
if (EFI_ERROR (Status) || Aip == NULL) {
if (EFI_ERROR (Status) || (Aip == NULL)) {
return EFI_NOT_FOUND;
}
InfoTypesBuffer = NULL;
InfoTypeBufferCount = 0;
Status = Aip->GetSupportedTypes (Aip, &InfoTypesBuffer, &InfoTypeBufferCount);
if (EFI_ERROR (Status) || InfoTypesBuffer == NULL) {
Status = Aip->GetSupportedTypes (Aip, &InfoTypesBuffer, &InfoTypeBufferCount);
if (EFI_ERROR (Status) || (InfoTypesBuffer == NULL)) {
FreePool (InfoTypesBuffer);
return EFI_NOT_FOUND;
}
@@ -111,13 +109,13 @@ HttpBootCheckIpv6Support (
//
InfoBlock = NULL;
InfoBlockSize = 0;
Status = Aip->GetInformation (Aip, &gEfiAdapterInfoUndiIpv6SupportGuid, &InfoBlock, &InfoBlockSize);
if (EFI_ERROR (Status) || InfoBlock == NULL) {
Status = Aip->GetInformation (Aip, &gEfiAdapterInfoUndiIpv6SupportGuid, &InfoBlock, &InfoBlockSize);
if (EFI_ERROR (Status) || (InfoBlock == NULL)) {
FreePool (InfoBlock);
return EFI_NOT_FOUND;
}
*Ipv6Support = ((EFI_ADAPTER_INFO_UNDI_IPV6_SUPPORT *) InfoBlock)->Ipv6Support;
*Ipv6Support = ((EFI_ADAPTER_INFO_UNDI_IPV6_SUPPORT *)InfoBlock)->Ipv6Support;
FreePool (InfoBlock);
return EFI_SUCCESS;
@@ -155,13 +153,12 @@ HttpBootDestroyIp4Children (
);
}
if (Private->Ip6Nic == NULL && Private->HttpCreated) {
if ((Private->Ip6Nic == NULL) && Private->HttpCreated) {
HttpIoDestroyIo (&Private->HttpIo);
Private->HttpCreated = FALSE;
}
if (Private->Ip4Nic != NULL) {
gBS->CloseProtocol (
Private->Controller,
&gEfiCallerIdGuid,
@@ -180,7 +177,6 @@ HttpBootDestroyIp4Children (
FreePool (Private->Ip4Nic);
Private->Ip4Nic = NULL;
}
}
/**
@@ -231,13 +227,12 @@ HttpBootDestroyIp6Children (
);
}
if (Private->Ip4Nic == NULL && Private->HttpCreated) {
HttpIoDestroyIo(&Private->HttpIo);
if ((Private->Ip4Nic == NULL) && Private->HttpCreated) {
HttpIoDestroyIo (&Private->HttpIo);
Private->HttpCreated = FALSE;
}
if (Private->Ip6Nic != NULL) {
gBS->CloseProtocol (
Private->Controller,
&gEfiCallerIdGuid,
@@ -308,7 +303,7 @@ HttpBootIp4DxeDriverBindingSupported (
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
)
{
EFI_STATUS Status;
EFI_STATUS Status;
//
// Try to open the DHCP4, HTTP4 and Device Path protocol.
@@ -349,7 +344,6 @@ HttpBootIp4DxeDriverBindingSupported (
return Status;
}
/**
Starts a device controller or a bus controller.
@@ -393,26 +387,26 @@ HttpBootIp4DxeDriverBindingStart (
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
)
{
EFI_STATUS Status;
HTTP_BOOT_PRIVATE_DATA *Private;
EFI_DEV_PATH *Node;
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
UINT32 *Id;
BOOLEAN FirstStart;
EFI_STATUS Status;
HTTP_BOOT_PRIVATE_DATA *Private;
EFI_DEV_PATH *Node;
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
UINT32 *Id;
BOOLEAN FirstStart;
FirstStart = FALSE;
Status = gBS->OpenProtocol (
ControllerHandle,
&gEfiCallerIdGuid,
(VOID **) &Id,
(VOID **)&Id,
This->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
if (!EFI_ERROR (Status)) {
Private = HTTP_BOOT_PRIVATE_DATA_FROM_ID(Id);
Private = HTTP_BOOT_PRIVATE_DATA_FROM_ID (Id);
} else {
FirstStart = TRUE;
@@ -423,7 +417,8 @@ HttpBootIp4DxeDriverBindingStart (
if (Private == NULL) {
return EFI_OUT_OF_RESOURCES;
}
Private->Signature = HTTP_BOOT_PRIVATE_DATA_SIGNATURE;
Private->Signature = HTTP_BOOT_PRIVATE_DATA_SIGNATURE;
Private->Controller = ControllerHandle;
InitializeListHead (&Private->CacheList);
//
@@ -432,7 +427,7 @@ HttpBootIp4DxeDriverBindingStart (
Status = gBS->OpenProtocol (
ControllerHandle,
&gEfiNetworkInterfaceIdentifierProtocolGuid_31,
(VOID **) &Private->Nii,
(VOID **)&Private->Nii,
This->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
@@ -447,7 +442,7 @@ HttpBootIp4DxeDriverBindingStart (
Status = gBS->OpenProtocol (
ControllerHandle,
&gEfiDevicePathProtocolGuid,
(VOID **) &Private->ParentDevicePath,
(VOID **)&Private->ParentDevicePath,
This->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
@@ -477,7 +472,6 @@ HttpBootIp4DxeDriverBindingStart (
if (EFI_ERROR (Status)) {
goto ON_ERROR;
}
}
if (Private->Ip4Nic != NULL) {
@@ -492,6 +486,7 @@ HttpBootIp4DxeDriverBindingStart (
Status = EFI_OUT_OF_RESOURCES;
goto ON_ERROR;
}
Private->Ip4Nic->Private = Private;
Private->Ip4Nic->ImageHandle = This->DriverBindingHandle;
Private->Ip4Nic->Signature = HTTP_BOOT_VIRTUAL_NIC_SIGNATURE;
@@ -512,7 +507,7 @@ HttpBootIp4DxeDriverBindingStart (
Status = gBS->OpenProtocol (
Private->Dhcp4Child,
&gEfiDhcp4ProtocolGuid,
(VOID **) &Private->Dhcp4,
(VOID **)&Private->Dhcp4,
This->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_BY_DRIVER
@@ -527,7 +522,7 @@ HttpBootIp4DxeDriverBindingStart (
Status = gBS->OpenProtocol (
ControllerHandle,
&gEfiIp4Config2ProtocolGuid,
(VOID **) &Private->Ip4Config2,
(VOID **)&Private->Ip4Config2,
This->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
@@ -544,11 +539,12 @@ HttpBootIp4DxeDriverBindingStart (
Status = EFI_OUT_OF_RESOURCES;
goto ON_ERROR;
}
Node->Ipv4.Header.Type = MESSAGING_DEVICE_PATH;
Node->Ipv4.Header.Type = MESSAGING_DEVICE_PATH;
Node->Ipv4.Header.SubType = MSG_IPv4_DP;
SetDevicePathNodeLength (Node, sizeof (IPv4_DEVICE_PATH));
Node->Ipv4.StaticIpAddress = FALSE;
DevicePath = AppendDevicePathNode (Private->ParentDevicePath, (EFI_DEVICE_PATH_PROTOCOL*) Node);
DevicePath = AppendDevicePathNode (Private->ParentDevicePath, (EFI_DEVICE_PATH_PROTOCOL *)Node);
FreePool (Node);
if (DevicePath == NULL) {
Status = EFI_OUT_OF_RESOURCES;
@@ -563,10 +559,11 @@ HttpBootIp4DxeDriverBindingStart (
Status = EFI_OUT_OF_RESOURCES;
goto ON_ERROR;
}
Node->DevPath.Type = MESSAGING_DEVICE_PATH;
Node->DevPath.Type = MESSAGING_DEVICE_PATH;
Node->DevPath.SubType = MSG_URI_DP;
SetDevicePathNodeLength (Node, sizeof (EFI_DEVICE_PATH_PROTOCOL));
Private->Ip4Nic->DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL*) Node);
Private->Ip4Nic->DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)Node);
FreePool (Node);
FreePool (DevicePath);
if (Private->Ip4Nic->DevicePath == NULL) {
@@ -597,7 +594,7 @@ HttpBootIp4DxeDriverBindingStart (
Status = gBS->OpenProtocol (
ControllerHandle,
&gEfiCallerIdGuid,
(VOID **) &Id,
(VOID **)&Id,
This->DriverBindingHandle,
Private->Ip4Nic->Controller,
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
@@ -629,7 +626,6 @@ ON_ERROR:
return Status;
}
/**
Stops a device controller or a bus controller.
@@ -665,11 +661,11 @@ HttpBootIp4DxeDriverBindingStop (
IN EFI_HANDLE *ChildHandleBuffer OPTIONAL
)
{
EFI_STATUS Status;
EFI_LOAD_FILE_PROTOCOL *LoadFile;
HTTP_BOOT_PRIVATE_DATA *Private;
EFI_HANDLE NicHandle;
UINT32 *Id;
EFI_STATUS Status;
EFI_LOAD_FILE_PROTOCOL *LoadFile;
HTTP_BOOT_PRIVATE_DATA *Private;
EFI_HANDLE NicHandle;
UINT32 *Id;
//
// Try to get the Load File Protocol from the controller handle.
@@ -677,7 +673,7 @@ HttpBootIp4DxeDriverBindingStop (
Status = gBS->OpenProtocol (
ControllerHandle,
&gEfiLoadFileProtocolGuid,
(VOID **) &LoadFile,
(VOID **)&LoadFile,
This->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
@@ -697,7 +693,7 @@ HttpBootIp4DxeDriverBindingStop (
Status = gBS->OpenProtocol (
NicHandle,
&gEfiCallerIdGuid,
(VOID **) &Id,
(VOID **)&Id,
This->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
@@ -705,9 +701,10 @@ HttpBootIp4DxeDriverBindingStop (
if (EFI_ERROR (Status)) {
return Status;
}
Private = HTTP_BOOT_PRIVATE_DATA_FROM_ID (Id);
} else {
Private = HTTP_BOOT_PRIVATE_DATA_FROM_LOADFILE (LoadFile);
Private = HTTP_BOOT_PRIVATE_DATA_FROM_LOADFILE (LoadFile);
NicHandle = Private->Controller;
}
@@ -715,7 +712,7 @@ HttpBootIp4DxeDriverBindingStop (
// Disable the HTTP boot function.
//
Status = HttpBootStop (Private);
if (Status != EFI_SUCCESS && Status != EFI_NOT_STARTED) {
if ((Status != EFI_SUCCESS) && (Status != EFI_NOT_STARTED)) {
return Status;
}
@@ -724,7 +721,7 @@ HttpBootIp4DxeDriverBindingStop (
//
HttpBootDestroyIp4Children (This, Private);
if (Private->Ip4Nic == NULL && Private->Ip6Nic == NULL) {
if ((Private->Ip4Nic == NULL) && (Private->Ip6Nic == NULL)) {
//
// Release the cached data.
//
@@ -741,7 +738,6 @@ HttpBootIp4DxeDriverBindingStop (
&Private->Id
);
FreePool (Private);
}
return EFI_SUCCESS;
@@ -797,7 +793,7 @@ HttpBootIp6DxeDriverBindingSupported (
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
)
{
EFI_STATUS Status;
EFI_STATUS Status;
//
// Try to open the DHCP6, HTTP and Device Path protocol.
@@ -836,7 +832,6 @@ HttpBootIp6DxeDriverBindingSupported (
);
return Status;
}
/**
@@ -882,27 +877,27 @@ HttpBootIp6DxeDriverBindingStart (
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
)
{
EFI_STATUS Status;
HTTP_BOOT_PRIVATE_DATA *Private;
EFI_DEV_PATH *Node;
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
UINT32 *Id;
BOOLEAN Ipv6Available;
BOOLEAN FirstStart;
EFI_STATUS Status;
HTTP_BOOT_PRIVATE_DATA *Private;
EFI_DEV_PATH *Node;
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
UINT32 *Id;
BOOLEAN Ipv6Available;
BOOLEAN FirstStart;
FirstStart = FALSE;
Status = gBS->OpenProtocol (
ControllerHandle,
&gEfiCallerIdGuid,
(VOID **) &Id,
(VOID **)&Id,
This->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
if (!EFI_ERROR (Status)) {
Private = HTTP_BOOT_PRIVATE_DATA_FROM_ID(Id);
Private = HTTP_BOOT_PRIVATE_DATA_FROM_ID (Id);
} else {
FirstStart = TRUE;
@@ -913,7 +908,8 @@ HttpBootIp6DxeDriverBindingStart (
if (Private == NULL) {
return EFI_OUT_OF_RESOURCES;
}
Private->Signature = HTTP_BOOT_PRIVATE_DATA_SIGNATURE;
Private->Signature = HTTP_BOOT_PRIVATE_DATA_SIGNATURE;
Private->Controller = ControllerHandle;
InitializeListHead (&Private->CacheList);
//
@@ -922,7 +918,7 @@ HttpBootIp6DxeDriverBindingStart (
Status = gBS->OpenProtocol (
ControllerHandle,
&gEfiNetworkInterfaceIdentifierProtocolGuid_31,
(VOID **) &Private->Nii,
(VOID **)&Private->Nii,
This->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
@@ -937,7 +933,7 @@ HttpBootIp6DxeDriverBindingStart (
Status = gBS->OpenProtocol (
ControllerHandle,
&gEfiDevicePathProtocolGuid,
(VOID **) &Private->ParentDevicePath,
(VOID **)&Private->ParentDevicePath,
This->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
@@ -967,7 +963,6 @@ HttpBootIp6DxeDriverBindingStart (
if (EFI_ERROR (Status)) {
goto ON_ERROR;
}
}
//
@@ -999,6 +994,7 @@ HttpBootIp6DxeDriverBindingStart (
Status = EFI_OUT_OF_RESOURCES;
goto ON_ERROR;
}
Private->Ip6Nic->Private = Private;
Private->Ip6Nic->ImageHandle = This->DriverBindingHandle;
Private->Ip6Nic->Signature = HTTP_BOOT_VIRTUAL_NIC_SIGNATURE;
@@ -1018,7 +1014,7 @@ HttpBootIp6DxeDriverBindingStart (
Status = gBS->OpenProtocol (
Private->Dhcp6Child,
&gEfiDhcp6ProtocolGuid,
(VOID **) &Private->Dhcp6,
(VOID **)&Private->Dhcp6,
This->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_BY_DRIVER
@@ -1031,11 +1027,11 @@ HttpBootIp6DxeDriverBindingStart (
// Create Ip6 child and open Ip6 protocol for background ICMP packets.
//
Status = NetLibCreateServiceChild (
ControllerHandle,
This->DriverBindingHandle,
&gEfiIp6ServiceBindingProtocolGuid,
&Private->Ip6Child
);
ControllerHandle,
This->DriverBindingHandle,
&gEfiIp6ServiceBindingProtocolGuid,
&Private->Ip6Child
);
if (EFI_ERROR (Status)) {
goto ON_ERROR;
}
@@ -1043,7 +1039,7 @@ HttpBootIp6DxeDriverBindingStart (
Status = gBS->OpenProtocol (
Private->Ip6Child,
&gEfiIp6ProtocolGuid,
(VOID **) &Private->Ip6,
(VOID **)&Private->Ip6,
This->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_BY_DRIVER
@@ -1058,7 +1054,7 @@ HttpBootIp6DxeDriverBindingStart (
Status = gBS->OpenProtocol (
ControllerHandle,
&gEfiIp6ConfigProtocolGuid,
(VOID **) &Private->Ip6Config,
(VOID **)&Private->Ip6Config,
This->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
@@ -1075,12 +1071,13 @@ HttpBootIp6DxeDriverBindingStart (
Status = EFI_OUT_OF_RESOURCES;
goto ON_ERROR;
}
Node->Ipv6.Header.Type = MESSAGING_DEVICE_PATH;
Node->Ipv6.Header.Type = MESSAGING_DEVICE_PATH;
Node->Ipv6.Header.SubType = MSG_IPv6_DP;
Node->Ipv6.PrefixLength = IP6_PREFIX_LENGTH;
Node->Ipv6.PrefixLength = IP6_PREFIX_LENGTH;
SetDevicePathNodeLength (Node, sizeof (IPv6_DEVICE_PATH));
DevicePath = AppendDevicePathNode(Private->ParentDevicePath, (EFI_DEVICE_PATH*) Node);
FreePool(Node);
DevicePath = AppendDevicePathNode (Private->ParentDevicePath, (EFI_DEVICE_PATH *)Node);
FreePool (Node);
if (DevicePath == NULL) {
Status = EFI_OUT_OF_RESOURCES;
goto ON_ERROR;
@@ -1094,10 +1091,11 @@ HttpBootIp6DxeDriverBindingStart (
Status = EFI_OUT_OF_RESOURCES;
goto ON_ERROR;
}
Node->DevPath.Type = MESSAGING_DEVICE_PATH;
Node->DevPath.Type = MESSAGING_DEVICE_PATH;
Node->DevPath.SubType = MSG_URI_DP;
SetDevicePathNodeLength (Node, sizeof (EFI_DEVICE_PATH_PROTOCOL));
Private->Ip6Nic->DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL*) Node);
Private->Ip6Nic->DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)Node);
FreePool (Node);
FreePool (DevicePath);
if (Private->Ip6Nic->DevicePath == NULL) {
@@ -1128,7 +1126,7 @@ HttpBootIp6DxeDriverBindingStart (
Status = gBS->OpenProtocol (
ControllerHandle,
&gEfiCallerIdGuid,
(VOID **) &Id,
(VOID **)&Id,
This->DriverBindingHandle,
Private->Ip6Nic->Controller,
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
@@ -1149,7 +1147,7 @@ ON_ERROR:
);
}
HttpBootDestroyIp6Children(This, Private);
HttpBootDestroyIp6Children (This, Private);
HttpBootConfigFormUnload (Private);
if (FirstStart) {
@@ -1195,11 +1193,11 @@ HttpBootIp6DxeDriverBindingStop (
IN EFI_HANDLE *ChildHandleBuffer OPTIONAL
)
{
EFI_STATUS Status;
EFI_LOAD_FILE_PROTOCOL *LoadFile;
HTTP_BOOT_PRIVATE_DATA *Private;
EFI_HANDLE NicHandle;
UINT32 *Id;
EFI_STATUS Status;
EFI_LOAD_FILE_PROTOCOL *LoadFile;
HTTP_BOOT_PRIVATE_DATA *Private;
EFI_HANDLE NicHandle;
UINT32 *Id;
//
// Try to get the Load File Protocol from the controller handle.
@@ -1207,7 +1205,7 @@ HttpBootIp6DxeDriverBindingStop (
Status = gBS->OpenProtocol (
ControllerHandle,
&gEfiLoadFileProtocolGuid,
(VOID **) &LoadFile,
(VOID **)&LoadFile,
This->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
@@ -1227,7 +1225,7 @@ HttpBootIp6DxeDriverBindingStop (
Status = gBS->OpenProtocol (
NicHandle,
&gEfiCallerIdGuid,
(VOID **) &Id,
(VOID **)&Id,
This->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
@@ -1235,9 +1233,10 @@ HttpBootIp6DxeDriverBindingStop (
if (EFI_ERROR (Status)) {
return Status;
}
Private = HTTP_BOOT_PRIVATE_DATA_FROM_ID (Id);
} else {
Private = HTTP_BOOT_PRIVATE_DATA_FROM_LOADFILE (LoadFile);
Private = HTTP_BOOT_PRIVATE_DATA_FROM_LOADFILE (LoadFile);
NicHandle = Private->Controller;
}
@@ -1245,7 +1244,7 @@ HttpBootIp6DxeDriverBindingStop (
// Disable the HTTP boot function.
//
Status = HttpBootStop (Private);
if (Status != EFI_SUCCESS && Status != EFI_NOT_STARTED) {
if ((Status != EFI_SUCCESS) && (Status != EFI_NOT_STARTED)) {
return Status;
}
@@ -1254,7 +1253,7 @@ HttpBootIp6DxeDriverBindingStop (
//
HttpBootDestroyIp6Children (This, Private);
if (Private->Ip4Nic == NULL && Private->Ip6Nic == NULL) {
if ((Private->Ip4Nic == NULL) && (Private->Ip6Nic == NULL)) {
//
// Release the cached data.
//
@@ -1271,11 +1270,11 @@ HttpBootIp6DxeDriverBindingStop (
&Private->Id
);
FreePool (Private);
}
return EFI_SUCCESS;
}
/**
This is the declaration of an EFI image entry point. This entry point is
the same for UEFI Applications, UEFI OS Loaders, and UEFI Drivers including
@@ -1295,7 +1294,7 @@ HttpBootDxeDriverEntryPoint (
IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
EFI_STATUS Status;
//
// Install UEFI Driver Model protocol(s).
@@ -1321,12 +1320,12 @@ HttpBootDxeDriverEntryPoint (
&gHttpBootDxeComponentName2
);
if (EFI_ERROR (Status)) {
EfiLibUninstallDriverBindingComponentName2(
EfiLibUninstallDriverBindingComponentName2 (
&gHttpBootIp4DxeDriverBinding,
&gHttpBootDxeComponentName,
&gHttpBootDxeComponentName2
);
}
return Status;
}

View File

@@ -75,22 +75,22 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
// Standard Media Types defined in
// http://www.iana.org/assignments/media-types
//
#define HTTP_CONTENT_TYPE_APP_EFI "application/efi"
#define HTTP_CONTENT_TYPE_APP_IMG "application/vnd.efi-img"
#define HTTP_CONTENT_TYPE_APP_ISO "application/vnd.efi-iso"
#define HTTP_CONTENT_TYPE_APP_EFI "application/efi"
#define HTTP_CONTENT_TYPE_APP_IMG "application/vnd.efi-img"
#define HTTP_CONTENT_TYPE_APP_ISO "application/vnd.efi-iso"
//
// Protocol instances
//
extern EFI_DRIVER_BINDING_PROTOCOL gHttpBootDxeDriverBinding;
extern EFI_COMPONENT_NAME2_PROTOCOL gHttpBootDxeComponentName2;
extern EFI_COMPONENT_NAME_PROTOCOL gHttpBootDxeComponentName;
extern EFI_DRIVER_BINDING_PROTOCOL gHttpBootDxeDriverBinding;
extern EFI_COMPONENT_NAME2_PROTOCOL gHttpBootDxeComponentName2;
extern EFI_COMPONENT_NAME_PROTOCOL gHttpBootDxeComponentName;
//
// Private data structure
//
typedef struct _HTTP_BOOT_PRIVATE_DATA HTTP_BOOT_PRIVATE_DATA;
typedef struct _HTTP_BOOT_VIRTUAL_NIC HTTP_BOOT_VIRTUAL_NIC;
typedef struct _HTTP_BOOT_PRIVATE_DATA HTTP_BOOT_PRIVATE_DATA;
typedef struct _HTTP_BOOT_VIRTUAL_NIC HTTP_BOOT_VIRTUAL_NIC;
typedef enum {
ImageTypeEfi,
@@ -111,17 +111,17 @@ typedef enum {
#include "HttpBootConfig.h"
typedef union {
HTTP_BOOT_DHCP4_PACKET_CACHE Dhcp4;
HTTP_BOOT_DHCP6_PACKET_CACHE Dhcp6;
HTTP_BOOT_DHCP4_PACKET_CACHE Dhcp4;
HTTP_BOOT_DHCP6_PACKET_CACHE Dhcp6;
} HTTP_BOOT_DHCP_PACKET_CACHE;
struct _HTTP_BOOT_VIRTUAL_NIC {
UINT32 Signature;
EFI_HANDLE Controller;
EFI_HANDLE ImageHandle;
EFI_LOAD_FILE_PROTOCOL LoadFile;
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
HTTP_BOOT_PRIVATE_DATA *Private;
UINT32 Signature;
EFI_HANDLE Controller;
EFI_HANDLE ImageHandle;
EFI_LOAD_FILE_PROTOCOL LoadFile;
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
HTTP_BOOT_PRIVATE_DATA *Private;
};
#define HTTP_BOOT_PRIVATE_DATA_FROM_CALLBACK_INFO(Callback) \
@@ -141,87 +141,86 @@ struct _HTTP_BOOT_VIRTUAL_NIC {
)
struct _HTTP_BOOT_PRIVATE_DATA {
UINT32 Signature;
EFI_HANDLE Controller;
UINT32 Signature;
EFI_HANDLE Controller;
HTTP_BOOT_VIRTUAL_NIC *Ip4Nic;
HTTP_BOOT_VIRTUAL_NIC *Ip6Nic;
HTTP_BOOT_VIRTUAL_NIC *Ip4Nic;
HTTP_BOOT_VIRTUAL_NIC *Ip6Nic;
//
// Consumed children
//
EFI_HANDLE Ip6Child;
EFI_HANDLE Dhcp4Child;
EFI_HANDLE Dhcp6Child;
HTTP_IO HttpIo;
BOOLEAN HttpCreated;
EFI_HANDLE Ip6Child;
EFI_HANDLE Dhcp4Child;
EFI_HANDLE Dhcp6Child;
HTTP_IO HttpIo;
BOOLEAN HttpCreated;
//
// Consumed protocol
//
EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL *Nii;
EFI_IP6_PROTOCOL *Ip6;
EFI_IP4_CONFIG2_PROTOCOL *Ip4Config2;
EFI_IP6_CONFIG_PROTOCOL *Ip6Config;
EFI_DHCP4_PROTOCOL *Dhcp4;
EFI_DHCP6_PROTOCOL *Dhcp6;
EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;
EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL *Nii;
EFI_IP6_PROTOCOL *Ip6;
EFI_IP4_CONFIG2_PROTOCOL *Ip4Config2;
EFI_IP6_CONFIG_PROTOCOL *Ip6Config;
EFI_DHCP4_PROTOCOL *Dhcp4;
EFI_DHCP6_PROTOCOL *Dhcp6;
EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;
//
// Produced protocol
//
EFI_LOAD_FILE_PROTOCOL LoadFile;
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
UINT32 Id;
EFI_HTTP_BOOT_CALLBACK_PROTOCOL *HttpBootCallback;
EFI_HTTP_BOOT_CALLBACK_PROTOCOL LoadFileCallback;
EFI_LOAD_FILE_PROTOCOL LoadFile;
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
UINT32 Id;
EFI_HTTP_BOOT_CALLBACK_PROTOCOL *HttpBootCallback;
EFI_HTTP_BOOT_CALLBACK_PROTOCOL LoadFileCallback;
//
// Data for the default HTTP Boot callback protocol
//
UINT64 FileSize;
UINT64 ReceivedSize;
UINT32 Percentage;
UINT64 FileSize;
UINT64 ReceivedSize;
UINT32 Percentage;
//
// HII callback info block
//
HTTP_BOOT_FORM_CALLBACK_INFO CallbackInfo;
HTTP_BOOT_FORM_CALLBACK_INFO CallbackInfo;
//
// Mode data
//
BOOLEAN UsingIpv6;
BOOLEAN Started;
EFI_IP_ADDRESS StationIp;
EFI_IP_ADDRESS SubnetMask;
EFI_IP_ADDRESS GatewayIp;
EFI_IP_ADDRESS ServerIp;
UINT16 Port;
UINT32 DnsServerCount;
EFI_IP_ADDRESS *DnsServerIp;
BOOLEAN UsingIpv6;
BOOLEAN Started;
EFI_IP_ADDRESS StationIp;
EFI_IP_ADDRESS SubnetMask;
EFI_IP_ADDRESS GatewayIp;
EFI_IP_ADDRESS ServerIp;
UINT16 Port;
UINT32 DnsServerCount;
EFI_IP_ADDRESS *DnsServerIp;
//
// The URI string attempt to download through HTTP, may point to
// the memory in cached DHCP offer, or to the memory in FilePathUri.
//
CHAR8 *BootFileUri;
VOID *BootFileUriParser;
UINTN BootFileSize;
BOOLEAN NoGateway;
HTTP_BOOT_IMAGE_TYPE ImageType;
CHAR8 *BootFileUri;
VOID *BootFileUriParser;
UINTN BootFileSize;
BOOLEAN NoGateway;
HTTP_BOOT_IMAGE_TYPE ImageType;
//
// URI string extracted from the input FilePath parameter.
//
CHAR8 *FilePathUri;
VOID *FilePathUriParser;
CHAR8 *FilePathUri;
VOID *FilePathUriParser;
//
// Cached HTTP data
//
LIST_ENTRY CacheList;
LIST_ENTRY CacheList;
//
// Cached DHCP offer
@@ -252,20 +251,20 @@ struct _HTTP_BOOT_PRIVATE_DATA {
// (OfferIndex is 0-based.)
//
//
UINT32 SelectIndex;
UINT32 SelectProxyType;
HTTP_BOOT_DHCP_PACKET_CACHE OfferBuffer[HTTP_BOOT_OFFER_MAX_NUM];
UINT32 OfferNum;
UINT32 OfferCount[HttpOfferTypeMax];
UINT32 OfferIndex[HttpOfferTypeMax][HTTP_BOOT_OFFER_MAX_NUM];
UINT32 SelectIndex;
UINT32 SelectProxyType;
HTTP_BOOT_DHCP_PACKET_CACHE OfferBuffer[HTTP_BOOT_OFFER_MAX_NUM];
UINT32 OfferNum;
UINT32 OfferCount[HttpOfferTypeMax];
UINT32 OfferIndex[HttpOfferTypeMax][HTTP_BOOT_OFFER_MAX_NUM];
};
#define HTTP_BOOT_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('H', 'B', 'P', 'D')
#define HTTP_BOOT_VIRTUAL_NIC_SIGNATURE SIGNATURE_32 ('H', 'B', 'V', 'N')
#define HTTP_BOOT_PRIVATE_DATA_FROM_LOADFILE(a) CR (a, HTTP_BOOT_PRIVATE_DATA, LoadFile, HTTP_BOOT_PRIVATE_DATA_SIGNATURE)
#define HTTP_BOOT_PRIVATE_DATA_FROM_ID(a) CR (a, HTTP_BOOT_PRIVATE_DATA, Id, HTTP_BOOT_PRIVATE_DATA_SIGNATURE)
#define HTTP_BOOT_VIRTUAL_NIC_FROM_LOADFILE(a) CR (a, HTTP_BOOT_VIRTUAL_NIC, LoadFile, HTTP_BOOT_VIRTUAL_NIC_SIGNATURE)
extern EFI_LOAD_FILE_PROTOCOL gHttpBootDxeLoadFile;
#define HTTP_BOOT_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('H', 'B', 'P', 'D')
#define HTTP_BOOT_VIRTUAL_NIC_SIGNATURE SIGNATURE_32 ('H', 'B', 'V', 'N')
#define HTTP_BOOT_PRIVATE_DATA_FROM_LOADFILE(a) CR (a, HTTP_BOOT_PRIVATE_DATA, LoadFile, HTTP_BOOT_PRIVATE_DATA_SIGNATURE)
#define HTTP_BOOT_PRIVATE_DATA_FROM_ID(a) CR (a, HTTP_BOOT_PRIVATE_DATA, Id, HTTP_BOOT_PRIVATE_DATA_SIGNATURE)
#define HTTP_BOOT_VIRTUAL_NIC_FROM_LOADFILE(a) CR (a, HTTP_BOOT_VIRTUAL_NIC, LoadFile, HTTP_BOOT_VIRTUAL_NIC_SIGNATURE)
extern EFI_LOAD_FILE_PROTOCOL gHttpBootDxeLoadFile;
/**
Tests to see if this driver supports a given controller. If a child device is provided,
@@ -522,4 +521,5 @@ HttpBootIp6DxeDriverBindingStop (
IN UINTN NumberOfChildren,
IN EFI_HANDLE *ChildHandleBuffer OPTIONAL
);
#endif

View File

@@ -20,11 +20,11 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
**/
EFI_STATUS
HttpBootInstallCallback (
IN HTTP_BOOT_PRIVATE_DATA *Private
IN HTTP_BOOT_PRIVATE_DATA *Private
)
{
EFI_STATUS Status;
EFI_HANDLE ControllerHandle;
EFI_STATUS Status;
EFI_HANDLE ControllerHandle;
if (!Private->UsingIpv6) {
ControllerHandle = Private->Ip4Nic->Controller;
@@ -38,10 +38,9 @@ HttpBootInstallCallback (
Status = gBS->HandleProtocol (
ControllerHandle,
&gEfiHttpBootCallbackProtocolGuid,
(VOID **) &Private->HttpBootCallback
(VOID **)&Private->HttpBootCallback
);
if (Status == EFI_UNSUPPORTED) {
CopyMem (
&Private->LoadFileCallback,
&gHttpBootDxeHttpBootCallback,
@@ -60,6 +59,7 @@ HttpBootInstallCallback (
if (EFI_ERROR (Status)) {
return Status;
}
Private->HttpBootCallback = &Private->LoadFileCallback;
}
@@ -74,15 +74,15 @@ HttpBootInstallCallback (
**/
VOID
HttpBootUninstallCallback (
IN HTTP_BOOT_PRIVATE_DATA *Private
IN HTTP_BOOT_PRIVATE_DATA *Private
)
{
if (Private->HttpBootCallback == &Private->LoadFileCallback) {
gBS->UninstallProtocolInterface (
Private->Controller,
&gEfiHttpBootCallbackProtocolGuid,
&Private->HttpBootCallback
);
Private->Controller,
&gEfiHttpBootCallbackProtocolGuid,
&Private->HttpBootCallback
);
Private->HttpBootCallback = NULL;
}
}
@@ -108,18 +108,18 @@ HttpBootUninstallCallback (
**/
EFI_STATUS
HttpBootStart (
IN HTTP_BOOT_PRIVATE_DATA *Private,
IN BOOLEAN UsingIpv6,
IN EFI_DEVICE_PATH_PROTOCOL *FilePath
IN HTTP_BOOT_PRIVATE_DATA *Private,
IN BOOLEAN UsingIpv6,
IN EFI_DEVICE_PATH_PROTOCOL *FilePath
)
{
UINTN Index;
EFI_STATUS Status;
CHAR8 *Uri;
UINTN Index;
EFI_STATUS Status;
CHAR8 *Uri;
Uri = NULL;
if (Private == NULL || FilePath == NULL) {
if ((Private == NULL) || (FilePath == NULL)) {
return EFI_INVALID_PARAMETER;
}
@@ -143,7 +143,8 @@ HttpBootStart (
// recorded before.
//
if ((UsingIpv6 != Private->UsingIpv6) ||
((Uri != NULL) && (AsciiStrCmp (Private->BootFileUri, Uri) != 0))) {
((Uri != NULL) && (AsciiStrCmp (Private->BootFileUri, Uri) != 0)))
{
//
// Restart is required, first stop then continue this start function.
//
@@ -152,6 +153,7 @@ HttpBootStart (
if (Uri != NULL) {
FreePool (Uri);
}
return Status;
}
} else {
@@ -161,6 +163,7 @@ HttpBootStart (
if (Uri != NULL) {
FreePool (Uri);
}
return EFI_ALREADY_STARTED;
}
}
@@ -168,14 +171,15 @@ HttpBootStart (
//
// Detect whether using ipv6 or not, and set it to the private data.
//
if (UsingIpv6 && Private->Ip6Nic != NULL) {
if (UsingIpv6 && (Private->Ip6Nic != NULL)) {
Private->UsingIpv6 = TRUE;
} else if (!UsingIpv6 && Private->Ip4Nic != NULL) {
} else if (!UsingIpv6 && (Private->Ip4Nic != NULL)) {
Private->UsingIpv6 = FALSE;
} else {
if (Uri != NULL) {
FreePool (Uri);
}
return EFI_UNSUPPORTED;
}
@@ -186,7 +190,7 @@ HttpBootStart (
if (Private->FilePathUri != NULL) {
Status = HttpParseUrl (
Private->FilePathUri,
(UINT32) AsciiStrLen (Private->FilePathUri),
(UINT32)AsciiStrLen (Private->FilePathUri),
FALSE,
&Private->FilePathUriParser
);
@@ -219,7 +223,8 @@ HttpBootStart (
return Status;
}
}
Private->Started = TRUE;
Private->Started = TRUE;
Print (L"\n>>Start HTTP Boot over IPv%d", Private->UsingIpv6 ? 6 : 4);
return EFI_SUCCESS;
@@ -239,10 +244,10 @@ HttpBootStart (
**/
EFI_STATUS
HttpBootDhcp (
IN HTTP_BOOT_PRIVATE_DATA *Private
IN HTTP_BOOT_PRIVATE_DATA *Private
)
{
EFI_STATUS Status;
EFI_STATUS Status;
if (Private == NULL) {
return EFI_INVALID_PARAMETER;
@@ -260,7 +265,7 @@ HttpBootDhcp (
//
Status = HttpBootDhcp4Dora (Private);
} else {
//
//
// Start S.A.R.R process to get a IPv6 address and other boot information.
//
Status = HttpBootDhcp6Sarr (Private);
@@ -294,19 +299,19 @@ HttpBootDhcp (
**/
EFI_STATUS
HttpBootLoadFile (
IN HTTP_BOOT_PRIVATE_DATA *Private,
IN OUT UINTN *BufferSize,
IN VOID *Buffer OPTIONAL,
OUT HTTP_BOOT_IMAGE_TYPE *ImageType
IN HTTP_BOOT_PRIVATE_DATA *Private,
IN OUT UINTN *BufferSize,
IN VOID *Buffer OPTIONAL,
OUT HTTP_BOOT_IMAGE_TYPE *ImageType
)
{
EFI_STATUS Status;
EFI_STATUS Status;
if (Private == NULL || ImageType == NULL || BufferSize == NULL ) {
if ((Private == NULL) || (ImageType == NULL) || (BufferSize == NULL)) {
return EFI_INVALID_PARAMETER;
}
if (*BufferSize != 0 && Buffer == NULL) {
if ((*BufferSize != 0) && (Buffer == NULL)) {
return EFI_INVALID_PARAMETER;
}
@@ -315,7 +320,7 @@ HttpBootLoadFile (
}
Status = HttpBootInstallCallback (Private);
if (EFI_ERROR(Status)) {
if (EFI_ERROR (Status)) {
goto ON_EXIT;
}
@@ -355,7 +360,7 @@ HttpBootLoadFile (
NULL,
&Private->ImageType
);
if (EFI_ERROR (Status) && Status != EFI_BUFFER_TOO_SMALL) {
if (EFI_ERROR (Status) && (Status != EFI_BUFFER_TOO_SMALL)) {
//
// Failed to get file size by HEAD method, may be trunked encoding, try HTTP GET method.
//
@@ -367,7 +372,7 @@ HttpBootLoadFile (
NULL,
&Private->ImageType
);
if (EFI_ERROR (Status) && Status != EFI_BUFFER_TOO_SMALL) {
if (EFI_ERROR (Status) && (Status != EFI_BUFFER_TOO_SMALL)) {
AsciiPrint ("\n Error: Could not retrieve NBP file size from HTTP server.\n");
goto ON_EXIT;
}
@@ -376,8 +381,8 @@ HttpBootLoadFile (
if (*BufferSize < Private->BootFileSize) {
*BufferSize = Private->BootFileSize;
*ImageType = Private->ImageType;
Status = EFI_BUFFER_TOO_SMALL;
*ImageType = Private->ImageType;
Status = EFI_BUFFER_TOO_SMALL;
goto ON_EXIT;
}
@@ -398,7 +403,7 @@ ON_EXIT:
if (EFI_ERROR (Status)) {
if (Status == EFI_ACCESS_DENIED) {
AsciiPrint ("\n Error: Could not establish connection with HTTP server.\n");
} else if (Status == EFI_BUFFER_TOO_SMALL && Buffer != NULL) {
} else if ((Status == EFI_BUFFER_TOO_SMALL) && (Buffer != NULL)) {
AsciiPrint ("\n Error: Buffer size is smaller than the requested file.\n");
} else if (Status == EFI_OUT_OF_RESOURCES) {
AsciiPrint ("\n Error: Could not allocate I/O buffers.\n");
@@ -429,10 +434,10 @@ ON_EXIT:
**/
EFI_STATUS
HttpBootStop (
IN HTTP_BOOT_PRIVATE_DATA *Private
IN HTTP_BOOT_PRIVATE_DATA *Private
)
{
UINTN Index;
UINTN Index;
if (Private == NULL) {
return EFI_INVALID_PARAMETER;
@@ -451,12 +456,12 @@ HttpBootStop (
ZeroMem (&Private->StationIp, sizeof (EFI_IP_ADDRESS));
ZeroMem (&Private->SubnetMask, sizeof (EFI_IP_ADDRESS));
ZeroMem (&Private->GatewayIp, sizeof (EFI_IP_ADDRESS));
Private->Port = 0;
Private->BootFileUri = NULL;
Private->Port = 0;
Private->BootFileUri = NULL;
Private->BootFileUriParser = NULL;
Private->BootFileSize = 0;
Private->SelectIndex = 0;
Private->SelectProxyType = HttpOfferTypeMax;
Private->BootFileSize = 0;
Private->SelectIndex = 0;
Private->SelectProxyType = HttpOfferTypeMax;
if (!Private->UsingIpv6) {
//
@@ -489,10 +494,10 @@ HttpBootStop (
Private->DnsServerIp = NULL;
}
if (Private->FilePathUri!= NULL) {
if (Private->FilePathUri != NULL) {
FreePool (Private->FilePathUri);
HttpUrlFreeParser (Private->FilePathUriParser);
Private->FilePathUri = NULL;
Private->FilePathUri = NULL;
Private->FilePathUriParser = NULL;
}
@@ -540,21 +545,21 @@ HttpBootStop (
EFI_STATUS
EFIAPI
HttpBootDxeLoadFile (
IN EFI_LOAD_FILE_PROTOCOL *This,
IN EFI_DEVICE_PATH_PROTOCOL *FilePath,
IN BOOLEAN BootPolicy,
IN OUT UINTN *BufferSize,
IN VOID *Buffer OPTIONAL
IN EFI_LOAD_FILE_PROTOCOL *This,
IN EFI_DEVICE_PATH_PROTOCOL *FilePath,
IN BOOLEAN BootPolicy,
IN OUT UINTN *BufferSize,
IN VOID *Buffer OPTIONAL
)
{
HTTP_BOOT_PRIVATE_DATA *Private;
HTTP_BOOT_VIRTUAL_NIC *VirtualNic;
EFI_STATUS MediaStatus;
BOOLEAN UsingIpv6;
EFI_STATUS Status;
HTTP_BOOT_IMAGE_TYPE ImageType;
HTTP_BOOT_PRIVATE_DATA *Private;
HTTP_BOOT_VIRTUAL_NIC *VirtualNic;
EFI_STATUS MediaStatus;
BOOLEAN UsingIpv6;
EFI_STATUS Status;
HTTP_BOOT_IMAGE_TYPE ImageType;
if (This == NULL || BufferSize == NULL || FilePath == NULL) {
if ((This == NULL) || (BufferSize == NULL) || (FilePath == NULL)) {
return EFI_INVALID_PARAMETER;
}
@@ -566,7 +571,7 @@ HttpBootDxeLoadFile (
}
VirtualNic = HTTP_BOOT_VIRTUAL_NIC_FROM_LOADFILE (This);
Private = VirtualNic->Private;
Private = VirtualNic->Private;
//
// Check media status before HTTP boot start
@@ -590,7 +595,7 @@ HttpBootDxeLoadFile (
// Initialize HTTP boot.
//
Status = HttpBootStart (Private, UsingIpv6, FilePath);
if (Status != EFI_SUCCESS && Status != EFI_ALREADY_STARTED) {
if ((Status != EFI_SUCCESS) && (Status != EFI_ALREADY_STARTED)) {
return Status;
}
@@ -598,20 +603,21 @@ HttpBootDxeLoadFile (
// Load the boot file.
//
ImageType = ImageTypeMax;
Status = HttpBootLoadFile (Private, BufferSize, Buffer, &ImageType);
Status = HttpBootLoadFile (Private, BufferSize, Buffer, &ImageType);
if (EFI_ERROR (Status)) {
if (Status == EFI_BUFFER_TOO_SMALL && (ImageType == ImageTypeVirtualCd || ImageType == ImageTypeVirtualDisk)) {
if ((Status == EFI_BUFFER_TOO_SMALL) && ((ImageType == ImageTypeVirtualCd) || (ImageType == ImageTypeVirtualDisk))) {
Status = EFI_WARN_FILE_SYSTEM;
} else if (Status != EFI_BUFFER_TOO_SMALL) {
HttpBootStop (Private);
}
return Status;
}
//
// Register the RAM Disk to the system if needed.
//
if (ImageType == ImageTypeVirtualCd || ImageType == ImageTypeVirtualDisk) {
if ((ImageType == ImageTypeVirtualCd) || (ImageType == ImageTypeVirtualDisk)) {
Status = HttpBootRegisterRamDisk (Private, *BufferSize, Buffer, ImageType);
if (!EFI_ERROR (Status)) {
Status = EFI_WARN_FILE_SYSTEM;
@@ -659,11 +665,11 @@ EFI_LOAD_FILE_PROTOCOL gHttpBootDxeLoadFile = {
EFI_STATUS
EFIAPI
HttpBootCallback (
IN EFI_HTTP_BOOT_CALLBACK_PROTOCOL *This,
IN EFI_HTTP_BOOT_CALLBACK_DATA_TYPE DataType,
IN BOOLEAN Received,
IN UINT32 DataLength,
IN VOID *Data OPTIONAL
IN EFI_HTTP_BOOT_CALLBACK_PROTOCOL *This,
IN EFI_HTTP_BOOT_CALLBACK_DATA_TYPE DataType,
IN BOOLEAN Received,
IN UINT32 DataLength,
IN VOID *Data OPTIONAL
)
{
EFI_HTTP_MESSAGE *HttpMessage;
@@ -671,89 +677,95 @@ HttpBootCallback (
HTTP_BOOT_PRIVATE_DATA *Private;
UINT32 Percentage;
Private = HTTP_BOOT_PRIVATE_DATA_FROM_CALLBACK_PROTOCOL(This);
Private = HTTP_BOOT_PRIVATE_DATA_FROM_CALLBACK_PROTOCOL (This);
switch (DataType) {
case HttpBootDhcp4:
case HttpBootDhcp6:
Print (L".");
break;
case HttpBootDhcp4:
case HttpBootDhcp6:
Print (L".");
break;
case HttpBootHttpRequest:
if (Data != NULL) {
HttpMessage = (EFI_HTTP_MESSAGE *) Data;
if (HttpMessage->Data.Request->Method == HttpMethodGet &&
HttpMessage->Data.Request->Url != NULL) {
Print (L"\n URI: %s\n", HttpMessage->Data.Request->Url);
case HttpBootHttpRequest:
if (Data != NULL) {
HttpMessage = (EFI_HTTP_MESSAGE *)Data;
if ((HttpMessage->Data.Request->Method == HttpMethodGet) &&
(HttpMessage->Data.Request->Url != NULL))
{
Print (L"\n URI: %s\n", HttpMessage->Data.Request->Url);
}
}
}
break;
case HttpBootHttpResponse:
if (Data != NULL) {
HttpMessage = (EFI_HTTP_MESSAGE *) Data;
break;
if (HttpMessage->Data.Response != NULL) {
if (HttpBootIsHttpRedirectStatusCode (HttpMessage->Data.Response->StatusCode)) {
//
// Server indicates the resource has been redirected to a different URL
// according to the section 6.4 of RFC7231 and the RFC 7538.
// Display the redirect information on the screen.
//
HttpHeader = HttpFindHeader (
HttpMessage->HeaderCount,
HttpMessage->Headers,
HTTP_HEADER_LOCATION
);
if (HttpHeader != NULL) {
Print (L"\n HTTP ERROR: Resource Redirected.\n New Location: %a\n", HttpHeader->FieldValue);
case HttpBootHttpResponse:
if (Data != NULL) {
HttpMessage = (EFI_HTTP_MESSAGE *)Data;
if (HttpMessage->Data.Response != NULL) {
if (HttpBootIsHttpRedirectStatusCode (HttpMessage->Data.Response->StatusCode)) {
//
// Server indicates the resource has been redirected to a different URL
// according to the section 6.4 of RFC7231 and the RFC 7538.
// Display the redirect information on the screen.
//
HttpHeader = HttpFindHeader (
HttpMessage->HeaderCount,
HttpMessage->Headers,
HTTP_HEADER_LOCATION
);
if (HttpHeader != NULL) {
Print (L"\n HTTP ERROR: Resource Redirected.\n New Location: %a\n", HttpHeader->FieldValue);
}
break;
}
break;
}
HttpHeader = HttpFindHeader (
HttpMessage->HeaderCount,
HttpMessage->Headers,
HTTP_HEADER_CONTENT_LENGTH
);
if (HttpHeader != NULL) {
Private->FileSize = AsciiStrDecimalToUintn (HttpHeader->FieldValue);
Private->ReceivedSize = 0;
Private->Percentage = 0;
}
}
HttpHeader = HttpFindHeader (
HttpMessage->HeaderCount,
HttpMessage->Headers,
HTTP_HEADER_CONTENT_LENGTH
);
if (HttpHeader != NULL) {
Private->FileSize = AsciiStrDecimalToUintn (HttpHeader->FieldValue);
Private->ReceivedSize = 0;
Private->Percentage = 0;
}
}
break;
break;
case HttpBootHttpEntityBody:
if (DataLength != 0) {
if (Private->FileSize != 0) {
//
// We already know the file size, print in percentage format.
//
if (Private->ReceivedSize == 0) {
Print (L" File Size: %lu Bytes\n", Private->FileSize);
}
Private->ReceivedSize += DataLength;
Percentage = (UINT32) DivU64x64Remainder (MultU64x32 (Private->ReceivedSize, 100), Private->FileSize, NULL);
if (Private->Percentage != Percentage) {
Private->Percentage = Percentage;
Print (L"\r Downloading...%d%%", Percentage);
}
} else {
//
// In some case we couldn't get the file size from the HTTP header, so we
// just print the downloaded file size.
//
Private->ReceivedSize += DataLength;
Print (L"\r Downloading...%lu Bytes", Private->ReceivedSize);
}
}
break;
case HttpBootHttpEntityBody:
if (DataLength != 0) {
if (Private->FileSize != 0) {
//
// We already know the file size, print in percentage format.
//
if (Private->ReceivedSize == 0) {
Print (L" File Size: %lu Bytes\n", Private->FileSize);
}
default:
break;
};
Private->ReceivedSize += DataLength;
Percentage = (UINT32)DivU64x64Remainder (MultU64x32 (Private->ReceivedSize, 100), Private->FileSize, NULL);
if (Private->Percentage != Percentage) {
Private->Percentage = Percentage;
Print (L"\r Downloading...%d%%", Percentage);
}
} else {
//
// In some case we couldn't get the file size from the HTTP header, so we
// just print the downloaded file size.
//
Private->ReceivedSize += DataLength;
Print (L"\r Downloading...%lu Bytes", Private->ReceivedSize);
}
}
break;
default:
break;
}
return EFI_SUCCESS;
}

View File

@@ -5,10 +5,11 @@ Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
#ifndef __EFI_HTTP_BOOT_IMPL_H__
#define __EFI_HTTP_BOOT_IMPL_H__
#define HTTP_BOOT_CHECK_MEDIA_WAITING_TIME EFI_TIMER_PERIOD_SECONDS(20)
#define HTTP_BOOT_CHECK_MEDIA_WAITING_TIME EFI_TIMER_PERIOD_SECONDS(20)
/**
Attempt to complete a DHCPv4 D.O.R.A or DHCPv6 S.R.A.A sequence to retrieve the boot resource information.
@@ -24,7 +25,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
**/
EFI_STATUS
HttpBootDhcp (
IN HTTP_BOOT_PRIVATE_DATA *Private
IN HTTP_BOOT_PRIVATE_DATA *Private
);
/**
@@ -40,7 +41,7 @@ HttpBootDhcp (
**/
EFI_STATUS
HttpBootStop (
IN HTTP_BOOT_PRIVATE_DATA *Private
IN HTTP_BOOT_PRIVATE_DATA *Private
);
extern EFI_HTTP_BOOT_CALLBACK_PROTOCOL gHttpBootDxeHttpBootCallback;

View File

@@ -9,7 +9,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include "HttpBootDxe.h"
/**
Get the Nic handle using any child handle in the IPv4 stack.
@@ -21,10 +20,10 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
**/
EFI_HANDLE
HttpBootGetNicByIp4Children (
IN EFI_HANDLE ControllerHandle
IN EFI_HANDLE ControllerHandle
)
{
EFI_HANDLE NicHandle;
EFI_HANDLE NicHandle;
NicHandle = NetLibGetNicHandle (ControllerHandle, &gEfiHttpProtocolGuid);
if (NicHandle == NULL) {
@@ -48,10 +47,11 @@ HttpBootGetNicByIp4Children (
**/
EFI_HANDLE
HttpBootGetNicByIp6Children (
IN EFI_HANDLE ControllerHandle
IN EFI_HANDLE ControllerHandle
)
{
EFI_HANDLE NicHandle;
EFI_HANDLE NicHandle;
NicHandle = NetLibGetNicHandle (ControllerHandle, &gEfiHttpProtocolGuid);
if (NicHandle == NULL) {
NicHandle = NetLibGetNicHandle (ControllerHandle, &gEfiDhcp6ProtocolGuid);
@@ -73,17 +73,17 @@ HttpBootGetNicByIp6Children (
**/
VOID
HttpBootUintnToAscDecWithFormat (
IN UINTN Number,
IN UINT8 *Buffer,
IN INTN Length
IN UINTN Number,
IN UINT8 *Buffer,
IN INTN Length
)
{
UINTN Remainder;
UINTN Remainder;
for (; Length > 0; Length--) {
Remainder = Number % 10;
Number /= 10;
Buffer[Length - 1] = (UINT8) ('0' + Remainder);
for ( ; Length > 0; Length--) {
Remainder = Number % 10;
Number /= 10;
Buffer[Length - 1] = (UINT8)('0' + Remainder);
}
}
@@ -95,10 +95,10 @@ HttpBootUintnToAscDecWithFormat (
**/
VOID
HttpBootShowIp4Addr (
IN EFI_IPv4_ADDRESS *Ip
IN EFI_IPv4_ADDRESS *Ip
)
{
UINTN Index;
UINTN Index;
for (Index = 0; Index < 4; Index++) {
AsciiPrint ("%d", Ip->Addr[Index]);
@@ -116,23 +116,25 @@ HttpBootShowIp4Addr (
**/
VOID
HttpBootShowIp6Addr (
IN EFI_IPv6_ADDRESS *Ip
IN EFI_IPv6_ADDRESS *Ip
)
{
UINTN Index;
UINTN Index;
for (Index = 0; Index < 16; Index++) {
if (Ip->Addr[Index] != 0) {
AsciiPrint ("%x", Ip->Addr[Index]);
}
Index++;
if (Index > 15) {
return;
}
if (((Ip->Addr[Index] & 0xf0) == 0) && (Ip->Addr[Index - 1] != 0)) {
AsciiPrint ("0");
}
AsciiPrint ("%x", Ip->Addr[Index]);
if (Index < 15) {
AsciiPrint (":");
@@ -148,142 +150,141 @@ HttpBootShowIp6Addr (
**/
VOID
HttpBootPrintErrorMessage (
EFI_HTTP_STATUS_CODE StatusCode
EFI_HTTP_STATUS_CODE StatusCode
)
{
AsciiPrint ("\n");
switch (StatusCode) {
case HTTP_STATUS_300_MULTIPLE_CHOICES:
AsciiPrint ("\n Redirection: 300 Multiple Choices");
break;
case HTTP_STATUS_300_MULTIPLE_CHOICES:
AsciiPrint ("\n Redirection: 300 Multiple Choices");
break;
case HTTP_STATUS_301_MOVED_PERMANENTLY:
AsciiPrint ("\n Redirection: 301 Moved Permanently");
break;
case HTTP_STATUS_301_MOVED_PERMANENTLY:
AsciiPrint ("\n Redirection: 301 Moved Permanently");
break;
case HTTP_STATUS_302_FOUND:
AsciiPrint ("\n Redirection: 302 Found");
break;
case HTTP_STATUS_302_FOUND:
AsciiPrint ("\n Redirection: 302 Found");
break;
case HTTP_STATUS_303_SEE_OTHER:
AsciiPrint ("\n Redirection: 303 See Other");
break;
case HTTP_STATUS_303_SEE_OTHER:
AsciiPrint ("\n Redirection: 303 See Other");
break;
case HTTP_STATUS_304_NOT_MODIFIED:
AsciiPrint ("\n Redirection: 304 Not Modified");
break;
case HTTP_STATUS_304_NOT_MODIFIED:
AsciiPrint ("\n Redirection: 304 Not Modified");
break;
case HTTP_STATUS_305_USE_PROXY:
AsciiPrint ("\n Redirection: 305 Use Proxy");
break;
case HTTP_STATUS_305_USE_PROXY:
AsciiPrint ("\n Redirection: 305 Use Proxy");
break;
case HTTP_STATUS_307_TEMPORARY_REDIRECT:
AsciiPrint ("\n Redirection: 307 Temporary Redirect");
break;
case HTTP_STATUS_307_TEMPORARY_REDIRECT:
AsciiPrint ("\n Redirection: 307 Temporary Redirect");
break;
case HTTP_STATUS_308_PERMANENT_REDIRECT:
AsciiPrint ("\n Redirection: 308 Permanent Redirect");
break;
case HTTP_STATUS_308_PERMANENT_REDIRECT:
AsciiPrint ("\n Redirection: 308 Permanent Redirect");
break;
case HTTP_STATUS_400_BAD_REQUEST:
AsciiPrint ("\n Client Error: 400 Bad Request");
break;
case HTTP_STATUS_400_BAD_REQUEST:
AsciiPrint ("\n Client Error: 400 Bad Request");
break;
case HTTP_STATUS_401_UNAUTHORIZED:
AsciiPrint ("\n Client Error: 401 Unauthorized");
break;
case HTTP_STATUS_401_UNAUTHORIZED:
AsciiPrint ("\n Client Error: 401 Unauthorized");
break;
case HTTP_STATUS_402_PAYMENT_REQUIRED:
AsciiPrint ("\n Client Error: 402 Payment Required");
break;
case HTTP_STATUS_402_PAYMENT_REQUIRED:
AsciiPrint ("\n Client Error: 402 Payment Required");
break;
case HTTP_STATUS_403_FORBIDDEN:
AsciiPrint ("\n Client Error: 403 Forbidden");
break;
case HTTP_STATUS_403_FORBIDDEN:
AsciiPrint ("\n Client Error: 403 Forbidden");
break;
case HTTP_STATUS_404_NOT_FOUND:
AsciiPrint ("\n Client Error: 404 Not Found");
break;
case HTTP_STATUS_404_NOT_FOUND:
AsciiPrint ("\n Client Error: 404 Not Found");
break;
case HTTP_STATUS_405_METHOD_NOT_ALLOWED:
AsciiPrint ("\n Client Error: 405 Method Not Allowed");
break;
case HTTP_STATUS_405_METHOD_NOT_ALLOWED:
AsciiPrint ("\n Client Error: 405 Method Not Allowed");
break;
case HTTP_STATUS_406_NOT_ACCEPTABLE:
AsciiPrint ("\n Client Error: 406 Not Acceptable");
break;
case HTTP_STATUS_406_NOT_ACCEPTABLE:
AsciiPrint ("\n Client Error: 406 Not Acceptable");
break;
case HTTP_STATUS_407_PROXY_AUTHENTICATION_REQUIRED:
AsciiPrint ("\n Client Error: 407 Proxy Authentication Required");
break;
case HTTP_STATUS_407_PROXY_AUTHENTICATION_REQUIRED:
AsciiPrint ("\n Client Error: 407 Proxy Authentication Required");
break;
case HTTP_STATUS_408_REQUEST_TIME_OUT:
AsciiPrint ("\n Client Error: 408 Request Timeout");
break;
case HTTP_STATUS_408_REQUEST_TIME_OUT:
AsciiPrint ("\n Client Error: 408 Request Timeout");
break;
case HTTP_STATUS_409_CONFLICT:
AsciiPrint ("\n Client Error: 409 Conflict");
break;
case HTTP_STATUS_409_CONFLICT:
AsciiPrint ("\n Client Error: 409 Conflict");
break;
case HTTP_STATUS_410_GONE:
AsciiPrint ("\n Client Error: 410 Gone");
break;
case HTTP_STATUS_410_GONE:
AsciiPrint ("\n Client Error: 410 Gone");
break;
case HTTP_STATUS_411_LENGTH_REQUIRED:
AsciiPrint ("\n Client Error: 411 Length Required");
break;
case HTTP_STATUS_411_LENGTH_REQUIRED:
AsciiPrint ("\n Client Error: 411 Length Required");
break;
case HTTP_STATUS_412_PRECONDITION_FAILED:
AsciiPrint ("\n Client Error: 412 Precondition Failed");
break;
case HTTP_STATUS_412_PRECONDITION_FAILED:
AsciiPrint ("\n Client Error: 412 Precondition Failed");
break;
case HTTP_STATUS_413_REQUEST_ENTITY_TOO_LARGE:
AsciiPrint ("\n Client Error: 413 Request Entity Too Large");
break;
case HTTP_STATUS_413_REQUEST_ENTITY_TOO_LARGE:
AsciiPrint ("\n Client Error: 413 Request Entity Too Large");
break;
case HTTP_STATUS_414_REQUEST_URI_TOO_LARGE:
AsciiPrint ("\n Client Error: 414 Request URI Too Long");
break;
case HTTP_STATUS_414_REQUEST_URI_TOO_LARGE:
AsciiPrint ("\n Client Error: 414 Request URI Too Long");
break;
case HTTP_STATUS_415_UNSUPPORTED_MEDIA_TYPE:
AsciiPrint ("\n Client Error: 415 Unsupported Media Type");
break;
case HTTP_STATUS_415_UNSUPPORTED_MEDIA_TYPE:
AsciiPrint ("\n Client Error: 415 Unsupported Media Type");
break;
case HTTP_STATUS_416_REQUESTED_RANGE_NOT_SATISFIED:
AsciiPrint ("\n Client Error: 416 Requested Range Not Satisfiable");
break;
case HTTP_STATUS_416_REQUESTED_RANGE_NOT_SATISFIED:
AsciiPrint ("\n Client Error: 416 Requested Range Not Satisfiable");
break;
case HTTP_STATUS_417_EXPECTATION_FAILED:
AsciiPrint ("\n Client Error: 417 Expectation Failed");
break;
case HTTP_STATUS_417_EXPECTATION_FAILED:
AsciiPrint ("\n Client Error: 417 Expectation Failed");
break;
case HTTP_STATUS_500_INTERNAL_SERVER_ERROR:
AsciiPrint ("\n Server Error: 500 Internal Server Error");
break;
case HTTP_STATUS_500_INTERNAL_SERVER_ERROR:
AsciiPrint ("\n Server Error: 500 Internal Server Error");
break;
case HTTP_STATUS_501_NOT_IMPLEMENTED:
AsciiPrint ("\n Server Error: 501 Not Implemented");
break;
case HTTP_STATUS_501_NOT_IMPLEMENTED:
AsciiPrint ("\n Server Error: 501 Not Implemented");
break;
case HTTP_STATUS_502_BAD_GATEWAY:
AsciiPrint ("\n Server Error: 502 Bad Gateway");
break;
case HTTP_STATUS_502_BAD_GATEWAY:
AsciiPrint ("\n Server Error: 502 Bad Gateway");
break;
case HTTP_STATUS_503_SERVICE_UNAVAILABLE:
AsciiPrint ("\n Server Error: 503 Service Unavailable");
break;
case HTTP_STATUS_503_SERVICE_UNAVAILABLE:
AsciiPrint ("\n Server Error: 503 Service Unavailable");
break;
case HTTP_STATUS_504_GATEWAY_TIME_OUT:
AsciiPrint ("\n Server Error: 504 Gateway Timeout");
break;
case HTTP_STATUS_504_GATEWAY_TIME_OUT:
AsciiPrint ("\n Server Error: 504 Gateway Timeout");
break;
case HTTP_STATUS_505_HTTP_VERSION_NOT_SUPPORTED:
AsciiPrint ("\n Server Error: 505 HTTP Version Not Supported");
break;
default: ;
case HTTP_STATUS_505_HTTP_VERSION_NOT_SUPPORTED:
AsciiPrint ("\n Server Error: 505 HTTP Version Not Supported");
break;
default:;
}
}
@@ -297,11 +298,11 @@ HttpBootPrintErrorMessage (
VOID
EFIAPI
HttpBootCommonNotify (
IN EFI_EVENT Event,
IN VOID *Context
IN EFI_EVENT Event,
IN VOID *Context
)
{
*((BOOLEAN *) Context) = TRUE;
*((BOOLEAN *)Context) = TRUE;
}
/**
@@ -317,38 +318,38 @@ HttpBootCommonNotify (
**/
EFI_STATUS
HttpBootDns (
IN HTTP_BOOT_PRIVATE_DATA *Private,
IN CHAR16 *HostName,
OUT EFI_IPv6_ADDRESS *IpAddress
IN HTTP_BOOT_PRIVATE_DATA *Private,
IN CHAR16 *HostName,
OUT EFI_IPv6_ADDRESS *IpAddress
)
{
EFI_STATUS Status;
EFI_DNS6_PROTOCOL *Dns6;
EFI_DNS6_CONFIG_DATA Dns6ConfigData;
EFI_DNS6_COMPLETION_TOKEN Token;
EFI_HANDLE Dns6Handle;
EFI_IP6_CONFIG_PROTOCOL *Ip6Config;
EFI_IPv6_ADDRESS *DnsServerList;
UINTN DnsServerListCount;
UINTN DataSize;
BOOLEAN IsDone;
EFI_STATUS Status;
EFI_DNS6_PROTOCOL *Dns6;
EFI_DNS6_CONFIG_DATA Dns6ConfigData;
EFI_DNS6_COMPLETION_TOKEN Token;
EFI_HANDLE Dns6Handle;
EFI_IP6_CONFIG_PROTOCOL *Ip6Config;
EFI_IPv6_ADDRESS *DnsServerList;
UINTN DnsServerListCount;
UINTN DataSize;
BOOLEAN IsDone;
DnsServerList = NULL;
DnsServerListCount = 0;
Dns6 = NULL;
Dns6Handle = NULL;
DnsServerList = NULL;
DnsServerListCount = 0;
Dns6 = NULL;
Dns6Handle = NULL;
ZeroMem (&Token, sizeof (EFI_DNS6_COMPLETION_TOKEN));
//
// Get DNS server list from EFI IPv6 Configuration protocol.
//
Status = gBS->HandleProtocol (Private->Controller, &gEfiIp6ConfigProtocolGuid, (VOID **) &Ip6Config);
Status = gBS->HandleProtocol (Private->Controller, &gEfiIp6ConfigProtocolGuid, (VOID **)&Ip6Config);
if (!EFI_ERROR (Status)) {
//
// Get the required size.
//
DataSize = 0;
Status = Ip6Config->GetData (Ip6Config, Ip6ConfigDataTypeDnsServer, &DataSize, NULL);
Status = Ip6Config->GetData (Ip6Config, Ip6ConfigDataTypeDnsServer, &DataSize, NULL);
if (Status == EFI_BUFFER_TOO_SMALL) {
DnsServerList = AllocatePool (DataSize);
if (DnsServerList == NULL) {
@@ -364,6 +365,7 @@ HttpBootDns (
}
}
}
//
// Create a DNSv6 child instance and get the protocol.
//
@@ -380,7 +382,7 @@ HttpBootDns (
Status = gBS->OpenProtocol (
Dns6Handle,
&gEfiDns6ProtocolGuid,
(VOID **) &Dns6,
(VOID **)&Dns6,
Private->Ip6Nic->ImageHandle,
Private->Controller,
EFI_OPEN_PROTOCOL_BY_DRIVER
@@ -397,11 +399,11 @@ HttpBootDns (
Dns6ConfigData.DnsServerList = DnsServerList;
Dns6ConfigData.EnableDnsCache = TRUE;
Dns6ConfigData.Protocol = EFI_IP_PROTO_UDP;
IP6_COPY_ADDRESS (&Dns6ConfigData.StationIp,&Private->StationIp.v6);
IP6_COPY_ADDRESS (&Dns6ConfigData.StationIp, &Private->StationIp.v6);
Status = Dns6->Configure (
Dns6,
&Dns6ConfigData
);
Dns6,
&Dns6ConfigData
);
if (EFI_ERROR (Status)) {
goto Exit;
}
@@ -443,25 +445,30 @@ HttpBootDns (
Status = EFI_DEVICE_ERROR;
goto Exit;
}
if (Token.RspData.H2AData->IpCount == 0 || Token.RspData.H2AData->IpList == NULL) {
if ((Token.RspData.H2AData->IpCount == 0) || (Token.RspData.H2AData->IpList == NULL)) {
Status = EFI_DEVICE_ERROR;
goto Exit;
}
//
// We just return the first IPv6 address from DNS protocol.
//
IP6_COPY_ADDRESS (IpAddress, Token.RspData.H2AData->IpList);
Status = EFI_SUCCESS;
}
Exit:
if (Token.Event != NULL) {
gBS->CloseEvent (Token.Event);
}
if (Token.RspData.H2AData != NULL) {
if (Token.RspData.H2AData->IpList != NULL) {
FreePool (Token.RspData.H2AData->IpList);
}
FreePool (Token.RspData.H2AData);
}
@@ -504,11 +511,11 @@ Exit:
**/
EFI_STATUS
HttpBootCheckUriScheme (
IN CHAR8 *Uri
IN CHAR8 *Uri
)
{
UINTN Index;
EFI_STATUS Status;
UINTN Index;
EFI_STATUS Status;
Status = EFI_SUCCESS;
@@ -519,7 +526,8 @@ HttpBootCheckUriScheme (
if (Uri[Index] == ':') {
break;
}
if (Uri[Index] >= 'A' && Uri[Index] <= 'Z') {
if ((Uri[Index] >= 'A') && (Uri[Index] <= 'Z')) {
Uri[Index] -= (CHAR8)('A' - 'a');
}
}
@@ -557,8 +565,8 @@ HttpBootCheckUriScheme (
**/
EFI_STATUS
HttpBootParseFilePath (
IN EFI_DEVICE_PATH_PROTOCOL *FilePath,
OUT CHAR8 **UriAddress
IN EFI_DEVICE_PATH_PROTOCOL *FilePath,
OUT CHAR8 **UriAddress
)
{
EFI_DEVICE_PATH_PROTOCOL *TempDevicePath;
@@ -578,28 +586,32 @@ HttpBootParseFilePath (
TempDevicePath = FilePath;
while (!IsDevicePathEnd (TempDevicePath)) {
if ((DevicePathType (TempDevicePath) == MESSAGING_DEVICE_PATH) &&
(DevicePathSubType (TempDevicePath) == MSG_URI_DP)) {
UriDevicePath = (URI_DEVICE_PATH*) TempDevicePath;
(DevicePathSubType (TempDevicePath) == MSG_URI_DP))
{
UriDevicePath = (URI_DEVICE_PATH *)TempDevicePath;
//
// UEFI Spec doesn't require the URI to be a NULL-terminated string
// So we allocate a new buffer and always append a '\0' to it.
//
UriStrLength = DevicePathNodeLength (UriDevicePath) - sizeof(EFI_DEVICE_PATH_PROTOCOL);
UriStrLength = DevicePathNodeLength (UriDevicePath) - sizeof (EFI_DEVICE_PATH_PROTOCOL);
if (UriStrLength == 0) {
//
// return a NULL UriAddress if it's a empty URI device path node.
//
break;
}
Uri = AllocatePool (UriStrLength + 1);
if (Uri == NULL) {
return EFI_OUT_OF_RESOURCES;
}
CopyMem (Uri, UriDevicePath->Uri, DevicePathNodeLength (UriDevicePath) - sizeof(EFI_DEVICE_PATH_PROTOCOL));
Uri[DevicePathNodeLength (UriDevicePath) - sizeof(EFI_DEVICE_PATH_PROTOCOL)] = '\0';
CopyMem (Uri, UriDevicePath->Uri, DevicePathNodeLength (UriDevicePath) - sizeof (EFI_DEVICE_PATH_PROTOCOL));
Uri[DevicePathNodeLength (UriDevicePath) - sizeof (EFI_DEVICE_PATH_PROTOCOL)] = '\0';
*UriAddress = Uri;
}
TempDevicePath = NextDevicePathNode (TempDevicePath);
}
@@ -625,23 +637,23 @@ HttpBootParseFilePath (
**/
EFI_STATUS
HttpBootCheckImageType (
IN CHAR8 *Uri,
IN VOID *UriParser,
IN UINTN HeaderCount,
IN EFI_HTTP_HEADER *Headers,
OUT HTTP_BOOT_IMAGE_TYPE *ImageType
IN CHAR8 *Uri,
IN VOID *UriParser,
IN UINTN HeaderCount,
IN EFI_HTTP_HEADER *Headers,
OUT HTTP_BOOT_IMAGE_TYPE *ImageType
)
{
EFI_STATUS Status;
EFI_HTTP_HEADER *Header;
CHAR8 *FilePath;
CHAR8 *FilePost;
EFI_STATUS Status;
EFI_HTTP_HEADER *Header;
CHAR8 *FilePath;
CHAR8 *FilePost;
if (Uri == NULL || UriParser == NULL || ImageType == NULL) {
if ((Uri == NULL) || (UriParser == NULL) || (ImageType == NULL)) {
return EFI_INVALID_PARAMETER;
}
if (HeaderCount != 0 && Headers == NULL) {
if ((HeaderCount != 0) && (Headers == NULL)) {
return EFI_INVALID_PARAMETER;
}
@@ -712,22 +724,22 @@ HttpBootCheckImageType (
**/
EFI_STATUS
HttpBootRegisterRamDisk (
IN HTTP_BOOT_PRIVATE_DATA *Private,
IN UINTN BufferSize,
IN VOID *Buffer,
IN HTTP_BOOT_IMAGE_TYPE ImageType
IN HTTP_BOOT_PRIVATE_DATA *Private,
IN UINTN BufferSize,
IN VOID *Buffer,
IN HTTP_BOOT_IMAGE_TYPE ImageType
)
{
EFI_RAM_DISK_PROTOCOL *RamDisk;
EFI_STATUS Status;
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
EFI_GUID *RamDiskType;
EFI_RAM_DISK_PROTOCOL *RamDisk;
EFI_STATUS Status;
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
EFI_GUID *RamDiskType;
ASSERT (Private != NULL);
ASSERT (Buffer != NULL);
ASSERT (BufferSize != 0);
Status = gBS->LocateProtocol (&gEfiRamDiskProtocolGuid, NULL, (VOID**) &RamDisk);
Status = gBS->LocateProtocol (&gEfiRamDiskProtocolGuid, NULL, (VOID **)&RamDisk);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "HTTP Boot: Couldn't find the RAM Disk protocol - %r\n", Status));
return Status;
@@ -742,12 +754,12 @@ HttpBootRegisterRamDisk (
}
Status = RamDisk->Register (
(UINTN)Buffer,
(UINT64)BufferSize,
RamDiskType,
Private->UsingIpv6 ? Private->Ip6Nic->DevicePath : Private->Ip4Nic->DevicePath,
&DevicePath
);
(UINTN)Buffer,
(UINT64)BufferSize,
RamDiskType,
Private->UsingIpv6 ? Private->Ip6Nic->DevicePath : Private->Ip4Nic->DevicePath,
&DevicePath
);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "HTTP Boot: Failed to register RAM Disk - %r\n", Status));
}
@@ -765,13 +777,14 @@ HttpBootRegisterRamDisk (
**/
BOOLEAN
HttpBootIsHttpRedirectStatusCode (
IN EFI_HTTP_STATUS_CODE StatusCode
IN EFI_HTTP_STATUS_CODE StatusCode
)
{
if (StatusCode == HTTP_STATUS_301_MOVED_PERMANENTLY ||
StatusCode == HTTP_STATUS_302_FOUND ||
StatusCode == HTTP_STATUS_307_TEMPORARY_REDIRECT ||
StatusCode == HTTP_STATUS_308_PERMANENT_REDIRECT) {
if ((StatusCode == HTTP_STATUS_301_MOVED_PERMANENTLY) ||
(StatusCode == HTTP_STATUS_302_FOUND) ||
(StatusCode == HTTP_STATUS_307_TEMPORARY_REDIRECT) ||
(StatusCode == HTTP_STATUS_308_PERMANENT_REDIRECT))
{
return TRUE;
}

View File

@@ -21,7 +21,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
**/
EFI_HANDLE
HttpBootGetNicByIp4Children (
IN EFI_HANDLE ControllerHandle
IN EFI_HANDLE ControllerHandle
);
/**
@@ -35,7 +35,7 @@ HttpBootGetNicByIp4Children (
**/
EFI_HANDLE
HttpBootGetNicByIp6Children (
IN EFI_HANDLE ControllerHandle
IN EFI_HANDLE ControllerHandle
);
/**
@@ -48,12 +48,11 @@ HttpBootGetNicByIp6Children (
**/
VOID
HttpBootUintnToAscDecWithFormat (
IN UINTN Number,
IN UINT8 *Buffer,
IN INTN Length
IN UINTN Number,
IN UINT8 *Buffer,
IN INTN Length
);
/**
This function is to display the IPv4 address.
@@ -62,7 +61,7 @@ HttpBootUintnToAscDecWithFormat (
**/
VOID
HttpBootShowIp4Addr (
IN EFI_IPv4_ADDRESS *Ip
IN EFI_IPv4_ADDRESS *Ip
);
/**
@@ -73,7 +72,7 @@ HttpBootShowIp4Addr (
**/
VOID
HttpBootShowIp6Addr (
IN EFI_IPv6_ADDRESS *Ip
IN EFI_IPv6_ADDRESS *Ip
);
/**
@@ -84,7 +83,7 @@ HttpBootShowIp6Addr (
**/
VOID
HttpBootPrintErrorMessage (
EFI_HTTP_STATUS_CODE StatusCode
EFI_HTTP_STATUS_CODE StatusCode
);
/**
@@ -100,9 +99,9 @@ HttpBootPrintErrorMessage (
**/
EFI_STATUS
HttpBootDns (
IN HTTP_BOOT_PRIVATE_DATA *Private,
IN CHAR16 *HostName,
OUT EFI_IPv6_ADDRESS *IpAddress
IN HTTP_BOOT_PRIVATE_DATA *Private,
IN CHAR16 *HostName,
OUT EFI_IPv6_ADDRESS *IpAddress
);
/**
@@ -115,8 +114,8 @@ HttpBootDns (
VOID
EFIAPI
HttpBootCommonNotify (
IN EFI_EVENT Event,
IN VOID *Context
IN EFI_EVENT Event,
IN VOID *Context
);
/**
@@ -131,7 +130,7 @@ HttpBootCommonNotify (
**/
EFI_STATUS
HttpBootCheckUriScheme (
IN CHAR8 *Uri
IN CHAR8 *Uri
);
/**
@@ -148,8 +147,8 @@ HttpBootCheckUriScheme (
**/
EFI_STATUS
HttpBootParseFilePath (
IN EFI_DEVICE_PATH_PROTOCOL *FilePath,
OUT CHAR8 **UriAddress
IN EFI_DEVICE_PATH_PROTOCOL *FilePath,
OUT CHAR8 **UriAddress
);
/**
@@ -171,11 +170,11 @@ HttpBootParseFilePath (
**/
EFI_STATUS
HttpBootCheckImageType (
IN CHAR8 *Uri,
IN VOID *UriParser,
IN UINTN HeaderCount,
IN EFI_HTTP_HEADER *Headers,
OUT HTTP_BOOT_IMAGE_TYPE *ImageType
IN CHAR8 *Uri,
IN VOID *UriParser,
IN UINTN HeaderCount,
IN EFI_HTTP_HEADER *Headers,
OUT HTTP_BOOT_IMAGE_TYPE *ImageType
);
/**
@@ -194,10 +193,10 @@ HttpBootCheckImageType (
**/
EFI_STATUS
HttpBootRegisterRamDisk (
IN HTTP_BOOT_PRIVATE_DATA *Private,
IN UINTN BufferSize,
IN VOID *Buffer,
IN HTTP_BOOT_IMAGE_TYPE ImageType
IN HTTP_BOOT_PRIVATE_DATA *Private,
IN UINTN BufferSize,
IN VOID *Buffer,
IN HTTP_BOOT_IMAGE_TYPE ImageType
);
/**
@@ -210,6 +209,7 @@ HttpBootRegisterRamDisk (
**/
BOOLEAN
HttpBootIsHttpRedirectStatusCode (
IN EFI_HTTP_STATUS_CODE StatusCode
IN EFI_HTTP_STATUS_CODE StatusCode
);
#endif