mirror of
https://github.com/acidanthera/audk.git
synced 2025-07-22 13:14:26 +02:00
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
This commit is contained in:
parent
889ac6a8b7
commit
cf30b996d5
@ -144,7 +144,9 @@ GetHIInputInteger (
|
|||||||
The function asks the user for an IPv4 address. If the input
|
The function asks the user for an IPv4 address. If the input
|
||||||
string defines a valid IPv4 address, the four bytes of the
|
string defines a valid IPv4 address, the four bytes of the
|
||||||
corresponding IPv4 address are extracted from the string and returned by
|
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
|
@param[out] EFI_IP_ADDRESS OutIpAddr Returned IPv4 address. Valid if
|
||||||
and only if the returned value
|
and only if the returned value
|
||||||
@ -152,8 +154,6 @@ GetHIInputInteger (
|
|||||||
|
|
||||||
@retval EFI_SUCCESS Input completed
|
@retval EFI_SUCCESS Input completed
|
||||||
@retval EFI_ABORTED Editing aborted by the user
|
@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
|
@retval EFI_OUT_OF_RESOURCES Fail to perform the operation due to
|
||||||
lack of resource
|
lack of resource
|
||||||
**/
|
**/
|
||||||
@ -165,6 +165,7 @@ GetHIInputIP (
|
|||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
CHAR16 CmdLine[48];
|
CHAR16 CmdLine[48];
|
||||||
|
|
||||||
|
while (TRUE) {
|
||||||
CmdLine[0] = '\0';
|
CmdLine[0] = '\0';
|
||||||
Status = EditHIInputStr (CmdLine, 48);
|
Status = EditHIInputStr (CmdLine, 48);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
@ -172,8 +173,12 @@ GetHIInputIP (
|
|||||||
}
|
}
|
||||||
|
|
||||||
Status = NetLibStrToIp4 (CmdLine, &OutIpAddr->v4);
|
Status = NetLibStrToIp4 (CmdLine, &OutIpAddr->v4);
|
||||||
|
if (Status == EFI_INVALID_PARAMETER) {
|
||||||
|
Print (L"Invalid address\n");
|
||||||
|
} else {
|
||||||
return Status;
|
return Status;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -183,7 +188,9 @@ GetHIInputIP (
|
|||||||
IPv4 address that is passed in and asks the user to modify it. If the
|
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
|
resulting string defines a valid IPv4 address, the four bytes of the
|
||||||
corresponding IPv4 address are extracted from the string and returned by
|
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[in ] EFI_IP_ADDRESS InIpAddr Input IPv4 address
|
||||||
@param[out] EFI_IP_ADDRESS OutIpAddr Returned IPv4 address. Valid if
|
@param[out] EFI_IP_ADDRESS OutIpAddr Returned IPv4 address. Valid if
|
||||||
@ -206,6 +213,7 @@ EditHIInputIP (
|
|||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
CHAR16 CmdLine[48];
|
CHAR16 CmdLine[48];
|
||||||
|
|
||||||
|
while (TRUE) {
|
||||||
UnicodeSPrint (
|
UnicodeSPrint (
|
||||||
CmdLine, 48, L"%d.%d.%d.%d",
|
CmdLine, 48, L"%d.%d.%d.%d",
|
||||||
InIpAddr->v4.Addr[0], InIpAddr->v4.Addr[1],
|
InIpAddr->v4.Addr[0], InIpAddr->v4.Addr[1],
|
||||||
@ -216,10 +224,13 @@ EditHIInputIP (
|
|||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
return EFI_ABORTED;
|
return EFI_ABORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = NetLibStrToIp4 (CmdLine, &OutIpAddr->v4);
|
Status = NetLibStrToIp4 (CmdLine, &OutIpAddr->v4);
|
||||||
|
if (Status == EFI_INVALID_PARAMETER) {
|
||||||
|
Print (L"Invalid address\n");
|
||||||
|
} else {
|
||||||
return Status;
|
return Status;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
|
Loading…
x
Reference in New Issue
Block a user