summaryrefslogtreecommitdiffstats
path: root/ArmPlatformPkg
diff options
context:
space:
mode:
authorRonald Cron <ronald.cron@arm.com>2014-07-29 14:16:10 +0000
committeroliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524>2014-07-29 14:16:10 +0000
commitcf30b996d5d47835bf72921f351bb34c6790d8be (patch)
treec27b724c22e0939aa79bfaed82215167e17c193e /ArmPlatformPkg
parent889ac6a8b7d632c7c2dc203bd20b722b9ee57719 (diff)
downloadedk2-cf30b996d5d47835bf72921f351bb34c6790d8be.tar.gz
edk2-cf30b996d5d47835bf72921f351bb34c6790d8be.tar.bz2
edk2-cf30b996d5d47835bf72921f351bb34c6790d8be.zip
ArmPlatformPkg/Bds: Change the GetHIInput/EditHIInput to always return a valid IP address
The new functions never return a invalid IP address. The user would be asked again if the IP address is mal-formed. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ronald Cron <ronald.cron@arm.com> Reviewed-By: Olivier Martin <olivier.martin@arm.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15714 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'ArmPlatformPkg')
-rw-r--r--ArmPlatformPkg/Bds/BdsHelper.c59
1 files changed, 35 insertions, 24 deletions
diff --git a/ArmPlatformPkg/Bds/BdsHelper.c b/ArmPlatformPkg/Bds/BdsHelper.c
index 8553577cf1..693bc7d12a 100644
--- a/ArmPlatformPkg/Bds/BdsHelper.c
+++ b/ArmPlatformPkg/Bds/BdsHelper.c
@@ -144,7 +144,9 @@ GetHIInputInteger (
The function asks the user for an IPv4 address. If the input
string defines a valid IPv4 address, the four bytes of the
corresponding IPv4 address are extracted from the string and returned by
- the function.
+ the function. As long as the user does not define a valid IP
+ address, he is asked for one. He can always escape by
+ pressing ESC.
@param[out] EFI_IP_ADDRESS OutIpAddr Returned IPv4 address. Valid if
and only if the returned value
@@ -152,8 +154,6 @@ GetHIInputInteger (
@retval EFI_SUCCESS Input completed
@retval EFI_ABORTED Editing aborted by the user
- @retval EFI_INVALID_PARAMETER The string returned by the user is
- mal-formated
@retval EFI_OUT_OF_RESOURCES Fail to perform the operation due to
lack of resource
**/
@@ -165,15 +165,20 @@ GetHIInputIP (
EFI_STATUS Status;
CHAR16 CmdLine[48];
- CmdLine[0] = '\0';
- Status = EditHIInputStr (CmdLine, 48);
- if (EFI_ERROR (Status)) {
- return EFI_ABORTED;
- }
-
- Status = NetLibStrToIp4 (CmdLine, &OutIpAddr->v4);
+ while (TRUE) {
+ CmdLine[0] = '\0';
+ Status = EditHIInputStr (CmdLine, 48);
+ if (EFI_ERROR (Status)) {
+ return EFI_ABORTED;
+ }
- return Status;
+ Status = NetLibStrToIp4 (CmdLine, &OutIpAddr->v4);
+ if (Status == EFI_INVALID_PARAMETER) {
+ Print (L"Invalid address\n");
+ } else {
+ return Status;
+ }
+ }
}
/**
@@ -183,7 +188,9 @@ GetHIInputIP (
IPv4 address that is passed in and asks the user to modify it. If the
resulting string defines a valid IPv4 address, the four bytes of the
corresponding IPv4 address are extracted from the string and returned by
- the function.
+ the function. As long as the user does not define a valid IP
+ address, he is asked for one. He can always escape by
+ pressing ESC.
@param[in ] EFI_IP_ADDRESS InIpAddr Input IPv4 address
@param[out] EFI_IP_ADDRESS OutIpAddr Returned IPv4 address. Valid if
@@ -206,20 +213,24 @@ EditHIInputIP (
EFI_STATUS Status;
CHAR16 CmdLine[48];
- UnicodeSPrint (
- CmdLine, 48, L"%d.%d.%d.%d",
- InIpAddr->v4.Addr[0], InIpAddr->v4.Addr[1],
- InIpAddr->v4.Addr[2], InIpAddr->v4.Addr[3]
- );
+ while (TRUE) {
+ UnicodeSPrint (
+ CmdLine, 48, L"%d.%d.%d.%d",
+ InIpAddr->v4.Addr[0], InIpAddr->v4.Addr[1],
+ InIpAddr->v4.Addr[2], InIpAddr->v4.Addr[3]
+ );
- Status = EditHIInputStr (CmdLine, 48);
- if (EFI_ERROR (Status)) {
- return EFI_ABORTED;
+ Status = EditHIInputStr (CmdLine, 48);
+ if (EFI_ERROR (Status)) {
+ return EFI_ABORTED;
+ }
+ Status = NetLibStrToIp4 (CmdLine, &OutIpAddr->v4);
+ if (Status == EFI_INVALID_PARAMETER) {
+ Print (L"Invalid address\n");
+ } else {
+ return Status;
+ }
}
-
- Status = NetLibStrToIp4 (CmdLine, &OutIpAddr->v4);
-
- return Status;
}
EFI_STATUS