From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.115; helo=mga14.intel.com; envelope-from=jaben.carsey@intel.com; receiver=edk2-devel@lists.01.org Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) (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 55D2721A07A82 for ; Mon, 17 Sep 2018 15:19:19 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 17 Sep 2018 15:19:18 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,387,1531810800"; d="scan'208";a="73775915" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by orsmga007.jf.intel.com with ESMTP; 17 Sep 2018 15:18:20 -0700 Received: from fmsmsx112.amr.corp.intel.com (10.18.116.6) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.319.2; Mon, 17 Sep 2018 15:18:19 -0700 Received: from fmsmsx103.amr.corp.intel.com ([169.254.2.126]) by FMSMSX112.amr.corp.intel.com ([169.254.5.84]) with mapi id 14.03.0319.002; Mon, 17 Sep 2018 15:18:18 -0700 From: "Carsey, Jaben" To: "Wu, Jiaxin" , "edk2-devel@lists.01.org" CC: "Ye, Ting" , "Fu, Siyuan" , "Shao, Ming" Thread-Topic: [Patch 3/5] ShellPkg/TftpDynamicCommand: Add one option for tftp command to specify windowsize. Thread-Index: AQHUTkl6Md4TeV9xhEifliRbBclgd6T1DA3w Date: Mon, 17 Sep 2018 22:18:18 +0000 Message-ID: References: <20180917054348.19228-1-Jiaxin.wu@intel.com> <20180917054348.19228-4-Jiaxin.wu@intel.com> In-Reply-To: <20180917054348.19228-4-Jiaxin.wu@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiMzNmZjJjMzMtMjJhNC00ZGYyLWEzMTgtMGQ2ZWRiNzNiYjJiIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiNFY5QmlOa1wvQzhlcnBLbEMzSnpoZlpiTytudUdKT1hnNUJmdkd1SnBONnArOFpqRzBXS2ExdzEyZmlwNUpBdlMifQ== x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.0.400.15 dlp-reaction: no-action x-originating-ip: [10.1.200.108] MIME-Version: 1.0 Subject: Re: [Patch 3/5] ShellPkg/TftpDynamicCommand: Add one option for tftp command to specify windowsize. X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 17 Sep 2018 22:19:19 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Jaben Carsey > -----Original Message----- > From: Wu, Jiaxin > Sent: Sunday, September 16, 2018 10:44 PM > To: edk2-devel@lists.01.org > Cc: Ye, Ting ; Fu, Siyuan ; Carse= y, > Jaben ; Shao, Ming ; Wu, > Jiaxin > Subject: [Patch 3/5] ShellPkg/TftpDynamicCommand: Add one option for tftp > command to specify windowsize. > Importance: High >=20 > Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D886 >=20 > This patch is to define one new option for TFTP shell command to specify = the > windowsize option as defined in RFC 7440. Valid range is between 1 and 64= , > default value is 1. >=20 > Note that: RFC 7440 does not mention max window size value, but for the > stability reason, the value is limited to 64. >=20 > Cc: Ye Ting > Cc: Fu Siyuan > Cc: Carsey Jaben > Cc: Shao Ming > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Wu Jiaxin > --- > .../DynamicCommand/TftpDynamicCommand/Tftp.c | 65 > ++++++++++++++++--- > .../TftpDynamicCommand/Tftp.uni | 6 +- > 2 files changed, 59 insertions(+), 12 deletions(-) >=20 > diff --git a/ShellPkg/DynamicCommand/TftpDynamicCommand/Tftp.c > b/ShellPkg/DynamicCommand/TftpDynamicCommand/Tftp.c > index 44be6d4e76..c66be6b9d9 100644 > --- a/ShellPkg/DynamicCommand/TftpDynamicCommand/Tftp.c > +++ b/ShellPkg/DynamicCommand/TftpDynamicCommand/Tftp.c > @@ -181,10 +181,11 @@ DownloadFile ( > IN EFI_MTFTP4_PROTOCOL *Mtftp4, > IN CONST CHAR16 *FilePath, > IN CONST CHAR8 *AsciiFilePath, > IN UINTN FileSize, > IN UINT16 BlockSize, > + IN UINT16 WindowSize, > OUT VOID **Data > ); >=20 > /** > Update the progress of a file download > @@ -225,10 +226,11 @@ STATIC CONST SHELL_PARAM_ITEM ParamList[] =3D { > {L"-l", TypeValue}, > {L"-r", TypeValue}, > {L"-c", TypeValue}, > {L"-t", TypeValue}, > {L"-s", TypeValue}, > + {L"-w", TypeValue}, > {NULL , TypeMax} > }; >=20 > /// > /// The default block size (512) of tftp is defined in the RFC1350. > @@ -237,11 +239,21 @@ STATIC CONST SHELL_PARAM_ITEM ParamList[] =3D { > /// > /// The valid range of block size option is defined in the RFC2348. > /// > #define MTFTP_MIN_BLKSIZE 8 > #define MTFTP_MAX_BLKSIZE 65464 > - > +/// > +/// The default windowsize (1) of tftp. > +/// > +#define MTFTP_DEFAULT_WINDOWSIZE 1 > +/// > +/// The valid range of window size option. > +/// Note that: RFC 7440 does not mention max window size value, but for > the > +/// stability reason, the value is limited to 64. > +/// > +#define MTFTP_MIN_WINDOWSIZE 1 > +#define MTFTP_MAX_WINDOWSIZE 64 >=20 > /** > Function for 'tftp' command. >=20 > @param[in] ImageHandle Handle to the Image (NULL if Internal). > @@ -286,19 +298,21 @@ RunTftp ( > UINTN FileSize; > UINTN DataSize; > VOID *Data; > SHELL_FILE_HANDLE FileHandle; > UINT16 BlockSize; > + UINT16 WindowSize; >=20 > ShellStatus =3D SHELL_INVALID_PARAMETER; > ProblemParam =3D NULL; > NicFound =3D FALSE; > AsciiRemoteFilePath =3D NULL; > Handles =3D NULL; > FileSize =3D 0; > DataSize =3D 0; > BlockSize =3D MTFTP_DEFAULT_BLKSIZE; > + WindowSize =3D MTFTP_DEFAULT_WINDOWSIZE; >=20 > // > // Initialize the Shell library (we must be in non-auto-init...) > // > Status =3D ShellInitialize (); > @@ -434,10 +448,24 @@ RunTftp ( > ); > goto Error; > } > } >=20 > + ValueStr =3D ShellCommandLineGetValue (CheckPackage, L"-w"); > + if (ValueStr !=3D NULL) { > + if (!StringToUint16 (ValueStr, &WindowSize)) { > + goto Error; > + } > + if (WindowSize < MTFTP_MIN_WINDOWSIZE || WindowSize > > MTFTP_MAX_WINDOWSIZE) { > + ShellPrintHiiEx ( > + -1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), > + mTftpHiiHandle, L"tftp", ValueStr > + ); > + goto Error; > + } > + } > + > // > // Locate all MTFTP4 Service Binding protocols > // > ShellStatus =3D SHELL_NOT_FOUND; > Status =3D gBS->LocateHandleBuffer ( > @@ -508,11 +536,11 @@ RunTftp ( > mTftpHiiHandle, RemoteFilePath, NicName, Status > ); > goto NextHandle; > } >=20 > - Status =3D DownloadFile (Mtftp4, RemoteFilePath, AsciiRemoteFilePath= , > FileSize, BlockSize, &Data); > + Status =3D DownloadFile (Mtftp4, RemoteFilePath, AsciiRemoteFilePath= , > FileSize, BlockSize, WindowSize, &Data); > if (EFI_ERROR (Status)) { > ShellPrintHiiEx ( > -1, -1, NULL, STRING_TOKEN (STR_TFTP_ERR_DOWNLOAD), > mTftpHiiHandle, RemoteFilePath, NicName, Status > ); > @@ -894,20 +922,21 @@ DownloadFile ( > IN EFI_MTFTP4_PROTOCOL *Mtftp4, > IN CONST CHAR16 *FilePath, > IN CONST CHAR8 *AsciiFilePath, > IN UINTN FileSize, > IN UINT16 BlockSize, > + IN UINT16 WindowSize, > OUT VOID **Data > ) > { > EFI_STATUS Status; > EFI_PHYSICAL_ADDRESS PagesAddress; > VOID *Buffer; > DOWNLOAD_CONTEXT *TftpContext; > EFI_MTFTP4_TOKEN Mtftp4Token; > - EFI_MTFTP4_OPTION ReqOpt; > - UINT8 OptBuf[10]; > + UINT8 BlksizeBuf[10]; > + UINT8 WindowsizeBuf[10]; >=20 > // Downloaded file can be large. BS.AllocatePages() is more faster > // than AllocatePool() and avoid fragmentation. > // The downloaded file could be an EFI application. Marking the > // allocated page as EfiBootServicesCode would allow to execute a > @@ -936,17 +965,29 @@ DownloadFile ( > Mtftp4Token.Filename =3D (UINT8*)AsciiFilePath; > Mtftp4Token.BufferSize =3D FileSize; > Mtftp4Token.Buffer =3D Buffer; > Mtftp4Token.CheckPacket =3D CheckPacket; > Mtftp4Token.Context =3D (VOID*)TftpContext; > + Mtftp4Token.OptionCount =3D 0; > + Mtftp4Token.OptionList =3D AllocatePool (sizeof (EFI_MTFTP4_OPTION) * > 2); > + if (Mtftp4Token.OptionList =3D=3D NULL) { > + Status =3D EFI_OUT_OF_RESOURCES; > + goto Error; > + } > + > if (BlockSize !=3D MTFTP_DEFAULT_BLKSIZE) { > - ReqOpt.OptionStr =3D (UINT8 *) "blksize"; > - AsciiSPrint ((CHAR8 *)OptBuf, sizeof (OptBuf), "%d", BlockSize); > - ReqOpt.ValueStr =3D OptBuf; > + Mtftp4Token.OptionList[Mtftp4Token.OptionCount].OptionStr =3D (UINT8 > *) "blksize"; > + AsciiSPrint ((CHAR8 *) BlksizeBuf, sizeof (BlksizeBuf), "%d", BlockS= ize); > + Mtftp4Token.OptionList[Mtftp4Token.OptionCount].ValueStr =3D > BlksizeBuf; > + Mtftp4Token.OptionCount ++; > + } >=20 > - Mtftp4Token.OptionCount =3D 1; > - Mtftp4Token.OptionList =3D &ReqOpt; > + if (WindowSize !=3D MTFTP_DEFAULT_WINDOWSIZE) { > + Mtftp4Token.OptionList[Mtftp4Token.OptionCount].OptionStr =3D (UINT8 > *) "windowsize"; > + AsciiSPrint ((CHAR8 *) WindowsizeBuf, sizeof (WindowsizeBuf), "%d", > WindowSize); > + Mtftp4Token.OptionList[Mtftp4Token.OptionCount].ValueStr =3D > WindowsizeBuf; > + Mtftp4Token.OptionCount ++; > } >=20 > ShellPrintHiiEx ( > -1, -1, NULL, STRING_TOKEN (STR_TFTP_DOWNLOADING), > mTftpHiiHandle, FilePath > @@ -958,14 +999,18 @@ DownloadFile ( > mTftpHiiHandle > ); >=20 > Error : >=20 > - if (TftpContext =3D=3D NULL) { > + if (TftpContext !=3D NULL) { > FreePool (TftpContext); > } >=20 > + if (Mtftp4Token.OptionList !=3D NULL) { > + FreePool (Mtftp4Token.OptionList); > + } > + > if (EFI_ERROR (Status)) { > gBS->FreePages (PagesAddress, EFI_SIZE_TO_PAGES (FileSize)); > return Status; > } >=20 > diff --git a/ShellPkg/DynamicCommand/TftpDynamicCommand/Tftp.uni > b/ShellPkg/DynamicCommand/TftpDynamicCommand/Tftp.uni > index 1393ba5679..654e42ad23 100644 > --- a/ShellPkg/DynamicCommand/TftpDynamicCommand/Tftp.uni > +++ b/ShellPkg/DynamicCommand/TftpDynamicCommand/Tftp.uni > @@ -1,9 +1,9 @@ > // /** > // > // (C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP
> -// Copyright (c) 2010 - 2017, Intel Corporation. All rights reserved. > +// Copyright (c) 2010 - 2018, 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 > // > @@ -48,11 +48,11 @@ > ".SH NAME\r\n" > "Download a file from TFTP server.\r\n" > ".SH SYNOPSIS\r\n" > " \r\n" > "TFTP [-i interface] [-l ] [-r ] [-c ] [-t > ]\r\n" > -" [-s ] host remotefilepath [localfilepath]\r\n" > +" [-s ] [-w ] host remotefilepath > [localfilepath]\r\n" > ".SH OPTIONS\r\n" > " \r\n" > " -i interface - Specifies an adapter name, i.e., eth0.\r\n" > " -l port - Specifies the local port number. Default value is = 0\r\n" > " and the port number is automatically assigned.\r\n= " > @@ -61,10 +61,12 @@ > " wait for a response. The default value is 6.\r\n" > " -t - The number of seconds to wait for a response after= \r\n" > " sending a request packet. Default value is 4s.\r\n= " > " -s - Specifies the TFTP blksize option as defined in RF= C > 2348.\r\n" > " Valid range is between 8 and 65464, default value = is 512.\r\n" > +" -w - Specifies the TFTP windowsize option as defined in > RFC 7440.\r\n" > +" Valid range is between 1 and 64, default value is = 1.\r\n" > " host - Specify TFTP Server IPv4 address.\r\n" > " remotefilepath - TFTP server file path to download the file.\r\n" > " localfilepath - Local destination file path.\r\n" > ".SH DESCRIPTION\r\n" > " \r\n" > -- > 2.17.1.windows.2