]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ArmPlatformPkg/Bds/BdsHelper.c
ArmPlatformPkg/Bds: Change the GetHIInput/EditHIInput to always return a valid IP...
[mirror_edk2.git] / ArmPlatformPkg / Bds / BdsHelper.c
index 8553577cf1b1272f63b297033c390a25546a56e4..693bc7d12a1494ae2e87c9581857e88699da6662 100644 (file)
@@ -144,7 +144,9 @@ GetHIInputInteger (
   The function asks the user for an IPv4 address. If the input\r
   string defines a valid IPv4 address, the four bytes of the\r
   corresponding IPv4 address are extracted from the string and returned by\r
-  the function.\r
+  the function. As long as the user does not define a valid IP\r
+  address, he is asked for one. He can always escape by\r
+  pressing ESC.\r
 \r
   @param[out]  EFI_IP_ADDRESS  OutIpAddr  Returned IPv4 address. Valid if\r
                                           and only if the returned value\r
@@ -152,8 +154,6 @@ GetHIInputInteger (
 
   @retval  EFI_SUCCESS            Input completed\r
   @retval  EFI_ABORTED            Editing aborted by the user\r
-  @retval  EFI_INVALID_PARAMETER  The string returned by the user is\r
-                                  mal-formated\r
   @retval  EFI_OUT_OF_RESOURCES   Fail to perform the operation due to\r
                                   lack of resource\r
 **/\r
@@ -165,15 +165,20 @@ GetHIInputIP (
   EFI_STATUS  Status;\r
   CHAR16      CmdLine[48];\r
 \r
-  CmdLine[0] = '\0';\r
-  Status = EditHIInputStr (CmdLine, 48);\r
-  if (EFI_ERROR (Status)) {\r
-    return EFI_ABORTED;\r
-  }\r
-\r
-  Status = NetLibStrToIp4 (CmdLine, &OutIpAddr->v4);\r
+  while (TRUE) {\r
+    CmdLine[0] = '\0';\r
+    Status = EditHIInputStr (CmdLine, 48);\r
+    if (EFI_ERROR (Status)) {\r
+      return EFI_ABORTED;\r
+    }\r
 \r
-  return Status;\r
+    Status = NetLibStrToIp4 (CmdLine, &OutIpAddr->v4);\r
+    if (Status == EFI_INVALID_PARAMETER) {\r
+      Print (L"Invalid address\n");\r
+    } else {\r
+      return Status;\r
+    }\r
+  }\r
 }\r
 \r
 /**\r
@@ -183,7 +188,9 @@ GetHIInputIP (
   IPv4 address that is passed in and asks the user to modify it. If the\r
   resulting string defines a valid IPv4 address, the four bytes of the\r
   corresponding IPv4 address are extracted from the string and returned by\r
-  the function.\r
+  the function. As long as the user does not define a valid IP\r
+  address, he is asked for one. He can always escape by\r
+  pressing ESC.\r
 \r
   @param[in ]  EFI_IP_ADDRESS  InIpAddr   Input IPv4 address\r
   @param[out]  EFI_IP_ADDRESS  OutIpAddr  Returned IPv4 address. Valid if\r
@@ -206,20 +213,24 @@ EditHIInputIP (
   EFI_STATUS  Status;\r
   CHAR16      CmdLine[48];\r
 \r
-  UnicodeSPrint (
-    CmdLine, 48, L"%d.%d.%d.%d",\r
-    InIpAddr->v4.Addr[0], InIpAddr->v4.Addr[1],\r
-    InIpAddr->v4.Addr[2], InIpAddr->v4.Addr[3]\r
-    );\r
+  while (TRUE) {\r
+    UnicodeSPrint (\r
+      CmdLine, 48, L"%d.%d.%d.%d",\r
+      InIpAddr->v4.Addr[0], InIpAddr->v4.Addr[1],\r
+      InIpAddr->v4.Addr[2], InIpAddr->v4.Addr[3]\r
+      );\r
 \r
-  Status = EditHIInputStr (CmdLine, 48);\r
-  if (EFI_ERROR (Status)) {\r
-    return EFI_ABORTED;\r
+    Status = EditHIInputStr (CmdLine, 48);\r
+    if (EFI_ERROR (Status)) {\r
+      return EFI_ABORTED;\r
+    }\r
+    Status = NetLibStrToIp4 (CmdLine, &OutIpAddr->v4);\r
+    if (Status == EFI_INVALID_PARAMETER) {\r
+      Print (L"Invalid address\n");\r
+    } else {\r
+      return Status;\r
+    }\r
   }\r
-\r
-  Status = NetLibStrToIp4 (CmdLine, &OutIpAddr->v4);\r
-\r
-  return Status;\r
 }\r
 \r
 EFI_STATUS\r