From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id BB27D81CCC for ; Fri, 4 Nov 2016 13:38:15 -0700 (PDT) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga105.jf.intel.com with ESMTP; 04 Nov 2016 13:38:17 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,445,1473145200"; d="scan'208";a="1055362907" Received: from fmsmsx108.amr.corp.intel.com ([10.18.124.206]) by orsmga001.jf.intel.com with ESMTP; 04 Nov 2016 13:38:17 -0700 Received: from fmsmsx114.amr.corp.intel.com (10.18.116.8) by FMSMSX108.amr.corp.intel.com (10.18.124.206) with Microsoft SMTP Server (TLS) id 14.3.248.2; Fri, 4 Nov 2016 13:38:17 -0700 Received: from fmsmsx103.amr.corp.intel.com ([169.254.2.170]) by FMSMSX114.amr.corp.intel.com ([10.18.116.8]) with mapi id 14.03.0248.002; Fri, 4 Nov 2016 13:38:16 -0700 From: "Carsey, Jaben" To: Marcin Wojtas , "edk2-devel@lists.01.org" CC: "Tian, Feng" , "leif.lindholm@linaro.org" , "Gao, Liming" , "Kinney, Michael D" , "Carsey, Jaben" Thread-Topic: [edk2] [PATCH 2/2] ShellPkg/Ifconfig: Enable setting MAC address Thread-Index: AQHSNskw5UXtFmoJOk+SQ8s7ljNqXqDJSBXQ Date: Fri, 4 Nov 2016 20:38:15 +0000 Message-ID: References: <1478284123-4355-1-git-send-email-mw@semihalf.com> <1478284123-4355-3-git-send-email-mw@semihalf.com> In-Reply-To: <1478284123-4355-3-git-send-email-mw@semihalf.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiNjUxMzcxMTktZTgzNC00ZjA4LWFkM2UtMTUwNjQ2OGY4NTZmIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE1LjkuNi42IiwiVHJ1c3RlZExhYmVsSGFzaCI6InFsRHc3VnhZTlwveUNCYXhjNnZabFdPSzRPYTJ0SnoxTGtxVCtlTlJtWDdrPSJ9 x-ctpclassification: CTP_IC x-originating-ip: [10.1.200.108] MIME-Version: 1.0 Subject: Re: [PATCH 2/2] ShellPkg/Ifconfig: Enable setting MAC address X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Nov 2016 20:38:15 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable I think this is a good idea. But I see 2 issues. =20 1 - ifconfig standard parameters are controlled by the UEFI Shell Specifica= tion. If you want to extend the parameters you need to use parameters that= start with underscore. I do not quite know how to so this under the "-s" = set of functions for this command. Maybe just add this separate from "-s",= using something like "-_mac"? 2 - whatever change is done here should also be done to the ipv6 version of= the command. -Jaben > -----Original Message----- > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of > Marcin Wojtas > Sent: Friday, November 04, 2016 11:29 AM > To: edk2-devel@lists.01.org > Cc: Tian, Feng ; leif.lindholm@linaro.org; Gao, Limi= ng > ; Kinney, Michael D > Subject: [edk2] [PATCH 2/2] ShellPkg/Ifconfig: Enable setting MAC address > Importance: High >=20 > This adds new feature to ifconfig shell command, which allow > for updating MAC address of the interface or resetting it to the > initial value. >=20 > It consumes newly added NetLib helpers for parsing the Unicode > string to EFI_MAC_ADDRESS, calling Snp->StationAddress() callback > and reconnecting controller, so that all interface's children > devices could get updated with new value of the MAC address. >=20 > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Marcin Wojtas > --- > .../UefiShellNetwork1CommandsLib/Ifconfig.c | 54 > ++++++++++++++++++++++ > .../UefiShellNetwork1CommandsLib.uni | 12 ++++- > 2 files changed, 64 insertions(+), 2 deletions(-) >=20 > diff --git a/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c > b/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c > index 5e243d5..e4ea308 100644 > --- a/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c > +++ b/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c > @@ -120,6 +120,12 @@ VAR_CHECK_ITEM mSetCheckList[] =3D { > FlagTypeSingle > }, > { > + L"mac", > + 0x00000010, > + 0x00000005, > + FlagTypeSingle > + }, > + { > NULL, > 0x0, > 0x0, > @@ -832,6 +838,7 @@ IfConfigSetInterfaceInfo ( > EFI_EVENT TimeOutEvt; > EFI_EVENT MappedEvt; > BOOLEAN IsAddressOk; > + BOOLEAN MacAddressReset; >=20 > EFI_IP4_CONFIG2_POLICY Policy; > EFI_IP4_CONFIG2_MANUAL_ADDRESS ManualAddress; > @@ -840,6 +847,7 @@ IfConfigSetInterfaceInfo ( > EFI_IPv4_ADDRESS *Dns; > ARG_LIST *Tmp; > UINTN Index; > + EFI_MAC_ADDRESS NewMac; >=20 > CONST CHAR16* TempString; >=20 > @@ -1150,6 +1158,52 @@ IfConfigSetInterfaceInfo ( > ShellStatus =3D SHELL_ACCESS_DENIED; > goto ON_EXIT; > } > + } else if (StrCmp (VarArg->Arg, L"mac") =3D=3D 0) { > + // > + // Set MAC address. > + // > + MacAddressReset =3D FALSE; > + VarArg =3D VarArg->Next; > + if (VarArg =3D=3D NULL) { > + ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN > (STR_IFCONFIG_LACK_COMMAND), gShellNetwork1HiiHandle); > + ShellStatus =3D SHELL_INVALID_PARAMETER; > + goto ON_EXIT; > + } > + > + if (StrCmp (VarArg->Arg, L"reset") =3D=3D 0) { > + MacAddressReset =3D TRUE; > + } else { > + Status =3D NetLibStrToMac (VarArg->Arg, &NewMac); > + if (EFI_ERROR(Status)) { > + ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN > (STR_IFCONFIG_INVALID_MACADDRESS), gShellNetwork1HiiHandle, VarArg- > >Arg); > + ShellStatus =3D SHELL_INVALID_PARAMETER; > + goto ON_EXIT; > + } > + } > + > + Status =3D NetLibSetMacAddress ( > + IfCb->NicHandle, > + &NewMac, > + IfCb->IfInfo->HwAddressSize, > + MacAddressReset > + ); > + if (EFI_ERROR(Status)) { > + ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN > (STR_IFCONFIG_SET_ADDR_FAILED), gShellNetwork1HiiHandle, Status); > + ShellStatus =3D SHELL_ACCESS_DENIED; > + goto ON_EXIT; > + } > + > + // > + // Reconnect controller, so that all children get updated with > + // new MAC address information. > + // > + Status =3D NetLibReconnectInterface (IfCb->NicHandle); > + if (EFI_ERROR(Status)) { > + ShellStatus =3D SHELL_DEVICE_ERROR; > + goto ON_EXIT; > + } > + > + VarArg =3D VarArg->Next; > } > } >=20 > diff --git > a/ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShellNetwork1Com > mandsLib.uni > b/ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShellNetwork1Com > mandsLib.uni > index 76b6188..ffc358d 100644 > --- > a/ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShellNetwork1Com > mandsLib.uni > +++ > b/ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShellNetwork1Com > mandsLib.uni > @@ -66,6 +66,7 @@ > #string STR_IFCONFIG_LACK_COMMAND #language en-US "Lack > interface config option.\n" > #string STR_IFCONFIG_INVALID_INTERFACE #language en-US "Invali= d > interface name.\n" > #string STR_IFCONFIG_INVALID_IPADDRESS #language en-US "Invali= d > ipv4 address: '%H%s%N'\n" > +#string STR_IFCONFIG_INVALID_MACADDRESS #language en-US > "Invalid MAC 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" > @@ -133,7 +134,7 @@ > ".SH SYNOPSIS\r\n" > " \r\n" > "IFCONFIG [-r [Name]] [-l [Name]]\r\n" > -"IFCONFIG [-s dhcp | > | >]\r\n" > +"IFCONFIG [-s dhcp | > | > | | >]\r\n" > ".SH OPTIONS\r\n" > " \r\n" > " -r - Renew configuration of interface and set dhcp policy.\r= \n" > @@ -146,6 +147,8 @@ > " - Example: 255.255.255.0\r\n" > " GatewayMask - Specifies a default gateway in four integer values:\r\n= " > " - Example: 192.168.0.1\r\n" > +" MAC - Specifies the MAC address:\r\n" > +" - Example: 00:11:22:33:44:55\r\n" > ".SH DESCRIPTION\r\n" > " \r\n" > "NOTES:\r\n" > @@ -174,6 +177,11 @@ > " \r\n" > " * To configure DNS server address for the eth0 interface:\r\n" > " fs0:\> ifconfig -s eth0 dns 192.168.0.8 192.168.0.9\r\n" > - > +" \r\n" > +" * To configure MAC address for the eth0 interface:\r\n" > +" fs0:\> ifconfig -s eth0 mac 00:11:22:33:44:55\r\n" > +" \r\n" > +" * To reset MAC address of the eth0 interface to initial value:\r\n" > +" fs0:\> ifconfig -s eth0 mac reset\r\n" >=20 >=20 > -- > 1.8.3.1 >=20 > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel