Re: [edk2] [Patch] ShellPkg: Update 'ifconfig -r' implementation
Reviewed-by: Sriram Subramanian-Original Message- From: Jiaxin Wu [mailto:jiaxin...@intel.com] Sent: Wednesday, March 02, 2016 1:33 PM To: edk2-devel@lists.01.org Cc: Ye Ting; Fu Siyuan; Carsey Jaben; El-Haj-Mahmoud, Samer; Subramanian, Sriram (EG Servers Platform SW) Subject: [Patch] 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 Cc: Fu Siyuan Cc: Carsey Jaben Cc: El-Haj-Mahmoud Samer Cc: Subramanian Sriram Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jiaxin Wu --- .../UefiShellNetwork1CommandsLib/Ifconfig.c| 31 ++ 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c b/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c index 0c4a3b0..92108a1 100644 --- a/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c +++ b/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c @@ -1,10 +1,10 @@ /** @file The implementation for Shell command ifconfig based on IP4Config2 protocol. (C) Copyright 2013-2015 Hewlett-Packard Development Company, L.P. - Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved. + Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved. This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php. @@ -708,40 +708,61 @@ IfConfigShowInterfaceInfo ( /** The clean process of the ifconfig command to clear interface info. @param[in] IfListThe pointer of IfList(interface list). + @param[in] IfNameThe pointer of interface name. @retval SHELL_SUCCESS The ifconfig command clean processed successfully. @retval others The ifconfig command clean process failed. **/ SHELL_STATUS IfConfigClearInterfaceInfo ( - IN LIST_ENTRY*IfList + IN LIST_ENTRY*IfList, + IN CHAR16*IfName ) { EFI_STATUSStatus; SHELL_STATUS ShellStatus; LIST_ENTRY*Entry; LIST_ENTRY*Next; IFCONFIG_INTERFACE_CB *IfCb; EFI_IP4_CONFIG2_POLICYPolicy; - - Policy = Ip4Config2PolicyDhcp; + Status = EFI_SUCCESS; ShellStatus = SHELL_SUCCESS; if (IsListEmpty (IfList)) { ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG_INVALID_INTERFACE), gShellNetwork1HiiHandle); } // // 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) { 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), + + ); + 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 ( IfCb->IfCfg, Ip4Config2DataTypePolicy, sizeof (EFI_IP4_CONFIG2_POLICY), @@ -1141,11 +1162,11 @@ IfConfig ( case IfConfigOpList: ShellStatus = IfConfigShowInterfaceInfo (>IfList); break; case IfConfigOpClear: -ShellStatus = IfConfigClearInterfaceInfo (>IfList); +ShellStatus = IfConfigClearInterfaceInfo (>IfList, Private->IfName); break; case IfConfigOpSet: ShellStatus = IfConfigSetInterfaceInfo (>IfList, Private->VarArg); break; -- 1.9.5.msysgit.1 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
Re: [edk2] [Patch] ShellPkg: Update 'ifconfig -r' implementation
Reviewed-by: Jaben Carsey <jaben.car...@intel.com> > On Mar 2, 2016, at 4:33 PM, Wu, Jiaxin <jiaxin...@intel.com> wrote: > > Thanks, Laszlo, I will fix it before commit the patch. > > >> -Original Message- >> From: Ryan Harkin [mailto:ryan.har...@linaro.org] >> Sent: Wednesday, March 2, 2016 5:57 PM >> To: Laszlo Ersek <ler...@redhat.com> >> Cc: Wu, Jiaxin <jiaxin...@intel.com>; edk2-devel@lists.01.org > de...@ml01.01.org>; Ye, Ting <ting...@intel.com>; Carsey, Jaben >> <jaben.car...@intel.com>; Fu, Siyuan <siyuan...@intel.com> >> Subject: Re: [edk2] [Patch] ShellPkg: Update 'ifconfig -r' implementation >> >>> On 2 March 2016 at 09:02, Laszlo Ersek <ler...@redhat.com> wrote: >>>> On 03/02/16 09:03, Jiaxin Wu wrote: >>>> This patch is used to update ifconfig –r implementation >>> >>> The dash character in the above "-r" option is not the ASCII >>> hyphen/minus character (0x2D), but the U+2013 unicode code point ("EN >>> DASH"). >>> >>> I think you may have copied & pasted it from a PDF, or a rendered >>> HTML, or a similar document. Please try to avoid this; we should keep >>> the source and the commit messages ASCII-clean. >> >> Well spotted! I've noticed Outlook causing this. >> >> >>> Can be fixed up when you commit the patch. >>> >>> Thanks >>> Laszlo >>> >>>> 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...@intel.com> >>>> Cc: Fu Siyuan <siyuan...@intel.com> >>>> Cc: Carsey Jaben <jaben.car...@intel.com> >>>> Cc: El-Haj-Mahmoud Samer <samer.el-haj-mahm...@hpe.com> >>>> Cc: Subramanian Sriram <srira...@hpe.com> >>>> Contributed-under: TianoCore Contribution Agreement 1.0 >>>> Signed-off-by: Jiaxin Wu <jiaxin...@intel.com> >>>> --- >>>> .../UefiShellNetwork1CommandsLib/Ifconfig.c| 31 >> ++ >>>> 1 file changed, 26 insertions(+), 5 deletions(-) >>>> >>>> diff --git a/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c >>>> b/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c >>>> index 0c4a3b0..92108a1 100644 >>>> --- a/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c >>>> +++ b/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c >>>> @@ -1,10 +1,10 @@ >>>> /** @file >>>> The implementation for Shell command ifconfig based on IP4Config2 >> protocol. >>>> >>>> (C) Copyright 2013-2015 Hewlett-Packard Development Company, >>>> L.P. >>>> - Copyright (c) 2006 - 2015, Intel Corporation. All rights >>>> reserved. >>>> + Copyright (c) 2006 - 2016, Intel Corporation. All rights >>>> + reserved. >>>> >>>> This program and the accompanying materials >>>> are licensed and made available under the terms and conditions of the >> BSD License >>>> which accompanies this distribution. The full text of the license may be >> found at >>>> http://opensource.org/licenses/bsd-license.php. >>>> @@ -708,40 +708,61 @@ IfConfigShowInterfaceInfo ( >>>> >>>> /** >>>> The clean process of the ifconfig command to clear interface info. >>>> >>>> @param[in] IfListThe pointer of IfList(interface list). >>>> + @param[in] IfNameThe pointer of interface name. >>>> >>>> @retval SHELL_SUCCESS The ifconfig command clean processed >> successfully. >>>> @retval others The ifconfig command clean process failed. >>>> >>>> **/ >>>> SHELL_STATUS >>>> IfConfigClearInterfaceInfo ( >>>> - IN LIST_ENTRY*IfList >>>> + IN LIST_ENTRY*IfList, >>>> + IN CHAR16*IfName >>>> ) >>>> { >>>> EFI_STATUSStatus; >>>> SHELL_STATUS ShellSt
Re: [edk2] [Patch] ShellPkg: Update 'ifconfig -r' implementation
Thanks, Laszlo, I will fix it before commit the patch. > -Original Message- > From: Ryan Harkin [mailto:ryan.har...@linaro.org] > Sent: Wednesday, March 2, 2016 5:57 PM > To: Laszlo Ersek <ler...@redhat.com> > Cc: Wu, Jiaxin <jiaxin...@intel.com>; edk2-devel@lists.01.org de...@ml01.01.org>; Ye, Ting <ting...@intel.com>; Carsey, Jaben > <jaben.car...@intel.com>; Fu, Siyuan <siyuan...@intel.com> > Subject: Re: [edk2] [Patch] ShellPkg: Update 'ifconfig -r' implementation > > On 2 March 2016 at 09:02, Laszlo Ersek <ler...@redhat.com> wrote: > > On 03/02/16 09:03, Jiaxin Wu wrote: > >> This patch is used to update ifconfig –r implementation > > > > The dash character in the above "-r" option is not the ASCII > > hyphen/minus character (0x2D), but the U+2013 unicode code point ("EN > > DASH"). > > > > I think you may have copied & pasted it from a PDF, or a rendered > > HTML, or a similar document. Please try to avoid this; we should keep > > the source and the commit messages ASCII-clean. > > > > Well spotted! I've noticed Outlook causing this. > > > > Can be fixed up when you commit the patch. > > > > Thanks > > Laszlo > > > >> 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...@intel.com> > >> Cc: Fu Siyuan <siyuan...@intel.com> > >> Cc: Carsey Jaben <jaben.car...@intel.com> > >> Cc: El-Haj-Mahmoud Samer <samer.el-haj-mahm...@hpe.com> > >> Cc: Subramanian Sriram <srira...@hpe.com> > >> Contributed-under: TianoCore Contribution Agreement 1.0 > >> Signed-off-by: Jiaxin Wu <jiaxin...@intel.com> > >> --- > >> .../UefiShellNetwork1CommandsLib/Ifconfig.c| 31 > ++ > >> 1 file changed, 26 insertions(+), 5 deletions(-) > >> > >> diff --git a/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c > >> b/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c > >> index 0c4a3b0..92108a1 100644 > >> --- a/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c > >> +++ b/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c > >> @@ -1,10 +1,10 @@ > >> /** @file > >>The implementation for Shell command ifconfig based on IP4Config2 > protocol. > >> > >>(C) Copyright 2013-2015 Hewlett-Packard Development Company, > >> L.P. > >> - Copyright (c) 2006 - 2015, Intel Corporation. All rights > >> reserved. > >> + Copyright (c) 2006 - 2016, Intel Corporation. All rights > >> + reserved. > >> > >>This program and the accompanying materials > >>are licensed and made available under the terms and conditions of the > BSD License > >>which accompanies this distribution. The full text of the license may > >> be > found at > >>http://opensource.org/licenses/bsd-license.php. > >> @@ -708,40 +708,61 @@ IfConfigShowInterfaceInfo ( > >> > >> /** > >>The clean process of the ifconfig command to clear interface info. > >> > >>@param[in] IfListThe pointer of IfList(interface list). > >> + @param[in] IfNameThe pointer of interface name. > >> > >>@retval SHELL_SUCCESS The ifconfig command clean processed > successfully. > >>@retval others The ifconfig command clean process failed. > >> > >> **/ > >> SHELL_STATUS > >> IfConfigClearInterfaceInfo ( > >> - IN LIST_ENTRY*IfList > >> + IN LIST_ENTRY*IfList, > >> + IN CHAR16*IfName > >>) > >> { > >>EFI_STATUSStatus; > >>SHELL_STATUS ShellStatus; > >>LIST_ENTRY*Entry; > >>LIST_ENTRY*Next; > >>IFCONFIG_INTERFACE_CB *IfCb; > >>EFI_IP4_CONFIG2_POLICYPolicy; > >> - > >> - Policy = Ip4Config2PolicyDhcp; > >> + > >>Status = EFI_SUCCESS; > >>ShellStatus = SHELL_SUCCESS; > >> > >>if (IsListEmpty (IfList)) { > >> S
Re: [edk2] [Patch] ShellPkg: Update 'ifconfig -r' implementation
On 03/02/16 09:03, Jiaxin Wu wrote: > This patch is used to update ifconfig –r implementation The dash character in the above "-r" option is not the ASCII hyphen/minus character (0x2D), but the U+2013 unicode code point ("EN DASH"). I think you may have copied & pasted it from a PDF, or a rendered HTML, or a similar document. Please try to avoid this; we should keep the source and the commit messages ASCII-clean. Can be fixed up when you commit the patch. Thanks Laszlo > 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> Cc: Fu Siyuan > Cc: Carsey Jaben > Cc: El-Haj-Mahmoud Samer > Cc: Subramanian Sriram > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Jiaxin Wu > --- > .../UefiShellNetwork1CommandsLib/Ifconfig.c| 31 > ++ > 1 file changed, 26 insertions(+), 5 deletions(-) > > diff --git a/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c > b/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c > index 0c4a3b0..92108a1 100644 > --- a/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c > +++ b/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c > @@ -1,10 +1,10 @@ > /** @file >The implementation for Shell command ifconfig based on IP4Config2 protocol. > >(C) Copyright 2013-2015 Hewlett-Packard Development Company, L.P. > - Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved. > + Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved. > >This program and the accompanying materials >are licensed and made available under the terms and conditions of the BSD > License >which accompanies this distribution. The full text of the license may be > found at >http://opensource.org/licenses/bsd-license.php. > @@ -708,40 +708,61 @@ IfConfigShowInterfaceInfo ( > > /** >The clean process of the ifconfig command to clear interface info. > >@param[in] IfListThe pointer of IfList(interface list). > + @param[in] IfNameThe pointer of interface name. > >@retval SHELL_SUCCESS The ifconfig command clean processed successfully. >@retval others The ifconfig command clean process failed. > > **/ > SHELL_STATUS > IfConfigClearInterfaceInfo ( > - IN LIST_ENTRY*IfList > + IN LIST_ENTRY*IfList, > + IN CHAR16*IfName >) > { >EFI_STATUSStatus; >SHELL_STATUS ShellStatus; >LIST_ENTRY*Entry; >LIST_ENTRY*Next; >IFCONFIG_INTERFACE_CB *IfCb; >EFI_IP4_CONFIG2_POLICYPolicy; > - > - Policy = Ip4Config2PolicyDhcp; > + >Status = EFI_SUCCESS; >ShellStatus = SHELL_SUCCESS; > >if (IsListEmpty (IfList)) { > ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN > (STR_IFCONFIG_INVALID_INTERFACE), gShellNetwork1HiiHandle); >} > >// >// 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) { > 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), > + > + ); > + 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 ( > IfCb->IfCfg, > Ip4Config2DataTypePolicy, > sizeof (EFI_IP4_CONFIG2_POLICY), > @@ -1141,11 +1162,11 @@ IfConfig ( >case IfConfigOpList: > ShellStatus = IfConfigShowInterfaceInfo (>IfList); > break; > >case IfConfigOpClear: > -ShellStatus = IfConfigClearInterfaceInfo (>IfList); > +ShellStatus = IfConfigClearInterfaceInfo (>IfList, > Private->IfName); > break; > >case IfConfigOpSet: > ShellStatus = IfConfigSetInterfaceInfo (>IfList, > Private->VarArg); > break; >
Re: [edk2] [Patch] ShellPkg: Update 'ifconfig -r' implementation
Reviewed-by: Fu Siyuan> -Original Message- > From: Wu, Jiaxin > Sent: Wednesday, March 2, 2016 4:03 PM > To: edk2-devel@lists.01.org > Cc: Ye, Ting ; Fu, Siyuan ; Carsey, > Jaben ; El-Haj-Mahmoud Samer mahm...@hpe.com>; Subramanian Sriram > Subject: [Patch] 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 > Cc: Fu Siyuan > Cc: Carsey Jaben > Cc: El-Haj-Mahmoud Samer > Cc: Subramanian Sriram > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Jiaxin Wu > --- > .../UefiShellNetwork1CommandsLib/Ifconfig.c| 31 ++- > --- > 1 file changed, 26 insertions(+), 5 deletions(-) > > diff --git a/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c > b/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c > index 0c4a3b0..92108a1 100644 > --- a/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c > +++ b/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c > @@ -1,10 +1,10 @@ > /** @file >The implementation for Shell command ifconfig based on IP4Config2 > protocol. > >(C) Copyright 2013-2015 Hewlett-Packard Development Company, L.P. > - Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved. > + Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved. > >This program and the accompanying materials >are licensed and made available under the terms and conditions of the BSD > License >which accompanies this distribution. The full text of the license may be > found at >http://opensource.org/licenses/bsd-license.php. > @@ -708,40 +708,61 @@ IfConfigShowInterfaceInfo ( > > /** >The clean process of the ifconfig command to clear interface info. > >@param[in] IfListThe pointer of IfList(interface list). > + @param[in] IfNameThe pointer of interface name. > >@retval SHELL_SUCCESS The ifconfig command clean processed > successfully. >@retval others The ifconfig command clean process failed. > > **/ > SHELL_STATUS > IfConfigClearInterfaceInfo ( > - IN LIST_ENTRY*IfList > + IN LIST_ENTRY*IfList, > + IN CHAR16*IfName >) > { >EFI_STATUSStatus; >SHELL_STATUS ShellStatus; >LIST_ENTRY*Entry; >LIST_ENTRY*Next; >IFCONFIG_INTERFACE_CB *IfCb; >EFI_IP4_CONFIG2_POLICYPolicy; > - > - Policy = Ip4Config2PolicyDhcp; > + >Status = EFI_SUCCESS; >ShellStatus = SHELL_SUCCESS; > >if (IsListEmpty (IfList)) { > ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN > (STR_IFCONFIG_INVALID_INTERFACE), gShellNetwork1HiiHandle); >} > >// >// 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) { > 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), > + > + ); > + 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 ( > IfCb->IfCfg, > Ip4Config2DataTypePolicy, > sizeof (EFI_IP4_CONFIG2_POLICY), > @@ -1141,11 +1162,11 @@ IfConfig ( >case IfConfigOpList: > ShellStatus = IfConfigShowInterfaceInfo (>IfList); > break; > >case IfConfigOpClear: > -ShellStatus = IfConfigClearInterfaceInfo (>IfList); > +ShellStatus = IfConfigClearInterfaceInfo (>IfList, > Private->IfName); > break; > >case IfConfigOpSet: > ShellStatus = IfConfigSetInterfaceInfo (>IfList, > Private->VarArg); > break; > -- > 1.9.5.msysgit.1 ___
[edk2] [Patch] 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 TingCc: Fu Siyuan Cc: Carsey Jaben Cc: El-Haj-Mahmoud Samer Cc: Subramanian Sriram Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jiaxin Wu --- .../UefiShellNetwork1CommandsLib/Ifconfig.c| 31 ++ 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c b/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c index 0c4a3b0..92108a1 100644 --- a/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c +++ b/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c @@ -1,10 +1,10 @@ /** @file The implementation for Shell command ifconfig based on IP4Config2 protocol. (C) Copyright 2013-2015 Hewlett-Packard Development Company, L.P. - Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved. + Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved. This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php. @@ -708,40 +708,61 @@ IfConfigShowInterfaceInfo ( /** The clean process of the ifconfig command to clear interface info. @param[in] IfListThe pointer of IfList(interface list). + @param[in] IfNameThe pointer of interface name. @retval SHELL_SUCCESS The ifconfig command clean processed successfully. @retval others The ifconfig command clean process failed. **/ SHELL_STATUS IfConfigClearInterfaceInfo ( - IN LIST_ENTRY*IfList + IN LIST_ENTRY*IfList, + IN CHAR16*IfName ) { EFI_STATUSStatus; SHELL_STATUS ShellStatus; LIST_ENTRY*Entry; LIST_ENTRY*Next; IFCONFIG_INTERFACE_CB *IfCb; EFI_IP4_CONFIG2_POLICYPolicy; - - Policy = Ip4Config2PolicyDhcp; + Status = EFI_SUCCESS; ShellStatus = SHELL_SUCCESS; if (IsListEmpty (IfList)) { ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG_INVALID_INTERFACE), gShellNetwork1HiiHandle); } // // 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) { 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), + + ); + 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 ( IfCb->IfCfg, Ip4Config2DataTypePolicy, sizeof (EFI_IP4_CONFIG2_POLICY), @@ -1141,11 +1162,11 @@ IfConfig ( case IfConfigOpList: ShellStatus = IfConfigShowInterfaceInfo (>IfList); break; case IfConfigOpClear: -ShellStatus = IfConfigClearInterfaceInfo (>IfList); +ShellStatus = IfConfigClearInterfaceInfo (>IfList, Private->IfName); break; case IfConfigOpSet: ShellStatus = IfConfigSetInterfaceInfo (>IfList, Private->VarArg); break; -- 1.9.5.msysgit.1 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel