diff options
Diffstat (limited to 'NetworkPkg/HttpBootDxe/HttpBootConfig.c')
-rw-r--r-- | NetworkPkg/HttpBootDxe/HttpBootConfig.c | 283 |
1 files changed, 145 insertions, 138 deletions
diff --git a/NetworkPkg/HttpBootDxe/HttpBootConfig.c b/NetworkPkg/HttpBootDxe/HttpBootConfig.c index 795e61b5b4..42d3fdc1fb 100644 --- a/NetworkPkg/HttpBootDxe/HttpBootConfig.c +++ b/NetworkPkg/HttpBootDxe/HttpBootConfig.c @@ -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;
-
- if (Progress == NULL || Results == NULL) {
+ 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)) {
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;
- }
-
- //
- // 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;
+ case KEY_INITIATOR_URI:
+ //
+ // Get user input URI string
+ //
+ Uri = HiiGetString (CallbackInfo->RegisteredHandle, Value->string, NULL);
+ if (Uri == NULL) {
+ return EFI_INVALID_PARAMETER;
}
- 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
- );
+ //
+ // 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);
- }
+ if (Uri != NULL) {
+ FreePool (Uri);
+ }
- if (AsciiUri != NULL) {
- FreePool (AsciiUri);
- }
+ if (AsciiUri != NULL) {
+ FreePool (AsciiUri);
+ }
- break;
+ 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.
//
|