summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJiaxin Wu <jiaxin.wu@intel.com>2015-12-18 07:39:06 +0000
committervanjeff <vanjeff@Edk2>2015-12-18 07:39:06 +0000
commit89ed8b7770eee793c2375abb479d1db7eaa8a823 (patch)
tree688c3fc24b14dca613ce5d062ba50921095b75ec
parent91cf863a549d441f73ed55b19af95c5ff65d7913 (diff)
downloadedk2-platforms-89ed8b7770eee793c2375abb479d1db7eaa8a823.tar.xz
ShellPkg: Fix ifconfig hang issue with incomplete parameters
This patch is used to fix ifconfig hang issue with incomplete parameters. In addition, some error related output information is added to increase the interactivity. (Sync patch r19212 from main trunk.) Cc: Leekha Shaveta <shaveta@freescale.com> Cc: Carsey Jaben <jaben.carsey@intel.com> Cc: Ye Ting <ting.ye@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jiaxin Wu <jiaxin.wu@intel.com> Reviewed-by: Jaben Carsey <jaben.carsey@intel.com> Tested-by: Leekha Shaveta <shaveta@freescale.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/branches/UDK2015@19408 6f19259b-4bc3-4df7-8a09-765794883524
-rw-r--r--ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c61
-rw-r--r--ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShellNetwork1CommandsLib.uni7
2 files changed, 51 insertions, 17 deletions
diff --git a/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c b/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c
index fb6f575184..f8dbc88cf8 100644
--- a/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c
+++ b/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c
@@ -828,6 +828,7 @@ IfConfigClearInterfaceInfo (
&Policy
);
if (EFI_ERROR (Status)) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_ERR_AD), gShellNetwork1HiiHandle, L"ifconfig");
ShellStatus = SHELL_ACCESS_DENIED;
break;
}
@@ -904,6 +905,7 @@ IfConfigSetInterfaceInfo (
&TimeOutEvt
);
if (EFI_ERROR (Status)) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_ERR_AD), gShellNetwork1HiiHandle, L"ifconfig");
ShellStatus = SHELL_ACCESS_DENIED;
goto ON_EXIT;
}
@@ -916,6 +918,7 @@ IfConfigSetInterfaceInfo (
&MappedEvt
);
if (EFI_ERROR (Status)) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_ERR_AD), gShellNetwork1HiiHandle, L"ifconfig");
ShellStatus = SHELL_ACCESS_DENIED;
goto ON_EXIT;
}
@@ -974,6 +977,7 @@ IfConfigSetInterfaceInfo (
if (IfCb->Policy == Ip4Config2PolicyDhcp) {
Status = IfConfigStartIp4 (IfCb->NicHandle, gImageHandle);
if (EFI_ERROR(Status)) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_ERR_AD), gShellNetwork1HiiHandle, L"ifconfig");
ShellStatus = SHELL_ACCESS_DENIED;
goto ON_EXIT;
}
@@ -989,6 +993,7 @@ IfConfigSetInterfaceInfo (
&Policy
);
if (EFI_ERROR(Status)) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_ERR_AD), gShellNetwork1HiiHandle, L"ifconfig");
ShellStatus = SHELL_ACCESS_DENIED;
goto ON_EXIT;
}
@@ -997,23 +1002,13 @@ IfConfigSetInterfaceInfo (
VarArg= VarArg->Next;
} else if (StrCmp (VarArg->Arg, L"static") == 0) {
- //
- // Set manual config policy.
- //
- Policy = Ip4Config2PolicyStatic;
- Status = IfCb->IfCfg->SetData (
- IfCb->IfCfg,
- Ip4Config2DataTypePolicy,
- sizeof (EFI_IP4_CONFIG2_POLICY),
- &Policy
- );
- if (EFI_ERROR(Status)) {
- ShellStatus = SHELL_ACCESS_DENIED;
+ VarArg= VarArg->Next;
+ if (VarArg == NULL) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG_LACK_COMMAND), gShellNetwork1HiiHandle);
+ ShellStatus = SHELL_INVALID_PARAMETER;
goto ON_EXIT;
}
- VarArg= VarArg->Next;
-
ZeroMem (&ManualAddress, sizeof (ManualAddress));
//
@@ -1021,6 +1016,7 @@ IfConfigSetInterfaceInfo (
//
Status = NetLibStrToIp4 (VarArg->Arg, &ManualAddress.Address);
if (EFI_ERROR(Status)) {
+ ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_IFCONFIG_INVALID_IPADDRESS), gShellNetwork1HiiHandle, VarArg->Arg);
ShellStatus = SHELL_INVALID_PARAMETER;
goto ON_EXIT;
}
@@ -1029,8 +1025,15 @@ IfConfigSetInterfaceInfo (
// Get subnetmask.
//
VarArg = VarArg->Next;
+ if (VarArg == NULL) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG_LACK_COMMAND), gShellNetwork1HiiHandle);
+ ShellStatus = SHELL_INVALID_PARAMETER;
+ goto ON_EXIT;
+ }
+
Status = NetLibStrToIp4 (VarArg->Arg, &ManualAddress.SubnetMask);
if (EFI_ERROR(Status)) {
+ ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_IFCONFIG_INVALID_IPADDRESS), gShellNetwork1HiiHandle, VarArg->Arg);
ShellStatus = SHELL_INVALID_PARAMETER;
goto ON_EXIT;
}
@@ -1039,12 +1042,38 @@ IfConfigSetInterfaceInfo (
// Get gateway.
//
VarArg = VarArg->Next;
+ if (VarArg == NULL) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG_LACK_COMMAND), gShellNetwork1HiiHandle);
+ ShellStatus = SHELL_INVALID_PARAMETER;
+ goto ON_EXIT;
+ }
+
Status = NetLibStrToIp4 (VarArg->Arg, &Gateway);
if (EFI_ERROR(Status)) {
+ ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_IFCONFIG_INVALID_IPADDRESS), gShellNetwork1HiiHandle, VarArg->Arg);
ShellStatus = SHELL_INVALID_PARAMETER;
goto ON_EXIT;
}
+
+ //
+ // Set manual config policy.
+ //
+ Policy = Ip4Config2PolicyStatic;
+ Status = IfCb->IfCfg->SetData (
+ IfCb->IfCfg,
+ Ip4Config2DataTypePolicy,
+ sizeof (EFI_IP4_CONFIG2_POLICY),
+ &Policy
+ );
+ if (EFI_ERROR(Status)) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_ERR_AD), gShellNetwork1HiiHandle, L"ifconfig");
+ ShellStatus = SHELL_ACCESS_DENIED;
+ goto ON_EXIT;
+ }
+ //
+ // Set Manual Address.
+ //
IsAddressOk = FALSE;
Status = IfCb->IfCfg->RegisterDataNotify (
@@ -1053,6 +1082,7 @@ IfConfigSetInterfaceInfo (
MappedEvt
);
if (EFI_ERROR (Status)) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG_SET_ADDR_FAILED), gShellNetwork1HiiHandle, Status);
ShellStatus = SHELL_ACCESS_DENIED;
goto ON_EXIT;
}
@@ -1101,6 +1131,7 @@ IfConfigSetInterfaceInfo (
&Gateway
);
if (EFI_ERROR (Status)) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG_SET_ADDR_FAILED), gShellNetwork1HiiHandle, Status);
ShellStatus = SHELL_ACCESS_DENIED;
goto ON_EXIT;
}
@@ -1126,6 +1157,7 @@ IfConfigSetInterfaceInfo (
while (Tmp != NULL) {
Status = NetLibStrToIp4 (Tmp->Arg, Dns + Index);
if (EFI_ERROR(Status)) {
+ ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_IFCONFIG_INVALID_IPADDRESS), gShellNetwork1HiiHandle, Tmp->Arg);
ShellStatus = SHELL_INVALID_PARAMETER;
goto ON_EXIT;
}
@@ -1147,6 +1179,7 @@ IfConfigSetInterfaceInfo (
Dns
);
if (EFI_ERROR (Status)) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_ERR_AD), gShellNetwork1HiiHandle, L"ifconfig");
ShellStatus = SHELL_ACCESS_DENIED;
goto ON_EXIT;
}
diff --git a/ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShellNetwork1CommandsLib.uni b/ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShellNetwork1CommandsLib.uni
index 4c68e41640..bc6acac0c1 100644
--- a/ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShellNetwork1CommandsLib.uni
+++ b/ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShellNetwork1CommandsLib.uni
@@ -63,10 +63,11 @@
#string STR_IFCONFIG_LACK_INTERFACE #language en-US "Lack interface name.\n"
#string STR_IFCONFIG_LACK_COMMAND #language en-US "Lack interface config option.\n"
#string STR_IFCONFIG_INVALID_INTERFACE #language en-US "Invalid interface name.\n"
+#string STR_IFCONFIG_INVALID_IPADDRESS #language en-US "Invalid ipv4 address: '%H%s%N'\n"
#string STR_IFCONFIG_DUPLICATE_COMMAND #language en-US "Duplicate commands. Bad command %H%s%N is skipped.\n"
#string STR_IFCONFIG_CONFLICT_COMMAND #language en-US "Conflict commands. Bad command %H%s%N is skipped.\n"
#string STR_IFCONFIG_UNKNOWN_COMMAND #language en-US "Unknown commands. Bad command %H%s%N is skipped.\n"
-#string STR_IFCONFIG_SET_ADDR_FAILED #language en-US "It failed to set .\n"
+#string STR_IFCONFIG_SET_ADDR_FAILED #language en-US "Failed to set address.\n"
#string STR_IFCONFIG_ROUTES_SIZE #language en-US "\n%H Routes (%d entries):\n"
#string STR_IFCONFIG_ROUTES_ENTRY_INDEX #language en-US "%H Entry[%d]\n"
#string STR_IFCONFIG_SHOW_IP_ADDR #language en-US "%12s: %N%d.%d.%d.%d\n"
@@ -156,9 +157,9 @@
" 3. Use '-l' to list the DNS and other address related settings for all\r\n"
" interfaces or the specified interface.\r\n"
" 4. Use '-s <Name> static <IP> <SubnetMask> <GatewayMask>' with \r\n"
-" static IP4 address configuration for all or specified interface.\r\n"
+" static IP4 address configuration for specified interface.\r\n"
" 5. Use '-s <Name> dhcp' for DHCP4 to request the IP4 address\r\n"
-" configuration dynamically for all interface or specified interface.\r\n"
+" configuration dynamically for specified interface.\r\n"
" 6. Use '-s <Name> dns <IP>' must under manual policy.\r\n"
".SH EXAMPLES\r\n"
" \r\n"