The implementation for the 'tftp' Shell command.\r
\r
Copyright (c) 2015, ARM Ltd. All rights reserved.<BR>\r
+ Copyright (c) 2015, Intel Corporation. All rights reserved. <BR>\r
+ (C) Copyright 2015 Hewlett Packard Enterprise Development LP<BR>\r
\r
This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
\r
#include "UefiShellTftpCommandLib.h"\r
\r
+#define IP4_CONFIG2_INTERFACE_INFO_NAME_LENGTH 32\r
+\r
/*\r
Constant strings and definitions related to the message indicating the amount of\r
progress in the dowloading of a TFTP file.\r
@param[in] NicNumber The network physical device number.\r
@param[out] NicName Address where to store the NIC name.\r
The memory area has to be at least\r
- IP4_NIC_NAME_LENGTH bytes wide.\r
+ IP4_CONFIG2_INTERFACE_INFO_NAME_LENGTH \r
+ double byte wide.\r
\r
@return EFI_SUCCESS The name of the NIC was returned.\r
@return Others The creation of the child for the Managed\r
**/\r
STATIC \r
EFI_STATUS \r
+EFIAPI\r
CheckPacket (\r
IN EFI_MTFTP4_PROTOCOL *This,\r
IN EFI_MTFTP4_TOKEN *Token,\r
EFI_HANDLE *Handles;\r
UINTN HandleCount;\r
UINTN NicNumber;\r
- CHAR16 NicName[IP4_NIC_NAME_LENGTH];\r
+ CHAR16 NicName[IP4_CONFIG2_INTERFACE_INFO_NAME_LENGTH];\r
EFI_HANDLE ControllerHandle;\r
EFI_HANDLE Mtftp4ChildHandle;\r
EFI_MTFTP4_PROTOCOL *Mtftp4;\r
NicFound = FALSE;\r
AsciiRemoteFilePath = NULL;\r
Handles = NULL;\r
+ FileSize = 0;\r
\r
//\r
// Initialize the Shell library (we must be in non-auto-init...)\r
}\r
\r
RemoteFilePath = ShellCommandLineGetRawValue (CheckPackage, 2);\r
+ ASSERT(RemoteFilePath != NULL);\r
AsciiRemoteFilePath = AllocatePool (\r
(StrLen (RemoteFilePath) + 1) * sizeof (CHAR8)\r
);\r
return FALSE;\r
}\r
\r
- *Value = Val;\r
+ *Value = (UINT16)Val;\r
return TRUE;\r
}\r
\r
@param[in] NicNumber The network physical device number.\r
@param[out] NicName Address where to store the NIC name.\r
The memory area has to be at least\r
- IP4_NIC_NAME_LENGTH bytes wide.\r
+ IP4_CONFIG2_INTERFACE_INFO_NAME_LENGTH \r
+ double byte wide.\r
\r
@return EFI_SUCCESS The name of the NIC was returned.\r
@return Others The creation of the child for the Managed\r
\r
UnicodeSPrint (\r
NicName,\r
- IP4_NIC_NAME_LENGTH,\r
+ IP4_CONFIG2_INTERFACE_INFO_NAME_LENGTH,\r
SnpMode.IfType == NET_IFTYPE_ETHERNET ?\r
L"eth%d" :\r
L"unk%d" ,\r
**/\r
STATIC\r
EFI_STATUS\r
+EFIAPI\r
CheckPacket (\r
IN EFI_MTFTP4_PROTOCOL *This,\r
IN EFI_MTFTP4_TOKEN *Token,\r
{\r
DOWNLOAD_CONTEXT *Context;\r
CHAR16 Progress[TFTP_PROGRESS_MESSAGE_SIZE];\r
- UINT64 NbOfKb;\r
+ UINTN NbOfKb;\r
UINTN Index;\r
UINTN LastStep;\r
UINTN Step;\r
+ EFI_STATUS Status;\r
\r
if ((NTOHS (Packet->OpCode)) != EFI_MTFTP4_OPCODE_DATA) {\r
return EFI_SUCCESS;\r
NbOfKb = Context->DownloadedNbOfBytes / 1024;\r
\r
Progress[0] = L'\0';\r
- LastStep = (Context->LastReportedNbOfBytes * TFTP_PROGRESS_SLIDER_STEPS) /\r
- Context->FileSize;\r
- Step = (Context->DownloadedNbOfBytes * TFTP_PROGRESS_SLIDER_STEPS) /\r
- Context->FileSize;\r
+ LastStep = (Context->LastReportedNbOfBytes * TFTP_PROGRESS_SLIDER_STEPS) / Context->FileSize;\r
+ Step = (Context->DownloadedNbOfBytes * TFTP_PROGRESS_SLIDER_STEPS) / Context->FileSize;\r
+\r
if (Step <= LastStep) {\r
return EFI_SUCCESS;\r
}\r
\r
ShellPrintEx (-1, -1, L"%s", mTftpProgressDelete);\r
\r
- StrCpy (Progress, mTftpProgressFrame);\r
+ Status = StrCpyS (Progress, TFTP_PROGRESS_MESSAGE_SIZE, mTftpProgressFrame);\r
+ if (EFI_ERROR(Status)) {\r
+ return Status;\r
+ }\r
for (Index = 1; Index < Step; Index++) {\r
Progress[Index] = L'=';\r
}\r