mirror of https://github.com/acidanthera/audk.git
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
|
||||
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;
|
||||
while (TRUE) {
|
||||
CmdLine[0] = '\0';
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue