mirror of https://github.com/acidanthera/audk.git
ShellPkg: Update 'ifconfig -r' implementation
This patch is used to update ifconfig -r implementation to sync with UEFI Shell 2.2. option -r means to reconfigure all or specified interface, and set DHCP policy. If specified interface is already set to DHCP, then refresh the IPv4 configuration. If the interface name is specified with '-r', DHCP DORA process will be triggered by the policy transition (static -> dhcp). Cc: Ye Ting <ting.ye@intel.com> Cc: Fu Siyuan <siyuan.fu@intel.com> Cc: Carsey Jaben <jaben.carsey@intel.com> Cc: El-Haj-Mahmoud Samer <samer.el-haj-mahmoud@hpe.com> Cc: Subramanian Sriram <sriram-s@hpe.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jiaxin Wu <jiaxin.wu@intel.com> Reviewed-by: Sriram Subramanian <sriram-s@hpe.com> Reviewed-by: Jaben Carsey <Jaben.carsey@intel.com> Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
This commit is contained in:
parent
c8d9d0e2bd
commit
913ba15120
|
@ -2,7 +2,7 @@
|
||||||
The implementation for Shell command ifconfig based on IP4Config2 protocol.
|
The implementation for Shell command ifconfig based on IP4Config2 protocol.
|
||||||
|
|
||||||
(C) Copyright 2013-2015 Hewlett-Packard Development Company, L.P.<BR>
|
(C) Copyright 2013-2015 Hewlett-Packard Development Company, L.P.<BR>
|
||||||
Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
|
||||||
|
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
are licensed and made available under the terms and conditions of the BSD License
|
||||||
|
@ -710,6 +710,7 @@ IfConfigShowInterfaceInfo (
|
||||||
The clean process of the ifconfig command to clear interface info.
|
The clean process of the ifconfig command to clear interface info.
|
||||||
|
|
||||||
@param[in] IfList The pointer of IfList(interface list).
|
@param[in] IfList The pointer of IfList(interface list).
|
||||||
|
@param[in] IfName The pointer of interface name.
|
||||||
|
|
||||||
@retval SHELL_SUCCESS The ifconfig command clean processed successfully.
|
@retval SHELL_SUCCESS The ifconfig command clean processed successfully.
|
||||||
@retval others The ifconfig command clean process failed.
|
@retval others The ifconfig command clean process failed.
|
||||||
|
@ -717,7 +718,8 @@ IfConfigShowInterfaceInfo (
|
||||||
**/
|
**/
|
||||||
SHELL_STATUS
|
SHELL_STATUS
|
||||||
IfConfigClearInterfaceInfo (
|
IfConfigClearInterfaceInfo (
|
||||||
IN LIST_ENTRY *IfList
|
IN LIST_ENTRY *IfList,
|
||||||
|
IN CHAR16 *IfName
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
|
@ -727,7 +729,6 @@ IfConfigClearInterfaceInfo (
|
||||||
IFCONFIG_INTERFACE_CB *IfCb;
|
IFCONFIG_INTERFACE_CB *IfCb;
|
||||||
EFI_IP4_CONFIG2_POLICY Policy;
|
EFI_IP4_CONFIG2_POLICY Policy;
|
||||||
|
|
||||||
Policy = Ip4Config2PolicyDhcp;
|
|
||||||
Status = EFI_SUCCESS;
|
Status = EFI_SUCCESS;
|
||||||
ShellStatus = SHELL_SUCCESS;
|
ShellStatus = SHELL_SUCCESS;
|
||||||
|
|
||||||
|
@ -737,10 +738,30 @@ IfConfigClearInterfaceInfo (
|
||||||
|
|
||||||
//
|
//
|
||||||
// Go through the interface list.
|
// Go through the interface list.
|
||||||
|
// If the interface name is specified, DHCP DORA process will be
|
||||||
|
// triggered by the policy transition (static -> dhcp).
|
||||||
//
|
//
|
||||||
NET_LIST_FOR_EACH_SAFE (Entry, Next, IfList) {
|
NET_LIST_FOR_EACH_SAFE (Entry, Next, IfList) {
|
||||||
IfCb = NET_LIST_USER_STRUCT (Entry, IFCONFIG_INTERFACE_CB, Link);
|
IfCb = NET_LIST_USER_STRUCT (Entry, IFCONFIG_INTERFACE_CB, Link);
|
||||||
|
|
||||||
|
if ((IfName != NULL) && (StrCmp (IfName, IfCb->IfInfo->Name) == 0)) {
|
||||||
|
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;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Policy = Ip4Config2PolicyDhcp;
|
||||||
|
|
||||||
Status = IfCb->IfCfg->SetData (
|
Status = IfCb->IfCfg->SetData (
|
||||||
IfCb->IfCfg,
|
IfCb->IfCfg,
|
||||||
Ip4Config2DataTypePolicy,
|
Ip4Config2DataTypePolicy,
|
||||||
|
@ -1143,7 +1164,7 @@ IfConfig (
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IfConfigOpClear:
|
case IfConfigOpClear:
|
||||||
ShellStatus = IfConfigClearInterfaceInfo (&Private->IfList);
|
ShellStatus = IfConfigClearInterfaceInfo (&Private->IfList, Private->IfName);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IfConfigOpSet:
|
case IfConfigOpSet:
|
||||||
|
|
Loading…
Reference in New Issue