/** @file\r
Routines to process Wrq (upload).\r
- \r
-Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
-This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution. The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php<BR>\r
\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
\r
**/\r
\r
FreePool (DataBuf);\r
}\r
\r
+ if (UdpPacket != NULL) {\r
+ NetbufFree (UdpPacket);\r
+ }\r
+\r
Mtftp4SendError (\r
Instance,\r
EFI_MTFTP4_ERRORCODE_REQUEST_DENIED,\r
\r
\r
/**\r
- Function to handle received ACK packet. \r
- \r
- If the ACK number matches the expected block number, and there are more \r
+ Function to handle received ACK packet.\r
+\r
+ If the ACK number matches the expected block number, and there are more\r
data pending, send the next block. Otherwise tell the caller that we are done.\r
\r
@param Instance The MTFTP upload session\r
{\r
UINT16 AckNum;\r
INTN Expected;\r
- UINT64 TotalBlock;\r
- \r
+ UINT64 BlockCounter;\r
+\r
*Completed = FALSE;\r
AckNum = NTOHS (Packet->Ack.Block[0]);\r
Expected = Mtftp4GetNextBlockNum (&Instance->Blocks);\r
//\r
// Remove the acked block number, if this is the last block number,\r
// tell the Mtftp4WrqInput to finish the transfer. This is the last\r
- // block number if the block range are empty..\r
+ // block number if the block range are empty.\r
//\r
- Mtftp4RemoveBlockNum (&Instance->Blocks, AckNum, *Completed,&TotalBlock);\r
+ Mtftp4RemoveBlockNum (&Instance->Blocks, AckNum, *Completed, &BlockCounter);\r
\r
Expected = Mtftp4GetNextBlockNum (&Instance->Blocks);\r
\r
if (Expected < 0) {\r
- \r
+\r
//\r
// The block range is empty. It may either because the the last\r
// block has been ACKed, or the sequence number just looped back,\r
\r
\r
/**\r
- Check whether the received OACK is valid. \r
- \r
+ Check whether the received OACK is valid.\r
+\r
The OACK is valid only if:\r
1. It only include options requested by us\r
2. It can only include a smaller block size\r
\r
\r
/**\r
- Function to handle the MTFTP OACK packet. \r
- \r
+ Function to handle the MTFTP OACK packet.\r
+\r
It parses the packet's options, and update the internal states of the session.\r
\r
@param Instance The MTFTP session\r
// Parse and validate the options from server\r
//\r
ZeroMem (&Reply, sizeof (MTFTP4_OPTION));\r
- Status = Mtftp4ParseOptionOack (Packet, Len, &Reply);\r
+ Status = Mtftp4ParseOptionOack (Packet, Len, Instance->Operation, &Reply);\r
\r
if (EFI_ERROR (Status) || !Mtftp4WrqOackValid (&Reply, &Instance->RequestOption)) {\r
//\r
\r
} else {\r
Packet = (EFI_MTFTP4_PACKET *) NetbufGetByte (UdpPacket, 0, NULL);\r
+ ASSERT (Packet != NULL);\r
}\r
\r
Opcode = NTOHS (Packet->OpCode);\r
case EFI_MTFTP4_OPCODE_ERROR:\r
Status = EFI_TFTP_ERROR;\r
break;\r
- \r
+\r
default:\r
break;\r
}\r
\r
/**\r
Start the MTFTP session for upload.\r
- \r
- It will first init some states, then send the WRQ request packet, \r
+\r
+ It will first init some states, then send the WRQ request packet,\r
and start receiving the packet.\r
\r
@param Instance The MTFTP session\r