]> git.proxmox.com Git - mirror_edk2.git/blobdiff - NetworkPkg/HttpBootDxe/HttpBootConfig.c
NetworkPkg: Fix HII related problem in HTTP boot driver.
[mirror_edk2.git] / NetworkPkg / HttpBootDxe / HttpBootConfig.c
index 0c1ff43d5c84a856211fbec5cda329a94a450f91..e7dd5db4dbe2a7ecefbe9d946b11c969c6f44f76 100644 (file)
@@ -351,6 +351,7 @@ HttpBootFormExtractConfig (
   //\r
   BufferSize = sizeof (HTTP_BOOT_CONFIG_IFR_NVDATA);\r
   ZeroMem (&CallbackInfo->HttpBootNvData, BufferSize);\r
+  StrCpyS (CallbackInfo->HttpBootNvData.Description, DESCRIPTION_STR_MAX_SIZE / sizeof (CHAR16), HTTP_BOOT_DEFAULT_DESCRIPTION_STR);\r
 \r
   ConfigRequest = Request;\r
   if ((Request == NULL) || (StrStr (Request, L"OFFSET") == NULL)) {\r
@@ -376,7 +377,6 @@ HttpBootFormExtractConfig (
                                 Results,\r
                                 Progress\r
                                 );\r
-  ASSERT_EFI_ERROR (Status);\r
   \r
   //\r
   // Free the allocated config request string.\r
@@ -487,14 +487,14 @@ HttpBootFormRouteConfig (
   //\r
   // Create a new boot option according to the configuration data.\r
   //\r
-  Status = HttpBootAddBootOption (\r
-             Private,\r
-             (CallbackInfo->HttpBootNvData.IpVersion == HTTP_BOOT_IP_VERSION_6) ? TRUE : FALSE,\r
-             CallbackInfo->HttpBootNvData.Description,\r
-             CallbackInfo->HttpBootNvData.Uri\r
-             );\r
+  HttpBootAddBootOption (\r
+    Private,\r
+    (CallbackInfo->HttpBootNvData.IpVersion == HTTP_BOOT_IP_VERSION_6) ? TRUE : FALSE,\r
+    CallbackInfo->HttpBootNvData.Description,\r
+    CallbackInfo->HttpBootNvData.Uri\r
+    );\r
   \r
-  return Status;\r
+  return EFI_SUCCESS;\r
 }\r
 \r
 /**\r
@@ -533,7 +533,66 @@ HttpBootFormCallback (
   OUT       EFI_BROWSER_ACTION_REQUEST       *ActionRequest\r
   )\r
 {\r
-  return EFI_UNSUPPORTED;\r
+  EFI_INPUT_KEY                   Key;\r
+  UINTN                           Index;\r
+  CHAR16                          *Uri;\r
+  HTTP_BOOT_FORM_CALLBACK_INFO    *CallbackInfo;\r
+  \r
+  if (This == NULL || Value == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  CallbackInfo = HTTP_BOOT_FORM_CALLBACK_INFO_FROM_CONFIG_ACCESS (This);\r
+  \r
+  if (Action != EFI_BROWSER_ACTION_CHANGING) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+  \r
+  switch (QuestionId) {\r
+  case KEY_INITIATOR_URI:\r
+    //\r
+    // Get user input URI string\r
+    //\r
+    Uri = HiiGetString (CallbackInfo->RegisteredHandle, Value->string, NULL);\r
+\r
+    //\r
+    // Convert the scheme to all lower case.\r
+    //\r
+    for (Index = 0; Index < StrLen (Uri); Index++) {\r
+      if (Uri[Index] == L':') {\r
+        break;\r
+      }\r
+      if (Uri[Index] >= L'A' && Uri[Index] <= L'Z') {\r
+        Uri[Index] -= (CHAR16)(L'A' - L'a');\r
+      }\r
+    }\r
+\r
+    //\r
+    // Set the converted URI string back\r
+    //\r
+    HiiSetString (CallbackInfo->RegisteredHandle, Value->string, Uri, NULL);\r
+\r
+    //\r
+    // We only accept http and https, pop up a message box for unsupported URI.\r
+    //\r
+    if ((StrnCmp (Uri, L"http://", 7) != 0) && (StrnCmp (Uri, L"https://", 7) != 0)) {\r
+      CreatePopUp (\r
+        EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,\r
+        &Key,\r
+        L"ERROR: Unsupported URI!",\r
+        L"Only supports HTTP and HTTPS",\r
+        NULL\r
+        );\r
+    }\r
+\r
+    FreePool (Uri);\r
+    break;\r
+\r
+  default:\r
+    break;\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
 }\r
 \r
 /**\r