diff options
author | Ronald Cron <ronald.cron@arm.com> | 2014-07-29 14:16:10 +0000 |
---|---|---|
committer | oliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524> | 2014-07-29 14:16:10 +0000 |
commit | cf30b996d5d47835bf72921f351bb34c6790d8be (patch) | |
tree | c27b724c22e0939aa79bfaed82215167e17c193e /ArmPlatformPkg/Bds | |
parent | 889ac6a8b7d632c7c2dc203bd20b722b9ee57719 (diff) | |
download | edk2-platforms-cf30b996d5d47835bf72921f351bb34c6790d8be.tar.xz |
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/Bds')
-rw-r--r-- | ArmPlatformPkg/Bds/BdsHelper.c | 59 |
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
|